scm2cpp-lasso 0.13.2__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 (65) hide show
  1. scm2cpp_lasso/__init__.py +2808 -0
  2. scm2cpp_lasso/_classifiers.cp312-win_amd64.pyd +0 -0
  3. scm2cpp_lasso/_generated/__init__.py +0 -0
  4. scm2cpp_lasso/_generated/_loader.py +41 -0
  5. scm2cpp_lasso/_generated/_loader_accel_cublas.py +140 -0
  6. scm2cpp_lasso/_generated/_loader_classifiers.py +281 -0
  7. scm2cpp_lasso/_generated/_loader_derived_blas.py +29 -0
  8. scm2cpp_lasso/_generated/_loader_derived_cublas.py +29 -0
  9. scm2cpp_lasso/_generated/_loader_derived_loops.py +29 -0
  10. scm2cpp_lasso/_generated/_loader_gpu_cuda.py +294 -0
  11. scm2cpp_lasso/_generated/_loader_gramops_blas.py +496 -0
  12. scm2cpp_lasso/_generated/_loader_gramops_loops.py +496 -0
  13. scm2cpp_lasso/_generated/_loader_nmf_blas.py +29 -0
  14. scm2cpp_lasso/_generated/_loader_nmf_cublas.py +29 -0
  15. scm2cpp_lasso/_generated/_loader_nmf_loops.py +29 -0
  16. scm2cpp_lasso/_generated/accel_cublas/accel.cpp +20 -0
  17. scm2cpp_lasso/_generated/accel_cublas/accel.hpp +1023 -0
  18. scm2cpp_lasso/_generated/accel_cublas/accel_capi.cpp +64 -0
  19. scm2cpp_lasso/_generated/classifiers.cpp +34 -0
  20. scm2cpp_lasso/_generated/classifiers.hpp +2825 -0
  21. scm2cpp_lasso/_generated/classifiers_capi.cpp +106 -0
  22. scm2cpp_lasso/_generated/derived_blas/lasso_design.cpp +5 -0
  23. scm2cpp_lasso/_generated/derived_blas/lasso_design.hpp +153 -0
  24. scm2cpp_lasso/_generated/derived_blas/lasso_design_capi.cpp +19 -0
  25. scm2cpp_lasso/_generated/derived_cublas/lasso_design.cpp +5 -0
  26. scm2cpp_lasso/_generated/derived_cublas/lasso_design.hpp +155 -0
  27. scm2cpp_lasso/_generated/derived_cublas/lasso_design_capi.cpp +19 -0
  28. scm2cpp_lasso/_generated/derived_loops/lasso_design.cpp +5 -0
  29. scm2cpp_lasso/_generated/derived_loops/lasso_design.hpp +176 -0
  30. scm2cpp_lasso/_generated/derived_loops/lasso_design_capi.cpp +19 -0
  31. scm2cpp_lasso/_generated/gpu_cuda/gpu.cpp +35 -0
  32. scm2cpp_lasso/_generated/gpu_cuda/gpu.hpp +3715 -0
  33. scm2cpp_lasso/_generated/gpu_cuda/gpu_capi.cpp +289 -0
  34. scm2cpp_lasso/_generated/gramops_blas/gramops.cpp +57 -0
  35. scm2cpp_lasso/_generated/gramops_blas/gramops.hpp +3033 -0
  36. scm2cpp_lasso/_generated/gramops_blas/gramops_capi.cpp +175 -0
  37. scm2cpp_lasso/_generated/gramops_loops/gramops.cpp +57 -0
  38. scm2cpp_lasso/_generated/gramops_loops/gramops.hpp +3302 -0
  39. scm2cpp_lasso/_generated/gramops_loops/gramops_capi.cpp +175 -0
  40. scm2cpp_lasso/_generated/lasso_cov.cpp +7 -0
  41. scm2cpp_lasso/_generated/lasso_cov.hpp +152 -0
  42. scm2cpp_lasso/_generated/lasso_cov_capi.cpp +25 -0
  43. scm2cpp_lasso/_generated/nmf_blas/nmf_cd.cpp +5 -0
  44. scm2cpp_lasso/_generated/nmf_blas/nmf_cd.hpp +132 -0
  45. scm2cpp_lasso/_generated/nmf_blas/nmf_cd_capi.cpp +19 -0
  46. scm2cpp_lasso/_generated/nmf_cublas/nmf_cd.cpp +5 -0
  47. scm2cpp_lasso/_generated/nmf_cublas/nmf_cd.hpp +136 -0
  48. scm2cpp_lasso/_generated/nmf_cublas/nmf_cd_capi.cpp +19 -0
  49. scm2cpp_lasso/_generated/nmf_loops/nmf_cd.cpp +5 -0
  50. scm2cpp_lasso/_generated/nmf_loops/nmf_cd.hpp +167 -0
  51. scm2cpp_lasso/_generated/nmf_loops/nmf_cd_capi.cpp +19 -0
  52. scm2cpp_lasso/_generated/scm2cpp-blas.hpp +77 -0
  53. scm2cpp_lasso/_generated/scm2cpp-cublas.hpp +155 -0
  54. scm2cpp_lasso/_generated/scm2cpp-cuda.hpp +285 -0
  55. scm2cpp_lasso/_generated/scm2cpp.hpp +1627 -0
  56. scm2cpp_lasso/_gramops_loops.cp312-win_amd64.pyd +0 -0
  57. scm2cpp_lasso/_lasso_cov.cp312-win_amd64.pyd +0 -0
  58. scm2cpp_lasso/_lasso_derived_loops.cp312-win_amd64.pyd +0 -0
  59. scm2cpp_lasso/_libfind.py +149 -0
  60. scm2cpp_lasso/_nmf_loops.cp312-win_amd64.pyd +0 -0
  61. scm2cpp_lasso/batch_capi.cu +428 -0
  62. scm2cpp_lasso-0.13.2.dist-info/METADATA +920 -0
  63. scm2cpp_lasso-0.13.2.dist-info/RECORD +65 -0
  64. scm2cpp_lasso-0.13.2.dist-info/WHEEL +5 -0
  65. scm2cpp_lasso-0.13.2.dist-info/top_level.txt +1 -0
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,140 @@
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_pca.restype = ctypes.c_int
117
+ _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]
118
+ def pca(x, comps, ev, sv, mean, n, p):
119
+ x = np.ascontiguousarray(x, dtype=np.float64)
120
+ comps = np.ascontiguousarray(comps, dtype=np.float64)
121
+ ev = np.ascontiguousarray(ev, dtype=np.float64)
122
+ sv = np.ascontiguousarray(sv, dtype=np.float64)
123
+ mean = np.ascontiguousarray(mean, dtype=np.float64)
124
+ 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)
125
+
126
+ _lib.scm2cpp_gram_xx.restype = ctypes.c_int
127
+ _lib.scm2cpp_gram_xx.argtypes = [ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.c_int, ctypes.c_int]
128
+ def gram_xx(x, g, n, p):
129
+ x = np.ascontiguousarray(x, dtype=np.float64)
130
+ g = np.ascontiguousarray(g, dtype=np.float64)
131
+ 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)
132
+
133
+ _lib.scm2cpp_gram_xy.restype = ctypes.c_int
134
+ _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]
135
+ def gram_xy(x, y, c, n, p, q):
136
+ x = np.ascontiguousarray(x, dtype=np.float64)
137
+ y = np.ascontiguousarray(y, dtype=np.float64)
138
+ c = np.ascontiguousarray(c, dtype=np.float64)
139
+ 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)
140
+
@@ -0,0 +1,281 @@
1
+ # ctypes loader for libclassifiers.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_classifier_lib as _load_classifier_lib
10
+
11
+ _lib = _load_classifier_lib()
12
+
13
+ _lib.scm2cpp_svm_liblinear.restype = ctypes.c_int
14
+ _lib.scm2cpp_svm_liblinear.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_double, ctypes.c_int, ctypes.c_double, ctypes.c_int, ctypes.c_int, ctypes.c_int]
15
+ def svm_liblinear(x, y, w, alpha, xnorm, cost, iters, tol, seed, n, p):
16
+ x = np.ascontiguousarray(x, dtype=np.float64)
17
+ y = np.ascontiguousarray(y, dtype=np.float64)
18
+ w = np.ascontiguousarray(w, dtype=np.float64)
19
+ alpha = np.ascontiguousarray(alpha, dtype=np.float64)
20
+ xnorm = np.ascontiguousarray(xnorm, dtype=np.float64)
21
+ return _lib.scm2cpp_svm_liblinear(x.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), y.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), w.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), alpha.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), xnorm.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), cost, iters, tol, seed, n, p)
22
+
23
+ _lib.scm2cpp_svm_smo.restype = ctypes.c_int
24
+ _lib.scm2cpp_svm_smo.argtypes = [ctypes.POINTER(ctypes.c_double), 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]
25
+ def svm_smo(k, y, alpha, rho, cost, iters, eps, n):
26
+ k = np.ascontiguousarray(k, dtype=np.float64)
27
+ y = np.ascontiguousarray(y, dtype=np.float64)
28
+ alpha = np.ascontiguousarray(alpha, dtype=np.float64)
29
+ rho = np.ascontiguousarray(rho, dtype=np.float64)
30
+ return _lib.scm2cpp_svm_smo(k.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), y.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), alpha.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), rho.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), cost, iters, eps, n)
31
+
32
+ _lib.scm2cpp_smo_solve.restype = ctypes.c_int
33
+ _lib.scm2cpp_smo_solve.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_double, ctypes.c_int, ctypes.c_double, ctypes.c_int, ctypes.c_int]
34
+ def smo_solve(k, y, lin, alpha, rho, cost, iters, eps, n, nk):
35
+ k = np.ascontiguousarray(k, dtype=np.float64)
36
+ y = np.ascontiguousarray(y, dtype=np.float64)
37
+ lin = np.ascontiguousarray(lin, dtype=np.float64)
38
+ alpha = np.ascontiguousarray(alpha, dtype=np.float64)
39
+ rho = np.ascontiguousarray(rho, dtype=np.float64)
40
+ assert rho.size == 1, "rho: expected 1 elements"
41
+ return _lib.scm2cpp_smo_solve(k.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), y.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), lin.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), alpha.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), rho.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), cost, iters, eps, n, nk)
42
+
43
+ _lib.scm2cpp_shrinkable_P.restype = ctypes.c_int
44
+ _lib.scm2cpp_shrinkable_P.argtypes = [ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.c_double, ctypes.c_double, ctypes.c_double, ctypes.c_int]
45
+ def shrinkable_P(yy, a, g, cost, gmax1, gmax2, t):
46
+ yy = np.ascontiguousarray(yy, dtype=np.float64)
47
+ a = np.ascontiguousarray(a, dtype=np.float64)
48
+ g = np.ascontiguousarray(g, dtype=np.float64)
49
+ return _lib.scm2cpp_shrinkable_P(yy.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), a.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), g.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), cost, gmax1, gmax2, t)
50
+
51
+ _lib.scm2cpp_swap_position.restype = ctypes.c_int
52
+ _lib.scm2cpp_swap_position.argtypes = [ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_int), 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.POINTER(ctypes.c_double), ctypes.c_int, ctypes.c_int]
53
+ def swap_position(index, krow, pp, yy, a, g, gbar, qd, s, t):
54
+ index = np.ascontiguousarray(index, dtype=np.int32)
55
+ krow = np.ascontiguousarray(krow, dtype=np.int32)
56
+ pp = np.ascontiguousarray(pp, dtype=np.float64)
57
+ yy = np.ascontiguousarray(yy, dtype=np.float64)
58
+ a = np.ascontiguousarray(a, dtype=np.float64)
59
+ g = np.ascontiguousarray(g, dtype=np.float64)
60
+ gbar = np.ascontiguousarray(gbar, dtype=np.float64)
61
+ qd = np.ascontiguousarray(qd, dtype=np.float64)
62
+ return _lib.scm2cpp_swap_position(index.ctypes.data_as(ctypes.POINTER(ctypes.c_int)), krow.ctypes.data_as(ctypes.POINTER(ctypes.c_int)), pp.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), yy.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), a.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), g.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), gbar.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), qd.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), s, t)
63
+
64
+ _lib.scm2cpp_reconstruct_gradient.restype = ctypes.c_int
65
+ _lib.scm2cpp_reconstruct_gradient.argtypes = [ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_int), 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_double, ctypes.c_int, ctypes.c_int, ctypes.c_int]
66
+ def reconstruct_gradient(k, krow, pp, yy, a, g, gbar, cost, active, n, nk):
67
+ k = np.ascontiguousarray(k, dtype=np.float64)
68
+ krow = np.ascontiguousarray(krow, dtype=np.int32)
69
+ pp = np.ascontiguousarray(pp, dtype=np.float64)
70
+ yy = np.ascontiguousarray(yy, dtype=np.float64)
71
+ a = np.ascontiguousarray(a, dtype=np.float64)
72
+ g = np.ascontiguousarray(g, dtype=np.float64)
73
+ gbar = np.ascontiguousarray(gbar, dtype=np.float64)
74
+ return _lib.scm2cpp_reconstruct_gradient(k.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), krow.ctypes.data_as(ctypes.POINTER(ctypes.c_int)), pp.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), yy.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), a.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), g.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), gbar.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), cost, active, n, nk)
75
+
76
+ _lib.scm2cpp_select_working_set.restype = ctypes.c_int
77
+ _lib.scm2cpp_select_working_set.argtypes = [ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_double), 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_int, ctypes.POINTER(ctypes.c_int)]
78
+ def select_working_set(k, krow, yy, a, g, qd, cost, eps, active, nk, wi):
79
+ k = np.ascontiguousarray(k, dtype=np.float64)
80
+ krow = np.ascontiguousarray(krow, dtype=np.int32)
81
+ yy = np.ascontiguousarray(yy, dtype=np.float64)
82
+ a = np.ascontiguousarray(a, dtype=np.float64)
83
+ g = np.ascontiguousarray(g, dtype=np.float64)
84
+ qd = np.ascontiguousarray(qd, dtype=np.float64)
85
+ wi = np.ascontiguousarray(wi, dtype=np.int32)
86
+ assert wi.size == 2, "wi: expected 2 elements"
87
+ return _lib.scm2cpp_select_working_set(k.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), krow.ctypes.data_as(ctypes.POINTER(ctypes.c_int)), yy.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), a.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), g.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), qd.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), cost, eps, active, nk, wi.ctypes.data_as(ctypes.POINTER(ctypes.c_int)))
88
+
89
+ _lib.scm2cpp_svr_smo.restype = ctypes.c_int
90
+ _lib.scm2cpp_svr_smo.argtypes = [ctypes.POINTER(ctypes.c_double), 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]
91
+ def svr_smo(k, z, beta, rho, cost, epsilon, iters, eps, n):
92
+ k = np.ascontiguousarray(k, dtype=np.float64)
93
+ z = np.ascontiguousarray(z, dtype=np.float64)
94
+ beta = np.ascontiguousarray(beta, dtype=np.float64)
95
+ rho = np.ascontiguousarray(rho, dtype=np.float64)
96
+ return _lib.scm2cpp_svr_smo(k.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), z.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), beta.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), rho.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), cost, epsilon, iters, eps, n)
97
+
98
+ _lib.scm2cpp_logistic_l1.restype = ctypes.c_int
99
+ _lib.scm2cpp_logistic_l1.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_int, ctypes.c_int, ctypes.c_int]
100
+ def logistic_l1(x, y, w, cost, tol, maxnewton, seed, n, p):
101
+ x = np.ascontiguousarray(x, dtype=np.float64)
102
+ y = np.ascontiguousarray(y, dtype=np.float64)
103
+ w = np.ascontiguousarray(w, dtype=np.float64)
104
+ return _lib.scm2cpp_logistic_l1(x.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), y.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), w.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), cost, tol, maxnewton, seed, n, p)
105
+
106
+ _lib.scm2cpp_svr_liblinear.restype = ctypes.c_int
107
+ _lib.scm2cpp_svr_liblinear.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_double, ctypes.c_double, ctypes.c_int, ctypes.c_double, ctypes.c_int, ctypes.c_int, ctypes.c_int]
108
+ def svr_liblinear(x, y, w, beta, xnorm, cost, epsilon, iters, tol, seed, n, p):
109
+ x = np.ascontiguousarray(x, dtype=np.float64)
110
+ y = np.ascontiguousarray(y, dtype=np.float64)
111
+ w = np.ascontiguousarray(w, dtype=np.float64)
112
+ beta = np.ascontiguousarray(beta, dtype=np.float64)
113
+ xnorm = np.ascontiguousarray(xnorm, dtype=np.float64)
114
+ return _lib.scm2cpp_svr_liblinear(x.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), y.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), w.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), beta.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), xnorm.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), cost, epsilon, iters, tol, seed, n, p)
115
+
116
+ _lib.scm2cpp_ols_rows.restype = ctypes.c_double
117
+ _lib.scm2cpp_ols_rows.argtypes = [ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_int), ctypes.c_int, 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.POINTER(ctypes.c_double), ctypes.c_int, ctypes.c_int]
118
+ def ols_rows(x, y, rows, m, w, g, c, l, z, xm, n, p):
119
+ x = np.ascontiguousarray(x, dtype=np.float64)
120
+ y = np.ascontiguousarray(y, dtype=np.float64)
121
+ rows = np.ascontiguousarray(rows, dtype=np.int32)
122
+ w = np.ascontiguousarray(w, dtype=np.float64)
123
+ g = np.ascontiguousarray(g, dtype=np.float64)
124
+ c = np.ascontiguousarray(c, dtype=np.float64)
125
+ l = np.ascontiguousarray(l, dtype=np.float64)
126
+ z = np.ascontiguousarray(z, dtype=np.float64)
127
+ xm = np.ascontiguousarray(xm, dtype=np.float64)
128
+ return _lib.scm2cpp_ols_rows(x.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), y.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), rows.ctypes.data_as(ctypes.POINTER(ctypes.c_int)), m, w.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), g.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), c.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), l.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), z.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), xm.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), n, p)
129
+
130
+ _lib.scm2cpp_ransac.restype = ctypes.c_int
131
+ _lib.scm2cpp_ransac.argtypes = [ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_int), 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_double, ctypes.c_int, ctypes.c_int]
132
+ def ransac(x, y, subsets, coef, mask, out, maxtrials, minsamples, thresh, stopprob, n, p):
133
+ x = np.ascontiguousarray(x, dtype=np.float64)
134
+ y = np.ascontiguousarray(y, dtype=np.float64)
135
+ subsets = np.ascontiguousarray(subsets, dtype=np.int32)
136
+ coef = np.ascontiguousarray(coef, dtype=np.float64)
137
+ mask = np.ascontiguousarray(mask, dtype=np.float64)
138
+ out = np.ascontiguousarray(out, dtype=np.float64)
139
+ return _lib.scm2cpp_ransac(x.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), y.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), subsets.ctypes.data_as(ctypes.POINTER(ctypes.c_int)), coef.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), mask.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), out.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), maxtrials, minsamples, thresh, stopprob, n, p)
140
+
141
+ _lib.scm2cpp_sgd_loss.restype = ctypes.c_double
142
+ _lib.scm2cpp_sgd_loss.argtypes = [ctypes.c_int, ctypes.c_double, ctypes.c_double, ctypes.c_double]
143
+ def sgd_loss(loss, y, p, epsilon):
144
+ return _lib.scm2cpp_sgd_loss(loss, y, p, epsilon)
145
+
146
+ _lib.scm2cpp_sgd_grad.restype = ctypes.c_double
147
+ _lib.scm2cpp_sgd_grad.argtypes = [ctypes.c_int, ctypes.c_double, ctypes.c_double, ctypes.c_double]
148
+ def sgd_grad(loss, y, p, epsilon):
149
+ return _lib.scm2cpp_sgd_grad(loss, y, p, epsilon)
150
+
151
+ _lib.scm2cpp_sgd.restype = ctypes.c_int
152
+ _lib.scm2cpp_sgd.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_double, ctypes.c_double, ctypes.c_double, ctypes.c_double, ctypes.c_int, ctypes.c_double, ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_int]
153
+ def sgd(x, y, w, out, loss, lr, pen, alpha, eta0, powert, epsilon, maxiter, tol, niternochange, fitint, n, p):
154
+ x = np.ascontiguousarray(x, dtype=np.float64)
155
+ y = np.ascontiguousarray(y, dtype=np.float64)
156
+ w = np.ascontiguousarray(w, dtype=np.float64)
157
+ out = np.ascontiguousarray(out, dtype=np.float64)
158
+ return _lib.scm2cpp_sgd(x.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), y.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), w.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), out.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), loss, lr, pen, alpha, eta0, powert, epsilon, maxiter, tol, niternochange, fitint, n, p)
159
+
160
+ _lib.scm2cpp_sgd_min.restype = ctypes.c_double
161
+ _lib.scm2cpp_sgd_min.argtypes = [ctypes.c_double, ctypes.c_double]
162
+ def sgd_min(a, b):
163
+ return _lib.scm2cpp_sgd_min(a, b)
164
+
165
+ _lib.scm2cpp_min_pos.restype = ctypes.c_double
166
+ _lib.scm2cpp_min_pos.argtypes = [ctypes.POINTER(ctypes.c_double), ctypes.c_int]
167
+ def min_pos(v, m):
168
+ v = np.ascontiguousarray(v, dtype=np.float64)
169
+ return _lib.scm2cpp_min_pos(v.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), m)
170
+
171
+ _lib.scm2cpp_round_even.restype = ctypes.c_double
172
+ _lib.scm2cpp_round_even.argtypes = [ctypes.c_double]
173
+ def round_even(y):
174
+ return _lib.scm2cpp_round_even(y)
175
+
176
+ _lib.scm2cpp_cholesky_delete.restype = ctypes.c_int
177
+ _lib.scm2cpp_cholesky_delete.argtypes = [ctypes.POINTER(ctypes.c_double), ctypes.c_int, ctypes.c_int, ctypes.c_int]
178
+ def cholesky_delete(l, go, n, k):
179
+ l = np.ascontiguousarray(l, dtype=np.float64)
180
+ return _lib.scm2cpp_cholesky_delete(l.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), go, n, k)
181
+
182
+ _lib.scm2cpp_swap_rc.restype = ctypes.c_int
183
+ _lib.scm2cpp_swap_rc.argtypes = [ctypes.POINTER(ctypes.c_double), ctypes.c_int, ctypes.c_int, ctypes.c_int]
184
+ def swap_rc(g, a, b, p):
185
+ g = np.ascontiguousarray(g, dtype=np.float64)
186
+ return _lib.scm2cpp_swap_rc(g.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), a, b, p)
187
+
188
+ _lib.scm2cpp_lars.restype = ctypes.c_int
189
+ _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]
190
+ def lars(g, cov, coef, path, alphas, rec, nsamples, alphamin, method, maxiter, eps, p):
191
+ g = np.ascontiguousarray(g, dtype=np.float64)
192
+ cov = np.ascontiguousarray(cov, dtype=np.float64)
193
+ coef = np.ascontiguousarray(coef, dtype=np.float64)
194
+ path = np.ascontiguousarray(path, dtype=np.float64)
195
+ alphas = np.ascontiguousarray(alphas, dtype=np.float64)
196
+ 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)
197
+
198
+ _lib.scm2cpp_svm_l1.restype = ctypes.c_int
199
+ _lib.scm2cpp_svm_l1.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_int, ctypes.c_int, ctypes.c_int]
200
+ def svm_l1(x, y, w, cost, tol, maxiter, seed, n, p):
201
+ x = np.ascontiguousarray(x, dtype=np.float64)
202
+ y = np.ascontiguousarray(y, dtype=np.float64)
203
+ w = np.ascontiguousarray(w, dtype=np.float64)
204
+ return _lib.scm2cpp_svm_l1(x.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), y.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), w.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), cost, tol, maxiter, seed, n, p)
205
+
206
+ _lib.scm2cpp_svm_l1_abs.restype = ctypes.c_double
207
+ _lib.scm2cpp_svm_l1_abs.argtypes = [ctypes.c_double]
208
+ def svm_l1_abs(a):
209
+ return _lib.scm2cpp_svm_l1_abs(a)
210
+
211
+ _lib.scm2cpp_eig_hypot.restype = ctypes.c_double
212
+ _lib.scm2cpp_eig_hypot.argtypes = [ctypes.c_double, ctypes.c_double]
213
+ def eig_hypot(a, b):
214
+ return _lib.scm2cpp_eig_hypot(a, b)
215
+
216
+ _lib.scm2cpp_sym_eigen.restype = ctypes.c_int
217
+ _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]
218
+ def sym_eigen(a, v, ev, e, m):
219
+ a = np.ascontiguousarray(a, dtype=np.float64)
220
+ v = np.ascontiguousarray(v, dtype=np.float64)
221
+ ev = np.ascontiguousarray(ev, dtype=np.float64)
222
+ e = np.ascontiguousarray(e, dtype=np.float64)
223
+ 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)
224
+
225
+ _lib.scm2cpp_eig_abs.restype = ctypes.c_double
226
+ _lib.scm2cpp_eig_abs.argtypes = [ctypes.c_double]
227
+ def eig_abs(a):
228
+ return _lib.scm2cpp_eig_abs(a)
229
+
230
+ _lib.scm2cpp_eig_order.restype = ctypes.c_int
231
+ _lib.scm2cpp_eig_order.argtypes = [ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_int), ctypes.c_int]
232
+ def eig_order(ev, ord, m):
233
+ ev = np.ascontiguousarray(ev, dtype=np.float64)
234
+ ord = np.ascontiguousarray(ord, dtype=np.int32)
235
+ return _lib.scm2cpp_eig_order(ev.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), ord.ctypes.data_as(ctypes.POINTER(ctypes.c_int)), m)
236
+
237
+ _lib.scm2cpp_ts_minnorm.restype = ctypes.c_int
238
+ _lib.scm2cpp_ts_minnorm.argtypes = [ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_int), 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.POINTER(ctypes.c_double), ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_int]
239
+ def ts_minnorm(x, y, idx, w, aa, v, ev, e, ab, s, ns, fitint, p, d):
240
+ x = np.ascontiguousarray(x, dtype=np.float64)
241
+ y = np.ascontiguousarray(y, dtype=np.float64)
242
+ idx = np.ascontiguousarray(idx, dtype=np.int32)
243
+ w = np.ascontiguousarray(w, dtype=np.float64)
244
+ aa = np.ascontiguousarray(aa, dtype=np.float64)
245
+ v = np.ascontiguousarray(v, dtype=np.float64)
246
+ ev = np.ascontiguousarray(ev, dtype=np.float64)
247
+ e = np.ascontiguousarray(e, dtype=np.float64)
248
+ ab = np.ascontiguousarray(ab, dtype=np.float64)
249
+ return _lib.scm2cpp_ts_minnorm(x.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), y.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)), aa.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)), ab.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), s, ns, fitint, p, d)
250
+
251
+ _lib.scm2cpp_ts_fit.restype = ctypes.c_int
252
+ _lib.scm2cpp_ts_fit.argtypes = [ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_int), 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.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, ctypes.c_int]
253
+ def ts_fit(x, y, idx, w, a, b, aa, v, ev, e, ab, s, ns, fitint, p, d):
254
+ x = np.ascontiguousarray(x, dtype=np.float64)
255
+ y = np.ascontiguousarray(y, dtype=np.float64)
256
+ idx = np.ascontiguousarray(idx, dtype=np.int32)
257
+ w = np.ascontiguousarray(w, dtype=np.float64)
258
+ a = np.ascontiguousarray(a, dtype=np.float64)
259
+ b = np.ascontiguousarray(b, dtype=np.float64)
260
+ aa = np.ascontiguousarray(aa, dtype=np.float64)
261
+ v = np.ascontiguousarray(v, dtype=np.float64)
262
+ ev = np.ascontiguousarray(ev, dtype=np.float64)
263
+ e = np.ascontiguousarray(e, dtype=np.float64)
264
+ ab = np.ascontiguousarray(ab, dtype=np.float64)
265
+ return _lib.scm2cpp_ts_fit(x.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), y.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)), a.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), b.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), aa.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)), ab.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), s, ns, fitint, p, d)
266
+
267
+ _lib.scm2cpp_ts_abs.restype = ctypes.c_double
268
+ _lib.scm2cpp_ts_abs.argtypes = [ctypes.c_double]
269
+ def ts_abs(v):
270
+ return _lib.scm2cpp_ts_abs(v)
271
+
272
+ _lib.scm2cpp_theilsen.restype = ctypes.c_int
273
+ _lib.scm2cpp_theilsen.argtypes = [ctypes.POINTER(ctypes.c_double), 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, ctypes.c_int, ctypes.c_int, ctypes.c_double, ctypes.c_int]
274
+ def theilsen(x, y, idx, w, coef, nsub, ns, fitint, maxiter, tol, p):
275
+ x = np.ascontiguousarray(x, dtype=np.float64)
276
+ y = np.ascontiguousarray(y, dtype=np.float64)
277
+ idx = np.ascontiguousarray(idx, dtype=np.int32)
278
+ w = np.ascontiguousarray(w, dtype=np.float64)
279
+ coef = np.ascontiguousarray(coef, dtype=np.float64)
280
+ return _lib.scm2cpp_theilsen(x.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), y.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)), coef.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), nsub, ns, fitint, maxiter, tol, p)
281
+
@@ -0,0 +1,29 @@
1
+ # ctypes loader for liblasso_design.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_derived_lib as _load_derived_lib
10
+
11
+ _lib = _load_derived_lib("blas")
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_lasso_design.restype = ctypes.c_int
19
+ _lib.scm2cpp_lasso_design.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.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.c_int, ctypes.c_double, ctypes.c_int, ctypes.c_int, ctypes.c_int]
20
+ def lasso_design(x, y, resid, xnorm, beta, lams, betas, iters, tol, n, p, nlam):
21
+ x = np.ascontiguousarray(x, dtype=np.float64)
22
+ y = np.ascontiguousarray(y, dtype=np.float64)
23
+ resid = np.ascontiguousarray(resid, dtype=np.float64)
24
+ xnorm = np.ascontiguousarray(xnorm, dtype=np.float64)
25
+ beta = np.ascontiguousarray(beta, dtype=np.float64)
26
+ lams = np.ascontiguousarray(lams, dtype=np.float64)
27
+ betas = np.ascontiguousarray(betas, dtype=np.float64)
28
+ return _lib.scm2cpp_lasso_design(x.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), y.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), resid.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), xnorm.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), beta.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), lams.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), betas.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), iters, tol, n, p, nlam)
29
+
@@ -0,0 +1,29 @@
1
+ # ctypes loader for liblasso_design.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_derived_lib as _load_derived_lib
10
+
11
+ _lib = _load_derived_lib("cublas")
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_lasso_design.restype = ctypes.c_int
19
+ _lib.scm2cpp_lasso_design.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.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.c_int, ctypes.c_double, ctypes.c_int, ctypes.c_int, ctypes.c_int]
20
+ def lasso_design(x, y, resid, xnorm, beta, lams, betas, iters, tol, n, p, nlam):
21
+ x = np.ascontiguousarray(x, dtype=np.float64)
22
+ y = np.ascontiguousarray(y, dtype=np.float64)
23
+ resid = np.ascontiguousarray(resid, dtype=np.float64)
24
+ xnorm = np.ascontiguousarray(xnorm, dtype=np.float64)
25
+ beta = np.ascontiguousarray(beta, dtype=np.float64)
26
+ lams = np.ascontiguousarray(lams, dtype=np.float64)
27
+ betas = np.ascontiguousarray(betas, dtype=np.float64)
28
+ return _lib.scm2cpp_lasso_design(x.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), y.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), resid.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), xnorm.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), beta.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), lams.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), betas.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), iters, tol, n, p, nlam)
29
+
@@ -0,0 +1,29 @@
1
+ # ctypes loader for liblasso_design.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_derived_lib as _load_derived_lib
10
+
11
+ _lib = _load_derived_lib("loops")
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_lasso_design.restype = ctypes.c_int
19
+ _lib.scm2cpp_lasso_design.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.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.c_int, ctypes.c_double, ctypes.c_int, ctypes.c_int, ctypes.c_int]
20
+ def lasso_design(x, y, resid, xnorm, beta, lams, betas, iters, tol, n, p, nlam):
21
+ x = np.ascontiguousarray(x, dtype=np.float64)
22
+ y = np.ascontiguousarray(y, dtype=np.float64)
23
+ resid = np.ascontiguousarray(resid, dtype=np.float64)
24
+ xnorm = np.ascontiguousarray(xnorm, dtype=np.float64)
25
+ beta = np.ascontiguousarray(beta, dtype=np.float64)
26
+ lams = np.ascontiguousarray(lams, dtype=np.float64)
27
+ betas = np.ascontiguousarray(betas, dtype=np.float64)
28
+ return _lib.scm2cpp_lasso_design(x.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), y.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), resid.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), xnorm.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), beta.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), lams.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), betas.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), iters, tol, n, p, nlam)
29
+