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.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/ext/numo/linalg/blas/dot.c +59 -59
  4. data/ext/numo/linalg/blas/dot_sub.c +58 -58
  5. data/ext/numo/linalg/blas/gemm.c +157 -148
  6. data/ext/numo/linalg/blas/gemv.c +131 -127
  7. data/ext/numo/linalg/blas/nrm2.c +50 -50
  8. data/ext/numo/linalg/lapack/gees.c +239 -220
  9. data/ext/numo/linalg/lapack/geev.c +127 -110
  10. data/ext/numo/linalg/lapack/gelsd.c +81 -70
  11. data/ext/numo/linalg/lapack/geqrf.c +52 -51
  12. data/ext/numo/linalg/lapack/gerqf.c +70 -0
  13. data/ext/numo/linalg/lapack/gerqf.h +15 -0
  14. data/ext/numo/linalg/lapack/gesdd.c +96 -86
  15. data/ext/numo/linalg/lapack/gesv.c +80 -78
  16. data/ext/numo/linalg/lapack/gesvd.c +140 -129
  17. data/ext/numo/linalg/lapack/getrf.c +51 -50
  18. data/ext/numo/linalg/lapack/getri.c +64 -63
  19. data/ext/numo/linalg/lapack/getrs.c +92 -88
  20. data/ext/numo/linalg/lapack/gges.c +214 -0
  21. data/ext/numo/linalg/lapack/gges.h +15 -0
  22. data/ext/numo/linalg/lapack/heev.c +54 -52
  23. data/ext/numo/linalg/lapack/heevd.c +54 -52
  24. data/ext/numo/linalg/lapack/heevr.c +109 -98
  25. data/ext/numo/linalg/lapack/hegv.c +77 -74
  26. data/ext/numo/linalg/lapack/hegvd.c +77 -74
  27. data/ext/numo/linalg/lapack/hegvx.c +132 -120
  28. data/ext/numo/linalg/lapack/hetrf.c +54 -50
  29. data/ext/numo/linalg/lapack/lange.c +45 -44
  30. data/ext/numo/linalg/lapack/orgqr.c +63 -62
  31. data/ext/numo/linalg/lapack/orgrq.c +78 -0
  32. data/ext/numo/linalg/lapack/orgrq.h +15 -0
  33. data/ext/numo/linalg/lapack/potrf.c +49 -48
  34. data/ext/numo/linalg/lapack/potri.c +49 -48
  35. data/ext/numo/linalg/lapack/potrs.c +74 -72
  36. data/ext/numo/linalg/lapack/syev.c +54 -52
  37. data/ext/numo/linalg/lapack/syevd.c +54 -52
  38. data/ext/numo/linalg/lapack/syevr.c +107 -98
  39. data/ext/numo/linalg/lapack/sygv.c +77 -73
  40. data/ext/numo/linalg/lapack/sygvd.c +77 -73
  41. data/ext/numo/linalg/lapack/sygvx.c +132 -120
  42. data/ext/numo/linalg/lapack/sytrf.c +54 -50
  43. data/ext/numo/linalg/lapack/trtrs.c +79 -75
  44. data/ext/numo/linalg/lapack/ungqr.c +63 -62
  45. data/ext/numo/linalg/lapack/ungrq.c +78 -0
  46. data/ext/numo/linalg/lapack/ungrq.h +15 -0
  47. data/ext/numo/linalg/linalg.c +20 -10
  48. data/ext/numo/linalg/linalg.h +4 -0
  49. data/ext/numo/linalg/util.c +8 -0
  50. data/ext/numo/linalg/util.h +1 -0
  51. data/lib/numo/linalg/version.rb +1 -1
  52. data/lib/numo/linalg.rb +139 -3
  53. metadata +10 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bf52b8241dd646725159141067e9e38948c95d89d459f81e8ec5b19a20ce7a69
4
- data.tar.gz: 286fb08653029ff6bfd745323fd7b8e1165a9d6027bbcf3871bb5333eae8eddd
3
+ metadata.gz: 38d36b0f9d79ba30d90825df434ff9b7c4bdd44d71a120e65a75b7474017c04d
4
+ data.tar.gz: ea9c959067a82b0acf3c1990317657dfea6b055a2c4244d7cdfb7fa76b1d298b
5
5
  SHA512:
6
- metadata.gz: a7205197001dd99f404a39e63ac7caf6a88fa653ab9487756d3ef69b03c2c9abedc0c3900a1284ae70d41415ddc97f9180e1977d765e3b5f46578a72c67429cf
7
- data.tar.gz: 3b18b323a4d0873f19c5514ca3856de7651078ef227559f2c55ae9f82f6cb05b4a2bf28958a4c499d7909741e6ad0e58ae53b5821681d6d0f9a363b3719291da
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.
@@ -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)