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.
- scm2cpp_learn/__init__.py +3836 -0
- scm2cpp_learn/_classifiers.cp312-win_amd64.pyd +0 -0
- scm2cpp_learn/_compat.py +284 -0
- scm2cpp_learn/_generated/__init__.py +0 -0
- scm2cpp_learn/_generated/_loader.py +41 -0
- scm2cpp_learn/_generated/_loader_accel_cublas.py +173 -0
- scm2cpp_learn/_generated/_loader_classifiers.py +308 -0
- scm2cpp_learn/_generated/_loader_derived_blas.py +29 -0
- scm2cpp_learn/_generated/_loader_derived_cublas.py +29 -0
- scm2cpp_learn/_generated/_loader_derived_loops.py +29 -0
- scm2cpp_learn/_generated/_loader_gpu_cuda.py +313 -0
- scm2cpp_learn/_generated/_loader_gramops_blas.py +692 -0
- scm2cpp_learn/_generated/_loader_gramops_loops.py +711 -0
- scm2cpp_learn/_generated/_loader_nmf_blas.py +29 -0
- scm2cpp_learn/_generated/_loader_nmf_cublas.py +29 -0
- scm2cpp_learn/_generated/_loader_nmf_loops.py +29 -0
- scm2cpp_learn/_generated/accel_cublas/accel.cpp +24 -0
- scm2cpp_learn/_generated/accel_cublas/accel.hpp +1178 -0
- scm2cpp_learn/_generated/accel_cublas/accel_capi.cpp +76 -0
- scm2cpp_learn/_generated/classifiers.cpp +37 -0
- scm2cpp_learn/_generated/classifiers.hpp +3745 -0
- scm2cpp_learn/_generated/classifiers_capi.cpp +115 -0
- scm2cpp_learn/_generated/derived_blas/lasso_design.cpp +5 -0
- scm2cpp_learn/_generated/derived_blas/lasso_design.hpp +156 -0
- scm2cpp_learn/_generated/derived_blas/lasso_design_capi.cpp +19 -0
- scm2cpp_learn/_generated/derived_cublas/lasso_design.cpp +5 -0
- scm2cpp_learn/_generated/derived_cublas/lasso_design.hpp +158 -0
- scm2cpp_learn/_generated/derived_cublas/lasso_design_capi.cpp +19 -0
- scm2cpp_learn/_generated/derived_loops/lasso_design.cpp +5 -0
- scm2cpp_learn/_generated/derived_loops/lasso_design.hpp +179 -0
- scm2cpp_learn/_generated/derived_loops/lasso_design_capi.cpp +19 -0
- scm2cpp_learn/_generated/gpu_cuda/gpu.cpp +37 -0
- scm2cpp_learn/_generated/gpu_cuda/gpu.hpp +3846 -0
- scm2cpp_learn/_generated/gpu_cuda/gpu_capi.cpp +308 -0
- scm2cpp_learn/_generated/gramops_blas/gramops.cpp +82 -0
- scm2cpp_learn/_generated/gramops_blas/gramops.hpp +5411 -0
- scm2cpp_learn/_generated/gramops_blas/gramops_capi.cpp +244 -0
- scm2cpp_learn/_generated/gramops_loops/gramops.cpp +82 -0
- scm2cpp_learn/_generated/gramops_loops/gramops.hpp +6395 -0
- scm2cpp_learn/_generated/gramops_loops/gramops_capi.cpp +250 -0
- scm2cpp_learn/_generated/lasso_cov.cpp +7 -0
- scm2cpp_learn/_generated/lasso_cov.hpp +152 -0
- scm2cpp_learn/_generated/lasso_cov_capi.cpp +25 -0
- scm2cpp_learn/_generated/nmf_blas/nmf_cd.cpp +5 -0
- scm2cpp_learn/_generated/nmf_blas/nmf_cd.hpp +132 -0
- scm2cpp_learn/_generated/nmf_blas/nmf_cd_capi.cpp +19 -0
- scm2cpp_learn/_generated/nmf_cublas/nmf_cd.cpp +5 -0
- scm2cpp_learn/_generated/nmf_cublas/nmf_cd.hpp +136 -0
- scm2cpp_learn/_generated/nmf_cublas/nmf_cd_capi.cpp +19 -0
- scm2cpp_learn/_generated/nmf_loops/nmf_cd.cpp +5 -0
- scm2cpp_learn/_generated/nmf_loops/nmf_cd.hpp +167 -0
- scm2cpp_learn/_generated/nmf_loops/nmf_cd_capi.cpp +19 -0
- scm2cpp_learn/_generated/scm2cpp-blas.hpp +158 -0
- scm2cpp_learn/_generated/scm2cpp-cublas.hpp +155 -0
- scm2cpp_learn/_generated/scm2cpp-cuda.hpp +285 -0
- scm2cpp_learn/_generated/scm2cpp.hpp +1627 -0
- scm2cpp_learn/_gramops_blas.cp312-win_amd64.pyd +0 -0
- scm2cpp_learn/_lasso_cov.cp312-win_amd64.pyd +0 -0
- scm2cpp_learn/_lasso_derived_blas.cp312-win_amd64.pyd +0 -0
- scm2cpp_learn/_libfind.py +153 -0
- scm2cpp_learn/_nmf_blas.cp312-win_amd64.pyd +0 -0
- scm2cpp_learn/batch_capi.cu +428 -0
- scm2cpp_learn-0.18.0.dist-info/DELVEWHEEL +2 -0
- scm2cpp_learn-0.18.0.dist-info/METADATA +1171 -0
- scm2cpp_learn-0.18.0.dist-info/RECORD +72 -0
- scm2cpp_learn-0.18.0.dist-info/WHEEL +5 -0
- scm2cpp_learn-0.18.0.dist-info/top_level.txt +1 -0
- scm2cpp_learn.libs/.load-order-scm2cpp_learn-0.18.0 +4 -0
- scm2cpp_learn.libs/libopenblas-0486735c359a67419d8832e3c40e2837.dll +4 -0
- scm2cpp_learn.libs/msvcp140-73438573e87f9a2fd944b01def13566d.dll +0 -0
- scm2cpp_learn.libs/vcruntime140-052ad6a20d375957e82aa6a3c441ea54.dll +0 -0
- scm2cpp_learn.libs/vcruntime140_1-a198370e11c6e7469d1cf0ef5b3f433d.dll +0 -0
|
@@ -0,0 +1,308 @@
|
|
|
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_rbf_from_products.restype = ctypes.c_int
|
|
99
|
+
_lib.scm2cpp_rbf_from_products.argtypes = [ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.c_double, ctypes.c_int, ctypes.c_int]
|
|
100
|
+
def rbf_from_products(g, sa, sb, gamma, na, nb):
|
|
101
|
+
g = np.ascontiguousarray(g, dtype=np.float64)
|
|
102
|
+
sa = np.ascontiguousarray(sa, dtype=np.float64)
|
|
103
|
+
sb = np.ascontiguousarray(sb, dtype=np.float64)
|
|
104
|
+
return _lib.scm2cpp_rbf_from_products(g.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), sa.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), sb.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), gamma, na, nb)
|
|
105
|
+
|
|
106
|
+
_lib.scm2cpp_logistic_l1.restype = ctypes.c_int
|
|
107
|
+
_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]
|
|
108
|
+
def logistic_l1(x, y, w, cost, tol, maxnewton, 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
|
+
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)
|
|
113
|
+
|
|
114
|
+
_lib.scm2cpp_svr_liblinear.restype = ctypes.c_int
|
|
115
|
+
_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]
|
|
116
|
+
def svr_liblinear(x, y, w, beta, xnorm, cost, epsilon, iters, tol, seed, n, p):
|
|
117
|
+
x = np.ascontiguousarray(x, dtype=np.float64)
|
|
118
|
+
y = np.ascontiguousarray(y, dtype=np.float64)
|
|
119
|
+
w = np.ascontiguousarray(w, dtype=np.float64)
|
|
120
|
+
beta = np.ascontiguousarray(beta, dtype=np.float64)
|
|
121
|
+
xnorm = np.ascontiguousarray(xnorm, dtype=np.float64)
|
|
122
|
+
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)
|
|
123
|
+
|
|
124
|
+
_lib.scm2cpp_ols_rows.restype = ctypes.c_double
|
|
125
|
+
_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]
|
|
126
|
+
def ols_rows(x, y, rows, m, w, g, c, l, z, xm, n, p):
|
|
127
|
+
x = np.ascontiguousarray(x, dtype=np.float64)
|
|
128
|
+
y = np.ascontiguousarray(y, dtype=np.float64)
|
|
129
|
+
rows = np.ascontiguousarray(rows, dtype=np.int32)
|
|
130
|
+
w = np.ascontiguousarray(w, dtype=np.float64)
|
|
131
|
+
g = np.ascontiguousarray(g, dtype=np.float64)
|
|
132
|
+
c = np.ascontiguousarray(c, dtype=np.float64)
|
|
133
|
+
l = np.ascontiguousarray(l, dtype=np.float64)
|
|
134
|
+
z = np.ascontiguousarray(z, dtype=np.float64)
|
|
135
|
+
xm = np.ascontiguousarray(xm, dtype=np.float64)
|
|
136
|
+
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)
|
|
137
|
+
|
|
138
|
+
_lib.scm2cpp_ransac.restype = ctypes.c_int
|
|
139
|
+
_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]
|
|
140
|
+
def ransac(x, y, subsets, coef, mask, out, maxtrials, minsamples, thresh, stopprob, n, p):
|
|
141
|
+
x = np.ascontiguousarray(x, dtype=np.float64)
|
|
142
|
+
y = np.ascontiguousarray(y, dtype=np.float64)
|
|
143
|
+
subsets = np.ascontiguousarray(subsets, dtype=np.int32)
|
|
144
|
+
coef = np.ascontiguousarray(coef, dtype=np.float64)
|
|
145
|
+
mask = np.ascontiguousarray(mask, dtype=np.float64)
|
|
146
|
+
out = np.ascontiguousarray(out, dtype=np.float64)
|
|
147
|
+
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)
|
|
148
|
+
|
|
149
|
+
_lib.scm2cpp_sgd_loss.restype = ctypes.c_double
|
|
150
|
+
_lib.scm2cpp_sgd_loss.argtypes = [ctypes.c_int, ctypes.c_double, ctypes.c_double, ctypes.c_double]
|
|
151
|
+
def sgd_loss(loss, y, p, epsilon):
|
|
152
|
+
return _lib.scm2cpp_sgd_loss(loss, y, p, epsilon)
|
|
153
|
+
|
|
154
|
+
_lib.scm2cpp_sgd_grad.restype = ctypes.c_double
|
|
155
|
+
_lib.scm2cpp_sgd_grad.argtypes = [ctypes.c_int, ctypes.c_double, ctypes.c_double, ctypes.c_double]
|
|
156
|
+
def sgd_grad(loss, y, p, epsilon):
|
|
157
|
+
return _lib.scm2cpp_sgd_grad(loss, y, p, epsilon)
|
|
158
|
+
|
|
159
|
+
_lib.scm2cpp_sgd.restype = ctypes.c_int
|
|
160
|
+
_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]
|
|
161
|
+
def sgd(x, y, w, out, loss, lr, pen, alpha, eta0, powert, epsilon, maxiter, tol, niternochange, fitint, n, p):
|
|
162
|
+
x = np.ascontiguousarray(x, dtype=np.float64)
|
|
163
|
+
y = np.ascontiguousarray(y, dtype=np.float64)
|
|
164
|
+
w = np.ascontiguousarray(w, dtype=np.float64)
|
|
165
|
+
out = np.ascontiguousarray(out, dtype=np.float64)
|
|
166
|
+
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)
|
|
167
|
+
|
|
168
|
+
_lib.scm2cpp_sgd_min.restype = ctypes.c_double
|
|
169
|
+
_lib.scm2cpp_sgd_min.argtypes = [ctypes.c_double, ctypes.c_double]
|
|
170
|
+
def sgd_min(a, b):
|
|
171
|
+
return _lib.scm2cpp_sgd_min(a, b)
|
|
172
|
+
|
|
173
|
+
_lib.scm2cpp_min_pos.restype = ctypes.c_double
|
|
174
|
+
_lib.scm2cpp_min_pos.argtypes = [ctypes.POINTER(ctypes.c_double), ctypes.c_int]
|
|
175
|
+
def min_pos(v, m):
|
|
176
|
+
v = np.ascontiguousarray(v, dtype=np.float64)
|
|
177
|
+
return _lib.scm2cpp_min_pos(v.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), m)
|
|
178
|
+
|
|
179
|
+
_lib.scm2cpp_round_even.restype = ctypes.c_double
|
|
180
|
+
_lib.scm2cpp_round_even.argtypes = [ctypes.c_double]
|
|
181
|
+
def round_even(y):
|
|
182
|
+
return _lib.scm2cpp_round_even(y)
|
|
183
|
+
|
|
184
|
+
_lib.scm2cpp_cholesky_delete.restype = ctypes.c_int
|
|
185
|
+
_lib.scm2cpp_cholesky_delete.argtypes = [ctypes.POINTER(ctypes.c_double), ctypes.c_int, ctypes.c_int, ctypes.c_int]
|
|
186
|
+
def cholesky_delete(l, go, n, k):
|
|
187
|
+
l = np.ascontiguousarray(l, dtype=np.float64)
|
|
188
|
+
return _lib.scm2cpp_cholesky_delete(l.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), go, n, k)
|
|
189
|
+
|
|
190
|
+
_lib.scm2cpp_swap_rc.restype = ctypes.c_int
|
|
191
|
+
_lib.scm2cpp_swap_rc.argtypes = [ctypes.POINTER(ctypes.c_double), ctypes.c_int, ctypes.c_int, ctypes.c_int]
|
|
192
|
+
def swap_rc(g, a, b, p):
|
|
193
|
+
g = np.ascontiguousarray(g, dtype=np.float64)
|
|
194
|
+
return _lib.scm2cpp_swap_rc(g.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), a, b, p)
|
|
195
|
+
|
|
196
|
+
_lib.scm2cpp_lars.restype = ctypes.c_int
|
|
197
|
+
_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]
|
|
198
|
+
def lars(g, cov, coef, path, alphas, rec, nsamples, alphamin, method, maxiter, eps, p):
|
|
199
|
+
g = np.ascontiguousarray(g, dtype=np.float64)
|
|
200
|
+
cov = np.ascontiguousarray(cov, dtype=np.float64)
|
|
201
|
+
coef = np.ascontiguousarray(coef, dtype=np.float64)
|
|
202
|
+
path = np.ascontiguousarray(path, dtype=np.float64)
|
|
203
|
+
alphas = np.ascontiguousarray(alphas, dtype=np.float64)
|
|
204
|
+
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)
|
|
205
|
+
|
|
206
|
+
_lib.scm2cpp_svm_l1.restype = ctypes.c_int
|
|
207
|
+
_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]
|
|
208
|
+
def svm_l1(x, y, w, cost, tol, maxiter, seed, n, p):
|
|
209
|
+
x = np.ascontiguousarray(x, dtype=np.float64)
|
|
210
|
+
y = np.ascontiguousarray(y, dtype=np.float64)
|
|
211
|
+
w = np.ascontiguousarray(w, dtype=np.float64)
|
|
212
|
+
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)
|
|
213
|
+
|
|
214
|
+
_lib.scm2cpp_svm_l1_abs.restype = ctypes.c_double
|
|
215
|
+
_lib.scm2cpp_svm_l1_abs.argtypes = [ctypes.c_double]
|
|
216
|
+
def svm_l1_abs(a):
|
|
217
|
+
return _lib.scm2cpp_svm_l1_abs(a)
|
|
218
|
+
|
|
219
|
+
_lib.scm2cpp_eig_hypot.restype = ctypes.c_double
|
|
220
|
+
_lib.scm2cpp_eig_hypot.argtypes = [ctypes.c_double, ctypes.c_double]
|
|
221
|
+
def eig_hypot(a, b):
|
|
222
|
+
return _lib.scm2cpp_eig_hypot(a, b)
|
|
223
|
+
|
|
224
|
+
_lib.scm2cpp_sym_eigen.restype = ctypes.c_int
|
|
225
|
+
_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]
|
|
226
|
+
def sym_eigen(a, v, ev, e, m):
|
|
227
|
+
a = np.ascontiguousarray(a, dtype=np.float64)
|
|
228
|
+
v = np.ascontiguousarray(v, dtype=np.float64)
|
|
229
|
+
ev = np.ascontiguousarray(ev, dtype=np.float64)
|
|
230
|
+
e = np.ascontiguousarray(e, dtype=np.float64)
|
|
231
|
+
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)
|
|
232
|
+
|
|
233
|
+
_lib.scm2cpp_eig_abs.restype = ctypes.c_double
|
|
234
|
+
_lib.scm2cpp_eig_abs.argtypes = [ctypes.c_double]
|
|
235
|
+
def eig_abs(a):
|
|
236
|
+
return _lib.scm2cpp_eig_abs(a)
|
|
237
|
+
|
|
238
|
+
_lib.scm2cpp_eig_order.restype = ctypes.c_int
|
|
239
|
+
_lib.scm2cpp_eig_order.argtypes = [ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_int), ctypes.c_int]
|
|
240
|
+
def eig_order(ev, ord, m):
|
|
241
|
+
ev = np.ascontiguousarray(ev, dtype=np.float64)
|
|
242
|
+
ord = np.ascontiguousarray(ord, dtype=np.int32)
|
|
243
|
+
return _lib.scm2cpp_eig_order(ev.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), ord.ctypes.data_as(ctypes.POINTER(ctypes.c_int)), m)
|
|
244
|
+
|
|
245
|
+
_lib.scm2cpp_sym_eigen_top.restype = ctypes.c_int
|
|
246
|
+
_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]
|
|
247
|
+
def sym_eigen_top(a, v, ev, e, m, k):
|
|
248
|
+
a = np.ascontiguousarray(a, dtype=np.float64)
|
|
249
|
+
v = np.ascontiguousarray(v, dtype=np.float64)
|
|
250
|
+
ev = np.ascontiguousarray(ev, dtype=np.float64)
|
|
251
|
+
e = np.ascontiguousarray(e, dtype=np.float64)
|
|
252
|
+
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)
|
|
253
|
+
|
|
254
|
+
_lib.scm2cpp_sym_eigen_gen.restype = ctypes.c_int
|
|
255
|
+
_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]
|
|
256
|
+
def sym_eigen_gen(a, b, v, ev, e, m):
|
|
257
|
+
a = np.ascontiguousarray(a, dtype=np.float64)
|
|
258
|
+
b = np.ascontiguousarray(b, dtype=np.float64)
|
|
259
|
+
v = np.ascontiguousarray(v, dtype=np.float64)
|
|
260
|
+
ev = np.ascontiguousarray(ev, dtype=np.float64)
|
|
261
|
+
e = np.ascontiguousarray(e, dtype=np.float64)
|
|
262
|
+
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)
|
|
263
|
+
|
|
264
|
+
_lib.scm2cpp_ts_minnorm.restype = ctypes.c_int
|
|
265
|
+
_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]
|
|
266
|
+
def ts_minnorm(x, y, idx, w, aa, v, ev, e, ab, s, ns, fitint, p, d):
|
|
267
|
+
x = np.ascontiguousarray(x, dtype=np.float64)
|
|
268
|
+
y = np.ascontiguousarray(y, dtype=np.float64)
|
|
269
|
+
idx = np.ascontiguousarray(idx, dtype=np.int32)
|
|
270
|
+
w = np.ascontiguousarray(w, dtype=np.float64)
|
|
271
|
+
aa = np.ascontiguousarray(aa, dtype=np.float64)
|
|
272
|
+
v = np.ascontiguousarray(v, dtype=np.float64)
|
|
273
|
+
ev = np.ascontiguousarray(ev, dtype=np.float64)
|
|
274
|
+
e = np.ascontiguousarray(e, dtype=np.float64)
|
|
275
|
+
ab = np.ascontiguousarray(ab, dtype=np.float64)
|
|
276
|
+
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)
|
|
277
|
+
|
|
278
|
+
_lib.scm2cpp_ts_fit.restype = ctypes.c_int
|
|
279
|
+
_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]
|
|
280
|
+
def ts_fit(x, y, idx, w, a, b, aa, v, ev, e, ab, s, ns, fitint, p, d):
|
|
281
|
+
x = np.ascontiguousarray(x, dtype=np.float64)
|
|
282
|
+
y = np.ascontiguousarray(y, dtype=np.float64)
|
|
283
|
+
idx = np.ascontiguousarray(idx, dtype=np.int32)
|
|
284
|
+
w = np.ascontiguousarray(w, dtype=np.float64)
|
|
285
|
+
a = np.ascontiguousarray(a, dtype=np.float64)
|
|
286
|
+
b = np.ascontiguousarray(b, dtype=np.float64)
|
|
287
|
+
aa = np.ascontiguousarray(aa, dtype=np.float64)
|
|
288
|
+
v = np.ascontiguousarray(v, dtype=np.float64)
|
|
289
|
+
ev = np.ascontiguousarray(ev, dtype=np.float64)
|
|
290
|
+
e = np.ascontiguousarray(e, dtype=np.float64)
|
|
291
|
+
ab = np.ascontiguousarray(ab, dtype=np.float64)
|
|
292
|
+
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)
|
|
293
|
+
|
|
294
|
+
_lib.scm2cpp_ts_abs.restype = ctypes.c_double
|
|
295
|
+
_lib.scm2cpp_ts_abs.argtypes = [ctypes.c_double]
|
|
296
|
+
def ts_abs(v):
|
|
297
|
+
return _lib.scm2cpp_ts_abs(v)
|
|
298
|
+
|
|
299
|
+
_lib.scm2cpp_theilsen.restype = ctypes.c_int
|
|
300
|
+
_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]
|
|
301
|
+
def theilsen(x, y, idx, w, coef, nsub, ns, fitint, maxiter, tol, p):
|
|
302
|
+
x = np.ascontiguousarray(x, dtype=np.float64)
|
|
303
|
+
y = np.ascontiguousarray(y, dtype=np.float64)
|
|
304
|
+
idx = np.ascontiguousarray(idx, dtype=np.int32)
|
|
305
|
+
w = np.ascontiguousarray(w, dtype=np.float64)
|
|
306
|
+
coef = np.ascontiguousarray(coef, dtype=np.float64)
|
|
307
|
+
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)
|
|
308
|
+
|
|
@@ -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
|
+
|