numo-linalg-alt 0.3.0 → 0.4.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/ext/numo/linalg/blas/dot.c +59 -59
- data/ext/numo/linalg/blas/dot_sub.c +58 -58
- data/ext/numo/linalg/blas/gemm.c +157 -148
- data/ext/numo/linalg/blas/gemv.c +131 -127
- data/ext/numo/linalg/blas/nrm2.c +50 -50
- data/ext/numo/linalg/lapack/gees.c +239 -220
- data/ext/numo/linalg/lapack/geev.c +127 -110
- data/ext/numo/linalg/lapack/gelsd.c +81 -70
- data/ext/numo/linalg/lapack/geqrf.c +52 -51
- data/ext/numo/linalg/lapack/gerqf.c +70 -0
- data/ext/numo/linalg/lapack/gerqf.h +15 -0
- data/ext/numo/linalg/lapack/gesdd.c +96 -86
- data/ext/numo/linalg/lapack/gesv.c +80 -78
- data/ext/numo/linalg/lapack/gesvd.c +140 -129
- data/ext/numo/linalg/lapack/getrf.c +51 -50
- data/ext/numo/linalg/lapack/getri.c +64 -63
- data/ext/numo/linalg/lapack/getrs.c +92 -88
- data/ext/numo/linalg/lapack/gges.c +214 -0
- data/ext/numo/linalg/lapack/gges.h +15 -0
- data/ext/numo/linalg/lapack/heev.c +54 -52
- data/ext/numo/linalg/lapack/heevd.c +54 -52
- data/ext/numo/linalg/lapack/heevr.c +109 -98
- data/ext/numo/linalg/lapack/hegv.c +77 -74
- data/ext/numo/linalg/lapack/hegvd.c +77 -74
- data/ext/numo/linalg/lapack/hegvx.c +132 -120
- data/ext/numo/linalg/lapack/hetrf.c +54 -50
- data/ext/numo/linalg/lapack/lange.c +45 -44
- data/ext/numo/linalg/lapack/orgqr.c +63 -62
- data/ext/numo/linalg/lapack/orgrq.c +78 -0
- data/ext/numo/linalg/lapack/orgrq.h +15 -0
- data/ext/numo/linalg/lapack/potrf.c +49 -48
- data/ext/numo/linalg/lapack/potri.c +49 -48
- data/ext/numo/linalg/lapack/potrs.c +74 -72
- data/ext/numo/linalg/lapack/syev.c +54 -52
- data/ext/numo/linalg/lapack/syevd.c +54 -52
- data/ext/numo/linalg/lapack/syevr.c +107 -98
- data/ext/numo/linalg/lapack/sygv.c +77 -73
- data/ext/numo/linalg/lapack/sygvd.c +77 -73
- data/ext/numo/linalg/lapack/sygvx.c +132 -120
- data/ext/numo/linalg/lapack/sytrf.c +54 -50
- data/ext/numo/linalg/lapack/trtrs.c +79 -75
- data/ext/numo/linalg/lapack/ungqr.c +63 -62
- data/ext/numo/linalg/lapack/ungrq.c +78 -0
- data/ext/numo/linalg/lapack/ungrq.h +15 -0
- data/ext/numo/linalg/linalg.c +20 -10
- data/ext/numo/linalg/linalg.h +4 -0
- data/ext/numo/linalg/util.c +8 -0
- data/ext/numo/linalg/util.h +1 -0
- data/lib/numo/linalg/version.rb +1 -1
- data/lib/numo/linalg.rb +139 -3
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38d36b0f9d79ba30d90825df434ff9b7c4bdd44d71a120e65a75b7474017c04d
|
4
|
+
data.tar.gz: ea9c959067a82b0acf3c1990317657dfea6b055a2c4244d7cdfb7fa76b1d298b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71004a21081aec907f9142dfbbed991d662c11639450d691f3c4322bfe5a68d66279c48259c9cb1a8a33704d08c9033cc675a7370a00c402c31b68cf6848fea5
|
7
|
+
data.tar.gz: 667a1f392aa95e2681b40575ea53c18669596ee62d77f1e01a470b25691963111b8632a967acf6eef42be0544d99206bcf0fa1407de093a2d225a0aeaf21afe3
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## [[0.4.0](https://github.com/yoshoku/numo-linalg-alt/compare/v0.3.0...v0.4.0)] - 2025-10-16
|
2
|
+
|
3
|
+
- add `rq`, `qz`, and `tanm` module functions to Numo::Linalg.
|
4
|
+
|
1
5
|
## [[0.3.0](https://github.com/yoshoku/numo-linalg-alt/compare/v0.2.0...v0.3.0)] - 2025-10-06
|
2
6
|
|
3
7
|
- add `schur`, `cosm`, `sinm`, `orthogonal_procrustes`, and `polar` module functions to Numo::Linalg.
|
data/ext/numo/linalg/blas/dot.c
CHANGED
@@ -1,64 +1,64 @@
|
|
1
1
|
#include "dot.h"
|
2
2
|
|
3
|
-
#define DEF_LINALG_FUNC(tDType, tNAryClass, fBlasFunc)
|
4
|
-
static void _iter_##fBlasFunc(na_loop_t* const lp) {
|
5
|
-
tDType* x = (tDType*)NDL_PTR(lp, 0);
|
6
|
-
tDType* y = (tDType*)NDL_PTR(lp, 1);
|
7
|
-
tDType* d = (tDType*)NDL_PTR(lp, 2);
|
8
|
-
const blasint n = (blasint)NDL_SHAPE(lp, 0)[0];
|
9
|
-
tDType ret = cblas_##fBlasFunc(n, x, 1, y, 1);
|
10
|
-
*d = ret;
|
11
|
-
}
|
12
|
-
|
13
|
-
static VALUE _linalg_blas_##fBlasFunc(VALUE self, VALUE x, VALUE y) {
|
14
|
-
if (CLASS_OF(x) != tNAryClass) {
|
15
|
-
x = rb_funcall(tNAryClass, rb_intern("cast"), 1, x);
|
16
|
-
}
|
17
|
-
if (!RTEST(nary_check_contiguous(x))) {
|
18
|
-
x = nary_dup(x);
|
19
|
-
}
|
20
|
-
if (CLASS_OF(y) != tNAryClass) {
|
21
|
-
y = rb_funcall(tNAryClass, rb_intern("cast"), 1, y);
|
22
|
-
}
|
23
|
-
if (!RTEST(nary_check_contiguous(y))) {
|
24
|
-
y = nary_dup(y);
|
25
|
-
}
|
26
|
-
|
27
|
-
narray_t* x_nary = NULL;
|
28
|
-
GetNArray(x, x_nary);
|
29
|
-
narray_t* y_nary = NULL;
|
30
|
-
GetNArray(y, y_nary);
|
31
|
-
|
32
|
-
if (NA_NDIM(x_nary) != 1) {
|
33
|
-
rb_raise(rb_eArgError, "x must be 1-dimensional");
|
34
|
-
return Qnil;
|
35
|
-
}
|
36
|
-
if (NA_NDIM(y_nary) != 1) {
|
37
|
-
rb_raise(rb_eArgError, "y must be 1-dimensional");
|
38
|
-
return Qnil;
|
39
|
-
}
|
40
|
-
if (NA_SIZE(x_nary) == 0) {
|
41
|
-
rb_raise(rb_eArgError, "x must not be empty");
|
42
|
-
return Qnil;
|
43
|
-
}
|
44
|
-
if (NA_SIZE(y_nary) == 0) {
|
45
|
-
rb_raise(rb_eArgError, "x must not be empty");
|
46
|
-
return Qnil;
|
47
|
-
}
|
48
|
-
if (NA_SIZE(x_nary) != NA_SIZE(y_nary)) {
|
49
|
-
rb_raise(rb_eArgError, "x and y must have same size");
|
50
|
-
return Qnil;
|
51
|
-
}
|
52
|
-
|
53
|
-
ndfunc_arg_in_t ain[2] = { { tNAryClass, 1 }, { tNAryClass, 1 } };
|
54
|
-
size_t shape_out[1] = { 1 };
|
55
|
-
ndfunc_arg_out_t aout[1] = { { tNAryClass, 0, shape_out } };
|
56
|
-
ndfunc_t ndf = { _iter_##fBlasFunc, NO_LOOP | NDF_EXTRACT, 2, 1, ain, aout };
|
57
|
-
VALUE ret = na_ndloop(&ndf, 2, x, y);
|
58
|
-
|
59
|
-
RB_GC_GUARD(x);
|
60
|
-
RB_GC_GUARD(y);
|
61
|
-
return ret;
|
3
|
+
#define DEF_LINALG_FUNC(tDType, tNAryClass, fBlasFunc) \
|
4
|
+
static void _iter_##fBlasFunc(na_loop_t* const lp) { \
|
5
|
+
tDType* x = (tDType*)NDL_PTR(lp, 0); \
|
6
|
+
tDType* y = (tDType*)NDL_PTR(lp, 1); \
|
7
|
+
tDType* d = (tDType*)NDL_PTR(lp, 2); \
|
8
|
+
const blasint n = (blasint)NDL_SHAPE(lp, 0)[0]; \
|
9
|
+
tDType ret = cblas_##fBlasFunc(n, x, 1, y, 1); \
|
10
|
+
*d = ret; \
|
11
|
+
} \
|
12
|
+
\
|
13
|
+
static VALUE _linalg_blas_##fBlasFunc(VALUE self, VALUE x, VALUE y) { \
|
14
|
+
if (CLASS_OF(x) != tNAryClass) { \
|
15
|
+
x = rb_funcall(tNAryClass, rb_intern("cast"), 1, x); \
|
16
|
+
} \
|
17
|
+
if (!RTEST(nary_check_contiguous(x))) { \
|
18
|
+
x = nary_dup(x); \
|
19
|
+
} \
|
20
|
+
if (CLASS_OF(y) != tNAryClass) { \
|
21
|
+
y = rb_funcall(tNAryClass, rb_intern("cast"), 1, y); \
|
22
|
+
} \
|
23
|
+
if (!RTEST(nary_check_contiguous(y))) { \
|
24
|
+
y = nary_dup(y); \
|
25
|
+
} \
|
26
|
+
\
|
27
|
+
narray_t* x_nary = NULL; \
|
28
|
+
GetNArray(x, x_nary); \
|
29
|
+
narray_t* y_nary = NULL; \
|
30
|
+
GetNArray(y, y_nary); \
|
31
|
+
\
|
32
|
+
if (NA_NDIM(x_nary) != 1) { \
|
33
|
+
rb_raise(rb_eArgError, "x must be 1-dimensional"); \
|
34
|
+
return Qnil; \
|
35
|
+
} \
|
36
|
+
if (NA_NDIM(y_nary) != 1) { \
|
37
|
+
rb_raise(rb_eArgError, "y must be 1-dimensional"); \
|
38
|
+
return Qnil; \
|
39
|
+
} \
|
40
|
+
if (NA_SIZE(x_nary) == 0) { \
|
41
|
+
rb_raise(rb_eArgError, "x must not be empty"); \
|
42
|
+
return Qnil; \
|
43
|
+
} \
|
44
|
+
if (NA_SIZE(y_nary) == 0) { \
|
45
|
+
rb_raise(rb_eArgError, "x must not be empty"); \
|
46
|
+
return Qnil; \
|
47
|
+
} \
|
48
|
+
if (NA_SIZE(x_nary) != NA_SIZE(y_nary)) { \
|
49
|
+
rb_raise(rb_eArgError, "x and y must have same size"); \
|
50
|
+
return Qnil; \
|
51
|
+
} \
|
52
|
+
\
|
53
|
+
ndfunc_arg_in_t ain[2] = { { tNAryClass, 1 }, { tNAryClass, 1 } }; \
|
54
|
+
size_t shape_out[1] = { 1 }; \
|
55
|
+
ndfunc_arg_out_t aout[1] = { { tNAryClass, 0, shape_out } }; \
|
56
|
+
ndfunc_t ndf = { _iter_##fBlasFunc, NO_LOOP | NDF_EXTRACT, 2, 1, ain, aout }; \
|
57
|
+
VALUE ret = na_ndloop(&ndf, 2, x, y); \
|
58
|
+
\
|
59
|
+
RB_GC_GUARD(x); \
|
60
|
+
RB_GC_GUARD(y); \
|
61
|
+
return ret; \
|
62
62
|
}
|
63
63
|
|
64
64
|
DEF_LINALG_FUNC(double, numo_cDFloat, ddot)
|
@@ -1,63 +1,63 @@
|
|
1
1
|
#include "dot_sub.h"
|
2
2
|
|
3
|
-
#define DEF_LINALG_FUNC(tDType, tNAryClass, fBlasFunc)
|
4
|
-
static void _iter_##fBlasFunc(na_loop_t* const lp) {
|
5
|
-
tDType* x = (tDType*)NDL_PTR(lp, 0);
|
6
|
-
tDType* y = (tDType*)NDL_PTR(lp, 1);
|
7
|
-
tDType* d = (tDType*)NDL_PTR(lp, 2);
|
8
|
-
const blasint n = (blasint)NDL_SHAPE(lp, 0)[0];
|
9
|
-
cblas_##fBlasFunc(n, x, 1, y, 1, d);
|
10
|
-
}
|
11
|
-
|
12
|
-
static VALUE _linalg_blas_##fBlasFunc(VALUE self, VALUE x, VALUE y) {
|
13
|
-
if (CLASS_OF(x) != tNAryClass) {
|
14
|
-
x = rb_funcall(tNAryClass, rb_intern("cast"), 1, x);
|
15
|
-
}
|
16
|
-
if (!RTEST(nary_check_contiguous(x))) {
|
17
|
-
x = nary_dup(x);
|
18
|
-
}
|
19
|
-
if (CLASS_OF(y) != tNAryClass) {
|
20
|
-
y = rb_funcall(tNAryClass, rb_intern("cast"), 1, y);
|
21
|
-
}
|
22
|
-
if (!RTEST(nary_check_contiguous(y))) {
|
23
|
-
y = nary_dup(y);
|
24
|
-
}
|
25
|
-
|
26
|
-
narray_t* x_nary = NULL;
|
27
|
-
GetNArray(x, x_nary);
|
28
|
-
narray_t* y_nary = NULL;
|
29
|
-
GetNArray(y, y_nary);
|
30
|
-
|
31
|
-
if (NA_NDIM(x_nary) != 1) {
|
32
|
-
rb_raise(rb_eArgError, "x must be 1-dimensional");
|
33
|
-
return Qnil;
|
34
|
-
}
|
35
|
-
if (NA_NDIM(y_nary) != 1) {
|
36
|
-
rb_raise(rb_eArgError, "y must be 1-dimensional");
|
37
|
-
return Qnil;
|
38
|
-
}
|
39
|
-
if (NA_SIZE(x_nary) == 0) {
|
40
|
-
rb_raise(rb_eArgError, "x must not be empty");
|
41
|
-
return Qnil;
|
42
|
-
}
|
43
|
-
if (NA_SIZE(y_nary) == 0) {
|
44
|
-
rb_raise(rb_eArgError, "x must not be empty");
|
45
|
-
return Qnil;
|
46
|
-
}
|
47
|
-
if (NA_SIZE(x_nary) != NA_SIZE(y_nary)) {
|
48
|
-
rb_raise(rb_eArgError, "x and y must have same size");
|
49
|
-
return Qnil;
|
50
|
-
}
|
51
|
-
|
52
|
-
ndfunc_arg_in_t ain[2] = { { tNAryClass, 1 }, { tNAryClass, 1 } };
|
53
|
-
size_t shape_out[1] = { 1 };
|
54
|
-
ndfunc_arg_out_t aout[1] = { { tNAryClass, 0, shape_out } };
|
55
|
-
ndfunc_t ndf = { _iter_##fBlasFunc, NO_LOOP | NDF_EXTRACT, 2, 1, ain, aout };
|
56
|
-
VALUE ret = na_ndloop(&ndf, 2, x, y);
|
57
|
-
|
58
|
-
RB_GC_GUARD(x);
|
59
|
-
RB_GC_GUARD(y);
|
60
|
-
return ret;
|
3
|
+
#define DEF_LINALG_FUNC(tDType, tNAryClass, fBlasFunc) \
|
4
|
+
static void _iter_##fBlasFunc(na_loop_t* const lp) { \
|
5
|
+
tDType* x = (tDType*)NDL_PTR(lp, 0); \
|
6
|
+
tDType* y = (tDType*)NDL_PTR(lp, 1); \
|
7
|
+
tDType* d = (tDType*)NDL_PTR(lp, 2); \
|
8
|
+
const blasint n = (blasint)NDL_SHAPE(lp, 0)[0]; \
|
9
|
+
cblas_##fBlasFunc(n, x, 1, y, 1, d); \
|
10
|
+
} \
|
11
|
+
\
|
12
|
+
static VALUE _linalg_blas_##fBlasFunc(VALUE self, VALUE x, VALUE y) { \
|
13
|
+
if (CLASS_OF(x) != tNAryClass) { \
|
14
|
+
x = rb_funcall(tNAryClass, rb_intern("cast"), 1, x); \
|
15
|
+
} \
|
16
|
+
if (!RTEST(nary_check_contiguous(x))) { \
|
17
|
+
x = nary_dup(x); \
|
18
|
+
} \
|
19
|
+
if (CLASS_OF(y) != tNAryClass) { \
|
20
|
+
y = rb_funcall(tNAryClass, rb_intern("cast"), 1, y); \
|
21
|
+
} \
|
22
|
+
if (!RTEST(nary_check_contiguous(y))) { \
|
23
|
+
y = nary_dup(y); \
|
24
|
+
} \
|
25
|
+
\
|
26
|
+
narray_t* x_nary = NULL; \
|
27
|
+
GetNArray(x, x_nary); \
|
28
|
+
narray_t* y_nary = NULL; \
|
29
|
+
GetNArray(y, y_nary); \
|
30
|
+
\
|
31
|
+
if (NA_NDIM(x_nary) != 1) { \
|
32
|
+
rb_raise(rb_eArgError, "x must be 1-dimensional"); \
|
33
|
+
return Qnil; \
|
34
|
+
} \
|
35
|
+
if (NA_NDIM(y_nary) != 1) { \
|
36
|
+
rb_raise(rb_eArgError, "y must be 1-dimensional"); \
|
37
|
+
return Qnil; \
|
38
|
+
} \
|
39
|
+
if (NA_SIZE(x_nary) == 0) { \
|
40
|
+
rb_raise(rb_eArgError, "x must not be empty"); \
|
41
|
+
return Qnil; \
|
42
|
+
} \
|
43
|
+
if (NA_SIZE(y_nary) == 0) { \
|
44
|
+
rb_raise(rb_eArgError, "x must not be empty"); \
|
45
|
+
return Qnil; \
|
46
|
+
} \
|
47
|
+
if (NA_SIZE(x_nary) != NA_SIZE(y_nary)) { \
|
48
|
+
rb_raise(rb_eArgError, "x and y must have same size"); \
|
49
|
+
return Qnil; \
|
50
|
+
} \
|
51
|
+
\
|
52
|
+
ndfunc_arg_in_t ain[2] = { { tNAryClass, 1 }, { tNAryClass, 1 } }; \
|
53
|
+
size_t shape_out[1] = { 1 }; \
|
54
|
+
ndfunc_arg_out_t aout[1] = { { tNAryClass, 0, shape_out } }; \
|
55
|
+
ndfunc_t ndf = { _iter_##fBlasFunc, NO_LOOP | NDF_EXTRACT, 2, 1, ain, aout }; \
|
56
|
+
VALUE ret = na_ndloop(&ndf, 2, x, y); \
|
57
|
+
\
|
58
|
+
RB_GC_GUARD(x); \
|
59
|
+
RB_GC_GUARD(y); \
|
60
|
+
return ret; \
|
61
61
|
}
|
62
62
|
|
63
63
|
DEF_LINALG_FUNC(double, numo_cDComplex, zdotu_sub)
|