scm2cpp-learn 0.18.0__py3-none-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. scm2cpp_learn/__init__.py +3836 -0
  2. scm2cpp_learn/_classifiers.cp312-win_amd64.pyd +0 -0
  3. scm2cpp_learn/_compat.py +284 -0
  4. scm2cpp_learn/_generated/__init__.py +0 -0
  5. scm2cpp_learn/_generated/_loader.py +41 -0
  6. scm2cpp_learn/_generated/_loader_accel_cublas.py +173 -0
  7. scm2cpp_learn/_generated/_loader_classifiers.py +308 -0
  8. scm2cpp_learn/_generated/_loader_derived_blas.py +29 -0
  9. scm2cpp_learn/_generated/_loader_derived_cublas.py +29 -0
  10. scm2cpp_learn/_generated/_loader_derived_loops.py +29 -0
  11. scm2cpp_learn/_generated/_loader_gpu_cuda.py +313 -0
  12. scm2cpp_learn/_generated/_loader_gramops_blas.py +692 -0
  13. scm2cpp_learn/_generated/_loader_gramops_loops.py +711 -0
  14. scm2cpp_learn/_generated/_loader_nmf_blas.py +29 -0
  15. scm2cpp_learn/_generated/_loader_nmf_cublas.py +29 -0
  16. scm2cpp_learn/_generated/_loader_nmf_loops.py +29 -0
  17. scm2cpp_learn/_generated/accel_cublas/accel.cpp +24 -0
  18. scm2cpp_learn/_generated/accel_cublas/accel.hpp +1178 -0
  19. scm2cpp_learn/_generated/accel_cublas/accel_capi.cpp +76 -0
  20. scm2cpp_learn/_generated/classifiers.cpp +37 -0
  21. scm2cpp_learn/_generated/classifiers.hpp +3745 -0
  22. scm2cpp_learn/_generated/classifiers_capi.cpp +115 -0
  23. scm2cpp_learn/_generated/derived_blas/lasso_design.cpp +5 -0
  24. scm2cpp_learn/_generated/derived_blas/lasso_design.hpp +156 -0
  25. scm2cpp_learn/_generated/derived_blas/lasso_design_capi.cpp +19 -0
  26. scm2cpp_learn/_generated/derived_cublas/lasso_design.cpp +5 -0
  27. scm2cpp_learn/_generated/derived_cublas/lasso_design.hpp +158 -0
  28. scm2cpp_learn/_generated/derived_cublas/lasso_design_capi.cpp +19 -0
  29. scm2cpp_learn/_generated/derived_loops/lasso_design.cpp +5 -0
  30. scm2cpp_learn/_generated/derived_loops/lasso_design.hpp +179 -0
  31. scm2cpp_learn/_generated/derived_loops/lasso_design_capi.cpp +19 -0
  32. scm2cpp_learn/_generated/gpu_cuda/gpu.cpp +37 -0
  33. scm2cpp_learn/_generated/gpu_cuda/gpu.hpp +3846 -0
  34. scm2cpp_learn/_generated/gpu_cuda/gpu_capi.cpp +308 -0
  35. scm2cpp_learn/_generated/gramops_blas/gramops.cpp +82 -0
  36. scm2cpp_learn/_generated/gramops_blas/gramops.hpp +5411 -0
  37. scm2cpp_learn/_generated/gramops_blas/gramops_capi.cpp +244 -0
  38. scm2cpp_learn/_generated/gramops_loops/gramops.cpp +82 -0
  39. scm2cpp_learn/_generated/gramops_loops/gramops.hpp +6395 -0
  40. scm2cpp_learn/_generated/gramops_loops/gramops_capi.cpp +250 -0
  41. scm2cpp_learn/_generated/lasso_cov.cpp +7 -0
  42. scm2cpp_learn/_generated/lasso_cov.hpp +152 -0
  43. scm2cpp_learn/_generated/lasso_cov_capi.cpp +25 -0
  44. scm2cpp_learn/_generated/nmf_blas/nmf_cd.cpp +5 -0
  45. scm2cpp_learn/_generated/nmf_blas/nmf_cd.hpp +132 -0
  46. scm2cpp_learn/_generated/nmf_blas/nmf_cd_capi.cpp +19 -0
  47. scm2cpp_learn/_generated/nmf_cublas/nmf_cd.cpp +5 -0
  48. scm2cpp_learn/_generated/nmf_cublas/nmf_cd.hpp +136 -0
  49. scm2cpp_learn/_generated/nmf_cublas/nmf_cd_capi.cpp +19 -0
  50. scm2cpp_learn/_generated/nmf_loops/nmf_cd.cpp +5 -0
  51. scm2cpp_learn/_generated/nmf_loops/nmf_cd.hpp +167 -0
  52. scm2cpp_learn/_generated/nmf_loops/nmf_cd_capi.cpp +19 -0
  53. scm2cpp_learn/_generated/scm2cpp-blas.hpp +158 -0
  54. scm2cpp_learn/_generated/scm2cpp-cublas.hpp +155 -0
  55. scm2cpp_learn/_generated/scm2cpp-cuda.hpp +285 -0
  56. scm2cpp_learn/_generated/scm2cpp.hpp +1627 -0
  57. scm2cpp_learn/_gramops_blas.cp312-win_amd64.pyd +0 -0
  58. scm2cpp_learn/_lasso_cov.cp312-win_amd64.pyd +0 -0
  59. scm2cpp_learn/_lasso_derived_blas.cp312-win_amd64.pyd +0 -0
  60. scm2cpp_learn/_libfind.py +153 -0
  61. scm2cpp_learn/_nmf_blas.cp312-win_amd64.pyd +0 -0
  62. scm2cpp_learn/batch_capi.cu +428 -0
  63. scm2cpp_learn-0.18.0.dist-info/DELVEWHEEL +2 -0
  64. scm2cpp_learn-0.18.0.dist-info/METADATA +1171 -0
  65. scm2cpp_learn-0.18.0.dist-info/RECORD +72 -0
  66. scm2cpp_learn-0.18.0.dist-info/WHEEL +5 -0
  67. scm2cpp_learn-0.18.0.dist-info/top_level.txt +1 -0
  68. scm2cpp_learn.libs/.load-order-scm2cpp_learn-0.18.0 +4 -0
  69. scm2cpp_learn.libs/libopenblas-0486735c359a67419d8832e3c40e2837.dll +4 -0
  70. scm2cpp_learn.libs/msvcp140-73438573e87f9a2fd944b01def13566d.dll +0 -0
  71. scm2cpp_learn.libs/vcruntime140-052ad6a20d375957e82aa6a3c441ea54.dll +0 -0
  72. scm2cpp_learn.libs/vcruntime140_1-a198370e11c6e7469d1cf0ef5b3f433d.dll +0 -0
@@ -0,0 +1,284 @@
1
+ """The scikit-learn estimator interface, with scikit-learn optional.
2
+
3
+ With scikit-learn installed the estimators derive from its
4
+ BaseEstimator and mixins, and their inputs go through its
5
+ validate_data, so clone, get_params / set_params, GridSearchCV,
6
+ Pipeline and check_estimator see ordinary estimators. Without it
7
+ (numpy alone, as the wheels need) a small stand-in gives the same
8
+ get_params / set_params / score and the checks that matter for the
9
+ kernels: a 2-D float64 C-ordered X, finite values, the feature count
10
+ remembered at fit and compared at predict.
11
+ """
12
+ import inspect
13
+
14
+ import numpy as np
15
+
16
+ try:
17
+ from sklearn.base import (BaseEstimator, ClassifierMixin, RegressorMixin,
18
+ TransformerMixin, DensityMixin)
19
+ from sklearn.utils.validation import check_is_fitted
20
+ from sklearn.utils.multiclass import check_classification_targets
21
+ try:
22
+ from sklearn.utils.validation import validate_data as _sk_validate
23
+ except ImportError: # scikit-learn before 1.6
24
+ def _sk_validate(est, *args, **kw):
25
+ return est._validate_data(*args, **kw)
26
+ HAVE_SKLEARN = True
27
+ except ImportError:
28
+ HAVE_SKLEARN = False
29
+
30
+ class NotFittedError(ValueError, AttributeError):
31
+ pass
32
+
33
+ class BaseEstimator:
34
+ @classmethod
35
+ def _get_param_names(cls):
36
+ sig = inspect.signature(cls.__init__)
37
+ return sorted(p.name for p in sig.parameters.values()
38
+ if p.name != "self" and p.kind not in
39
+ (p.VAR_POSITIONAL, p.VAR_KEYWORD))
40
+
41
+ def get_params(self, deep=True):
42
+ return {k: getattr(self, k) for k in self._get_param_names()}
43
+
44
+ def set_params(self, **params):
45
+ valid = self._get_param_names()
46
+ for k, v in params.items():
47
+ if k not in valid:
48
+ raise ValueError(f"invalid parameter {k!r} for {type(self).__name__}")
49
+ setattr(self, k, v)
50
+ return self
51
+
52
+ def __repr__(self):
53
+ args = ", ".join(f"{k}={v!r}" for k, v in self.get_params().items())
54
+ return f"{type(self).__name__}({args})"
55
+
56
+ class ClassifierMixin:
57
+ _estimator_type = "classifier"
58
+
59
+ def score(self, X, y, sample_weight=None):
60
+ return float(np.average(self.predict(X) == np.asarray(y),
61
+ weights=sample_weight))
62
+
63
+ class RegressorMixin:
64
+ _estimator_type = "regressor"
65
+
66
+ def score(self, X, y, sample_weight=None):
67
+ y = np.asarray(y, dtype=np.float64)
68
+ r = y - self.predict(X)
69
+ w = None if sample_weight is None else np.asarray(sample_weight)
70
+ ss_res = np.average(r * r, axis=0, weights=w)
71
+ ym = np.average(y, axis=0, weights=w)
72
+ ss_tot = np.average((y - ym) ** 2, axis=0, weights=w)
73
+ return float(np.mean(1.0 - ss_res / ss_tot))
74
+
75
+ class TransformerMixin:
76
+ def fit_transform(self, X, y=None, **fit_params):
77
+ return self.fit(X, y, **fit_params).transform(X)
78
+
79
+ class DensityMixin:
80
+ _estimator_type = "DensityEstimator"
81
+
82
+ def score(self, X, y=None):
83
+ pass
84
+
85
+ def check_is_fitted(est, attributes=None):
86
+ if not any(k.endswith("_") and not k.startswith("__") for k in vars(est)):
87
+ raise NotFittedError(f"This {type(est).__name__} instance is not fitted yet; "
88
+ "call fit first")
89
+
90
+ def check_classification_targets(y):
91
+ if np.asarray(y).dtype.kind == "f" and not np.all(np.mod(y, 1) == 0):
92
+ raise ValueError("Unknown label type: continuous")
93
+
94
+ def _as_x(X):
95
+ X = np.ascontiguousarray(X, dtype=np.float64)
96
+ if X.ndim != 2:
97
+ raise ValueError(f"Expected a 2D array, got {X.ndim}D; reshape it")
98
+ if X.shape[0] < 1 or X.shape[1] < 1:
99
+ raise ValueError(f"Found array with shape {X.shape}; a minimum of 1 is required")
100
+ with np.errstate(over="ignore", invalid="ignore"):
101
+ finite = np.isfinite(X.sum()) or np.isfinite(X).all()
102
+ if not finite:
103
+ raise ValueError("Input X contains NaN or infinity")
104
+ return X
105
+
106
+ def _sk_validate(est, X="no_validation", y="no_validation", reset=True,
107
+ multi_output=False, y_numeric=False, dtype=None, order=None,
108
+ ensure_min_samples=1, ensure_min_features=1, **kw):
109
+ out = []
110
+ if not (isinstance(X, str) and X == "no_validation"):
111
+ X = _as_x(X)
112
+ if X.shape[0] < ensure_min_samples or X.shape[1] < ensure_min_features:
113
+ raise ValueError(f"Found array with shape {X.shape}; a minimum of "
114
+ f"{ensure_min_samples} samples and {ensure_min_features} "
115
+ f"features is required by {type(est).__name__}")
116
+ if reset:
117
+ est.n_features_in_ = X.shape[1]
118
+ elif X.shape[1] != getattr(est, "n_features_in_", X.shape[1]):
119
+ raise ValueError(f"X has {X.shape[1]} features, but {type(est).__name__} "
120
+ f"is expecting {est.n_features_in_} features as input")
121
+ out.append(X)
122
+ if not (isinstance(y, str) and y == "no_validation"):
123
+ if y is None:
124
+ raise ValueError(f"{type(est).__name__} requires y to be passed, "
125
+ "but the target y is None")
126
+ y = np.asarray(y)
127
+ if not multi_output and y.ndim == 2 and y.shape[1] == 1:
128
+ y = y.ravel()
129
+ if y_numeric or y.dtype.kind in "biuf":
130
+ y = np.ascontiguousarray(y, dtype=np.float64) if y_numeric else y
131
+ if out and len(y) != out[0].shape[0]:
132
+ raise ValueError("X and y have inconsistent numbers of samples")
133
+ out.append(y)
134
+ return out[0] if len(out) == 1 else tuple(out)
135
+
136
+
137
+ __all__ = ["BaseEstimator", "ClassifierMixin", "RegressorMixin", "TransformerMixin",
138
+ "DensityMixin", "check_is_fitted", "HAVE_SKLEARN",
139
+ "fit_xy", "fit_x", "pred_x", "classes_of", "Tagged"]
140
+
141
+
142
+ # The fast path. scikit-learn's validate_data costs about 100 us a
143
+ # call whatever the size (feature names, array namespaces, the config),
144
+ # which is most of a small fit and nearly all of a small predict. An
145
+ # input that is already what the kernels take -- a plain ndarray,
146
+ # float64, C-ordered, 2-D, non-empty, finite -- needs none of that
147
+ # machinery, so it is checked here directly; anything else (a list, a
148
+ # DataFrame, another dtype, NaN, a wrong feature count) goes through
149
+ # validate_data, which raises the error scikit-learn would. Finiteness
150
+ # is tested by one sum, as scikit-learn tests it first, and skipped
151
+ # under sklearn.set_config(assume_finite=True).
152
+ if HAVE_SKLEARN:
153
+ from sklearn import get_config as _get_config
154
+
155
+ def _assume_finite():
156
+ return _get_config()["assume_finite"]
157
+ else:
158
+ def _assume_finite():
159
+ return False
160
+
161
+
162
+ def _plain(X):
163
+ return (type(X) is np.ndarray and X.dtype == np.float64 and X.ndim == 2
164
+ and X.flags.c_contiguous and X.shape[0] > 0 and X.shape[1] > 0)
165
+
166
+
167
+ def _finite(a):
168
+ if _assume_finite():
169
+ return True
170
+ with np.errstate(over="ignore", invalid="ignore"):
171
+ return bool(np.isfinite(a.sum()))
172
+
173
+
174
+ def _labels_ok(y):
175
+ # what check_classification_targets accepts, in the cheap cases:
176
+ # integer or boolean labels, or floats that are all integral
177
+ k = y.dtype.kind
178
+ if k in "biu":
179
+ return True
180
+ if k == "f":
181
+ with np.errstate(invalid="ignore"):
182
+ return bool(np.isfinite(y.sum())) and bool((y == np.floor(y)).all())
183
+ return False
184
+
185
+
186
+ def _reset_names(est):
187
+ # what validate_data does on fit with an ndarray: no feature names
188
+ if "feature_names_in_" in vars(est):
189
+ del est.feature_names_in_
190
+
191
+
192
+ def fit_xy(est, X, y, *, y_numeric=True, multi_output=False, classifier=False):
193
+ """X as a float64 C-ordered 2-D array and y, validated, n_features_in_ set."""
194
+ if (_plain(X) and type(y) is np.ndarray and y.shape[0:1] == X.shape[0:1]
195
+ and (y.ndim == 1 or (multi_output and y.ndim == 2 and y.shape[1] > 1))
196
+ and _finite(X)):
197
+ if classifier:
198
+ ok = _labels_ok(y)
199
+ elif y_numeric:
200
+ ok = y.dtype == np.float64 and y.flags.c_contiguous and _finite(y)
201
+ else:
202
+ ok = y.dtype.kind in "biuf" and _finite(y)
203
+ if ok:
204
+ est.n_features_in_ = X.shape[1]
205
+ _reset_names(est)
206
+ return X, y
207
+ X, y = _sk_validate(est, X, y, dtype=np.float64, order="C",
208
+ y_numeric=y_numeric and not classifier, multi_output=multi_output)
209
+ if classifier:
210
+ check_classification_targets(y)
211
+ elif y_numeric:
212
+ y = np.ascontiguousarray(y, dtype=np.float64)
213
+ return X, y
214
+
215
+
216
+ def fit_x(est, X, ensure_min_samples=1, ensure_min_features=1):
217
+ """X alone (unsupervised fit), validated, n_features_in_ set."""
218
+ if (_plain(X) and X.shape[0] >= ensure_min_samples and X.shape[1] >= ensure_min_features
219
+ and _finite(X)):
220
+ est.n_features_in_ = X.shape[1]
221
+ _reset_names(est)
222
+ return X
223
+ return _sk_validate(est, X, dtype=np.float64, order="C",
224
+ ensure_min_samples=ensure_min_samples,
225
+ ensure_min_features=ensure_min_features)
226
+
227
+
228
+ def pred_x(est, X, **kw):
229
+ """X at predict / transform time: fitted, and as many features as at fit."""
230
+ d = vars(est)
231
+ if (not kw and _plain(X) and X.shape[1] == d.get("n_features_in_")
232
+ and "feature_names_in_" not in d and _finite(X)):
233
+ return X
234
+ check_is_fitted(est)
235
+ return _sk_validate(est, X, reset=False, dtype=np.float64, order="C", **kw)
236
+
237
+
238
+ def classes_of(y):
239
+ """classes_ and the 0-based label index, as LabelEncoder has them."""
240
+ return np.unique(np.asarray(y), return_inverse=True)
241
+
242
+
243
+ class Tagged:
244
+ """Declares scikit-learn tags from a few class attributes.
245
+
246
+ _binary_only: the solver is a two-class one (multi_class False).
247
+ _positive_X / _positive_y: the input or target must be non-negative.
248
+ _multi_output: y may be (n, k), and must be for _multi_output == "only".
249
+ _no_y: an unsupervised fit (y ignored).
250
+ """
251
+ _binary_only = False
252
+ _positive_X = False
253
+ _positive_y = False
254
+ _multi_output = False
255
+ _pairwise = False
256
+
257
+ def __sklearn_tags__(self):
258
+ tags = super().__sklearn_tags__()
259
+ tags.input_tags.positive_only = self._positive_X
260
+ tags.input_tags.pairwise = bool(self._pairwise_now())
261
+ if tags.target_tags is not None:
262
+ tags.target_tags.positive_only = self._positive_y
263
+ if self._multi_output:
264
+ tags.target_tags.multi_output = True
265
+ if self._multi_output == "only":
266
+ tags.target_tags.single_output = False
267
+ if self._binary_only and tags.classifier_tags is not None:
268
+ tags.classifier_tags.multi_class = False
269
+ return tags
270
+
271
+ def _more_tags(self): # scikit-learn before 1.6
272
+ t = {"binary_only": self._binary_only, "pairwise": bool(self._pairwise_now())}
273
+ if self._positive_X:
274
+ t["requires_positive_X"] = True
275
+ if self._positive_y:
276
+ t["requires_positive_y"] = True
277
+ if self._multi_output:
278
+ t["multioutput"] = True
279
+ if self._multi_output == "only":
280
+ t["multioutput_only"] = True
281
+ return t
282
+
283
+ def _pairwise_now(self):
284
+ return self._pairwise and getattr(self, "kernel", None) == "precomputed"
File without changes
@@ -0,0 +1,41 @@
1
+ # ctypes loader for liblasso_cov.so, generated alongside it.
2
+ # Arrays are numpy arrays of the declared dtype; they are made
3
+ # contiguous on the way in and mutated in place where the translated
4
+ # function mutates them.
5
+ import ctypes
6
+ import numpy as np
7
+ from pathlib import Path
8
+
9
+ from .._libfind import load_kernel_lib as _load_kernel_lib
10
+
11
+ _lib = _load_kernel_lib()
12
+
13
+ _lib.scm2cpp_soft_threshold.restype = ctypes.c_double
14
+ _lib.scm2cpp_soft_threshold.argtypes = [ctypes.c_double, ctypes.c_double]
15
+ def soft_threshold(z, g):
16
+ return _lib.scm2cpp_soft_threshold(z, g)
17
+
18
+ _lib.scm2cpp_cov_descend.restype = ctypes.c_int
19
+ _lib.scm2cpp_cov_descend.argtypes = [ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.c_double, ctypes.c_int, ctypes.c_double, ctypes.c_int]
20
+ def cov_descend(g, c, beta, lam, iters, nobs, p):
21
+ g = np.ascontiguousarray(g, dtype=np.float64)
22
+ c = np.ascontiguousarray(c, dtype=np.float64)
23
+ beta = np.ascontiguousarray(beta, dtype=np.float64)
24
+ return _lib.scm2cpp_cov_descend(g.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), c.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), beta.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), lam, iters, nobs, p)
25
+
26
+ _lib.scm2cpp_enet_descend.restype = ctypes.c_int
27
+ _lib.scm2cpp_enet_descend.argtypes = [ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.c_double, ctypes.c_double, ctypes.c_int, ctypes.c_double, ctypes.c_int]
28
+ def enet_descend(g, c, beta, lam1, lam2, iters, nobs, p):
29
+ g = np.ascontiguousarray(g, dtype=np.float64)
30
+ c = np.ascontiguousarray(c, dtype=np.float64)
31
+ beta = np.ascontiguousarray(beta, dtype=np.float64)
32
+ return _lib.scm2cpp_enet_descend(g.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), c.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), beta.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), lam1, lam2, iters, nobs, p)
33
+
34
+ _lib.scm2cpp_mt_descend.restype = ctypes.c_int
35
+ _lib.scm2cpp_mt_descend.argtypes = [ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.c_double, ctypes.c_double, ctypes.c_int, ctypes.c_double, ctypes.c_int, ctypes.c_int]
36
+ def mt_descend(g, c, w, lam1, lam2, iters, nobs, p, ntask):
37
+ g = np.ascontiguousarray(g, dtype=np.float64)
38
+ c = np.ascontiguousarray(c, dtype=np.float64)
39
+ w = np.ascontiguousarray(w, dtype=np.float64)
40
+ return _lib.scm2cpp_mt_descend(g.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), c.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), w.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), lam1, lam2, iters, nobs, p, ntask)
41
+
@@ -0,0 +1,173 @@
1
+ # ctypes loader for libaccel.so, generated alongside it.
2
+ # Arrays are numpy arrays of the declared dtype; they are made
3
+ # contiguous on the way in and mutated in place where the translated
4
+ # function mutates them.
5
+ import ctypes
6
+ import numpy as np
7
+ from pathlib import Path
8
+
9
+ from .._libfind import load_accel_lib as _load_accel_lib
10
+
11
+ _lib = _load_accel_lib()
12
+
13
+ _lib.scm2cpp_f_regression.restype = ctypes.c_int
14
+ _lib.scm2cpp_f_regression.argtypes = [ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_int]
15
+ def f_regression(x, y, r, f, center, n, p, q):
16
+ x = np.ascontiguousarray(x, dtype=np.float64)
17
+ y = np.ascontiguousarray(y, dtype=np.float64)
18
+ r = np.ascontiguousarray(r, dtype=np.float64)
19
+ f = np.ascontiguousarray(f, dtype=np.float64)
20
+ return _lib.scm2cpp_f_regression(x.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), y.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), r.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), f.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), center, n, p, q)
21
+
22
+ _lib.scm2cpp_f_classif.restype = ctypes.c_int
23
+ _lib.scm2cpp_f_classif.argtypes = [ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_double), ctypes.c_int, ctypes.c_int, ctypes.c_int]
24
+ def f_classif(x, lab, f, n, p, k):
25
+ x = np.ascontiguousarray(x, dtype=np.float64)
26
+ lab = np.ascontiguousarray(lab, dtype=np.int32)
27
+ f = np.ascontiguousarray(f, dtype=np.float64)
28
+ return _lib.scm2cpp_f_classif(x.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), lab.ctypes.data_as(ctypes.POINTER(ctypes.c_int)), f.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), n, p, k)
29
+
30
+ _lib.scm2cpp_min_pos.restype = ctypes.c_double
31
+ _lib.scm2cpp_min_pos.argtypes = [ctypes.POINTER(ctypes.c_double), ctypes.c_int]
32
+ def min_pos(v, m):
33
+ v = np.ascontiguousarray(v, dtype=np.float64)
34
+ return _lib.scm2cpp_min_pos(v.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), m)
35
+
36
+ _lib.scm2cpp_round_even.restype = ctypes.c_double
37
+ _lib.scm2cpp_round_even.argtypes = [ctypes.c_double]
38
+ def round_even(y):
39
+ return _lib.scm2cpp_round_even(y)
40
+
41
+ _lib.scm2cpp_cholesky_delete.restype = ctypes.c_int
42
+ _lib.scm2cpp_cholesky_delete.argtypes = [ctypes.POINTER(ctypes.c_double), ctypes.c_int, ctypes.c_int, ctypes.c_int]
43
+ def cholesky_delete(l, go, n, k):
44
+ l = np.ascontiguousarray(l, dtype=np.float64)
45
+ return _lib.scm2cpp_cholesky_delete(l.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), go, n, k)
46
+
47
+ _lib.scm2cpp_swap_rc.restype = ctypes.c_int
48
+ _lib.scm2cpp_swap_rc.argtypes = [ctypes.POINTER(ctypes.c_double), ctypes.c_int, ctypes.c_int, ctypes.c_int]
49
+ def swap_rc(g, a, b, p):
50
+ g = np.ascontiguousarray(g, dtype=np.float64)
51
+ return _lib.scm2cpp_swap_rc(g.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), a, b, p)
52
+
53
+ _lib.scm2cpp_lars.restype = ctypes.c_int
54
+ _lib.scm2cpp_lars.argtypes = [ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.c_int, ctypes.c_double, ctypes.c_double, ctypes.c_int, ctypes.c_int, ctypes.c_double, ctypes.c_int]
55
+ def lars(g, cov, coef, path, alphas, rec, nsamples, alphamin, method, maxiter, eps, p):
56
+ g = np.ascontiguousarray(g, dtype=np.float64)
57
+ cov = np.ascontiguousarray(cov, dtype=np.float64)
58
+ coef = np.ascontiguousarray(coef, dtype=np.float64)
59
+ path = np.ascontiguousarray(path, dtype=np.float64)
60
+ alphas = np.ascontiguousarray(alphas, dtype=np.float64)
61
+ return _lib.scm2cpp_lars(g.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), cov.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), coef.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), path.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), alphas.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), rec, nsamples, alphamin, method, maxiter, eps, p)
62
+
63
+ _lib.scm2cpp_rfe_chol.restype = ctypes.c_int
64
+ _lib.scm2cpp_rfe_chol.argtypes = [ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_double), ctypes.c_double, ctypes.c_int, ctypes.c_int]
65
+ def rfe_chol(g, idx, l, alpha, k, p):
66
+ g = np.ascontiguousarray(g, dtype=np.float64)
67
+ idx = np.ascontiguousarray(idx, dtype=np.int32)
68
+ l = np.ascontiguousarray(l, dtype=np.float64)
69
+ return _lib.scm2cpp_rfe_chol(g.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), idx.ctypes.data_as(ctypes.POINTER(ctypes.c_int)), l.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), alpha, k, p)
70
+
71
+ _lib.scm2cpp_rfe_solve.restype = ctypes.c_int
72
+ _lib.scm2cpp_rfe_solve.argtypes = [ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.c_int, ctypes.c_int]
73
+ def rfe_solve(c, idx, w, l, k, p):
74
+ c = np.ascontiguousarray(c, dtype=np.float64)
75
+ idx = np.ascontiguousarray(idx, dtype=np.int32)
76
+ w = np.ascontiguousarray(w, dtype=np.float64)
77
+ l = np.ascontiguousarray(l, dtype=np.float64)
78
+ return _lib.scm2cpp_rfe_solve(c.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), idx.ctypes.data_as(ctypes.POINTER(ctypes.c_int)), w.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), l.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), k, p)
79
+
80
+ _lib.scm2cpp_rfe.restype = ctypes.c_int
81
+ _lib.scm2cpp_rfe.argtypes = [ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_int), ctypes.c_double, ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_int]
82
+ def rfe(x, y, coef, support, ranking, alpha, nsel, step, n, p):
83
+ x = np.ascontiguousarray(x, dtype=np.float64)
84
+ y = np.ascontiguousarray(y, dtype=np.float64)
85
+ coef = np.ascontiguousarray(coef, dtype=np.float64)
86
+ support = np.ascontiguousarray(support, dtype=np.int32)
87
+ ranking = np.ascontiguousarray(ranking, dtype=np.int32)
88
+ return _lib.scm2cpp_rfe(x.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), y.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), coef.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), support.ctypes.data_as(ctypes.POINTER(ctypes.c_int)), ranking.ctypes.data_as(ctypes.POINTER(ctypes.c_int)), alpha, nsel, step, n, p)
89
+
90
+ _lib.scm2cpp_eig_hypot.restype = ctypes.c_double
91
+ _lib.scm2cpp_eig_hypot.argtypes = [ctypes.c_double, ctypes.c_double]
92
+ def eig_hypot(a, b):
93
+ return _lib.scm2cpp_eig_hypot(a, b)
94
+
95
+ _lib.scm2cpp_sym_eigen.restype = ctypes.c_int
96
+ _lib.scm2cpp_sym_eigen.argtypes = [ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.c_int]
97
+ def sym_eigen(a, v, ev, e, m):
98
+ a = np.ascontiguousarray(a, dtype=np.float64)
99
+ v = np.ascontiguousarray(v, dtype=np.float64)
100
+ ev = np.ascontiguousarray(ev, dtype=np.float64)
101
+ e = np.ascontiguousarray(e, dtype=np.float64)
102
+ return _lib.scm2cpp_sym_eigen(a.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), v.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), ev.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), e.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), m)
103
+
104
+ _lib.scm2cpp_eig_abs.restype = ctypes.c_double
105
+ _lib.scm2cpp_eig_abs.argtypes = [ctypes.c_double]
106
+ def eig_abs(a):
107
+ return _lib.scm2cpp_eig_abs(a)
108
+
109
+ _lib.scm2cpp_eig_order.restype = ctypes.c_int
110
+ _lib.scm2cpp_eig_order.argtypes = [ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_int), ctypes.c_int]
111
+ def eig_order(ev, ord, m):
112
+ ev = np.ascontiguousarray(ev, dtype=np.float64)
113
+ ord = np.ascontiguousarray(ord, dtype=np.int32)
114
+ return _lib.scm2cpp_eig_order(ev.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), ord.ctypes.data_as(ctypes.POINTER(ctypes.c_int)), m)
115
+
116
+ _lib.scm2cpp_sym_eigen_top.restype = ctypes.c_int
117
+ _lib.scm2cpp_sym_eigen_top.argtypes = [ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.c_int, ctypes.c_int]
118
+ def sym_eigen_top(a, v, ev, e, m, k):
119
+ a = np.ascontiguousarray(a, dtype=np.float64)
120
+ v = np.ascontiguousarray(v, dtype=np.float64)
121
+ ev = np.ascontiguousarray(ev, dtype=np.float64)
122
+ e = np.ascontiguousarray(e, dtype=np.float64)
123
+ return _lib.scm2cpp_sym_eigen_top(a.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), v.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), ev.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), e.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), m, k)
124
+
125
+ _lib.scm2cpp_sym_eigen_gen.restype = ctypes.c_int
126
+ _lib.scm2cpp_sym_eigen_gen.argtypes = [ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.c_int]
127
+ def sym_eigen_gen(a, b, v, ev, e, m):
128
+ a = np.ascontiguousarray(a, dtype=np.float64)
129
+ b = np.ascontiguousarray(b, dtype=np.float64)
130
+ v = np.ascontiguousarray(v, dtype=np.float64)
131
+ ev = np.ascontiguousarray(ev, dtype=np.float64)
132
+ e = np.ascontiguousarray(e, dtype=np.float64)
133
+ return _lib.scm2cpp_sym_eigen_gen(a.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), b.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), v.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), ev.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), e.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), m)
134
+
135
+ _lib.scm2cpp_pca.restype = ctypes.c_int
136
+ _lib.scm2cpp_pca.argtypes = [ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.c_int, ctypes.c_int]
137
+ def pca(x, comps, ev, sv, mean, n, p):
138
+ x = np.ascontiguousarray(x, dtype=np.float64)
139
+ comps = np.ascontiguousarray(comps, dtype=np.float64)
140
+ ev = np.ascontiguousarray(ev, dtype=np.float64)
141
+ sv = np.ascontiguousarray(sv, dtype=np.float64)
142
+ mean = np.ascontiguousarray(mean, dtype=np.float64)
143
+ return _lib.scm2cpp_pca(x.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), comps.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), ev.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), sv.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), mean.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), n, p)
144
+
145
+ _lib.scm2cpp_gram_xx.restype = ctypes.c_int
146
+ _lib.scm2cpp_gram_xx.argtypes = [ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.c_int, ctypes.c_int]
147
+ def gram_xx(x, g, n, p):
148
+ x = np.ascontiguousarray(x, dtype=np.float64)
149
+ g = np.ascontiguousarray(g, dtype=np.float64)
150
+ return _lib.scm2cpp_gram_xx(x.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), g.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), n, p)
151
+
152
+ _lib.scm2cpp_gram_xy.restype = ctypes.c_int
153
+ _lib.scm2cpp_gram_xy.argtypes = [ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.c_int, ctypes.c_int, ctypes.c_int]
154
+ def gram_xy(x, y, c, n, p, q):
155
+ x = np.ascontiguousarray(x, dtype=np.float64)
156
+ y = np.ascontiguousarray(y, dtype=np.float64)
157
+ c = np.ascontiguousarray(c, dtype=np.float64)
158
+ return _lib.scm2cpp_gram_xy(x.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), y.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), c.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), n, p, q)
159
+
160
+ _lib.scm2cpp_spd_solve.restype = ctypes.c_int
161
+ _lib.scm2cpp_spd_solve.argtypes = [ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.c_int, ctypes.c_int]
162
+ def spd_solve(a, b, m, q):
163
+ a = np.ascontiguousarray(a, dtype=np.float64)
164
+ b = np.ascontiguousarray(b, dtype=np.float64)
165
+ return _lib.scm2cpp_spd_solve(a.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), b.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), m, q)
166
+
167
+ _lib.scm2cpp_gram_ridge_solve.restype = ctypes.c_int
168
+ _lib.scm2cpp_gram_ridge_solve.argtypes = [ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.c_double, ctypes.c_int, ctypes.c_int]
169
+ def gram_ridge_solve(g, c, alpha, m, q):
170
+ g = np.ascontiguousarray(g, dtype=np.float64)
171
+ c = np.ascontiguousarray(c, dtype=np.float64)
172
+ return _lib.scm2cpp_gram_ridge_solve(g.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), c.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), alpha, m, q)
173
+