numo-linalg-alt 0.2.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 +7 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/LICENSE.txt +27 -0
- data/README.md +106 -0
- data/ext/numo/linalg/blas/dot.c +72 -0
- data/ext/numo/linalg/blas/dot.h +13 -0
- data/ext/numo/linalg/blas/dot_sub.c +71 -0
- data/ext/numo/linalg/blas/dot_sub.h +13 -0
- data/ext/numo/linalg/blas/gemm.c +184 -0
- data/ext/numo/linalg/blas/gemm.h +16 -0
- data/ext/numo/linalg/blas/gemv.c +161 -0
- data/ext/numo/linalg/blas/gemv.h +16 -0
- data/ext/numo/linalg/blas/nrm2.c +67 -0
- data/ext/numo/linalg/blas/nrm2.h +13 -0
- data/ext/numo/linalg/converter.c +67 -0
- data/ext/numo/linalg/converter.h +23 -0
- data/ext/numo/linalg/extconf.rb +99 -0
- data/ext/numo/linalg/lapack/geev.c +152 -0
- data/ext/numo/linalg/lapack/geev.h +15 -0
- data/ext/numo/linalg/lapack/gelsd.c +92 -0
- data/ext/numo/linalg/lapack/gelsd.h +15 -0
- data/ext/numo/linalg/lapack/geqrf.c +72 -0
- data/ext/numo/linalg/lapack/geqrf.h +15 -0
- data/ext/numo/linalg/lapack/gesdd.c +108 -0
- data/ext/numo/linalg/lapack/gesdd.h +15 -0
- data/ext/numo/linalg/lapack/gesv.c +99 -0
- data/ext/numo/linalg/lapack/gesv.h +15 -0
- data/ext/numo/linalg/lapack/gesvd.c +152 -0
- data/ext/numo/linalg/lapack/gesvd.h +15 -0
- data/ext/numo/linalg/lapack/getrf.c +71 -0
- data/ext/numo/linalg/lapack/getrf.h +15 -0
- data/ext/numo/linalg/lapack/getri.c +82 -0
- data/ext/numo/linalg/lapack/getri.h +15 -0
- data/ext/numo/linalg/lapack/getrs.c +110 -0
- data/ext/numo/linalg/lapack/getrs.h +15 -0
- data/ext/numo/linalg/lapack/heev.c +71 -0
- data/ext/numo/linalg/lapack/heev.h +15 -0
- data/ext/numo/linalg/lapack/heevd.c +71 -0
- data/ext/numo/linalg/lapack/heevd.h +15 -0
- data/ext/numo/linalg/lapack/heevr.c +111 -0
- data/ext/numo/linalg/lapack/heevr.h +15 -0
- data/ext/numo/linalg/lapack/hegv.c +94 -0
- data/ext/numo/linalg/lapack/hegv.h +15 -0
- data/ext/numo/linalg/lapack/hegvd.c +94 -0
- data/ext/numo/linalg/lapack/hegvd.h +15 -0
- data/ext/numo/linalg/lapack/hegvx.c +133 -0
- data/ext/numo/linalg/lapack/hegvx.h +15 -0
- data/ext/numo/linalg/lapack/hetrf.c +68 -0
- data/ext/numo/linalg/lapack/hetrf.h +15 -0
- data/ext/numo/linalg/lapack/lange.c +66 -0
- data/ext/numo/linalg/lapack/lange.h +15 -0
- data/ext/numo/linalg/lapack/orgqr.c +79 -0
- data/ext/numo/linalg/lapack/orgqr.h +15 -0
- data/ext/numo/linalg/lapack/potrf.c +70 -0
- data/ext/numo/linalg/lapack/potrf.h +15 -0
- data/ext/numo/linalg/lapack/potri.c +70 -0
- data/ext/numo/linalg/lapack/potri.h +15 -0
- data/ext/numo/linalg/lapack/potrs.c +94 -0
- data/ext/numo/linalg/lapack/potrs.h +15 -0
- data/ext/numo/linalg/lapack/syev.c +71 -0
- data/ext/numo/linalg/lapack/syev.h +15 -0
- data/ext/numo/linalg/lapack/syevd.c +71 -0
- data/ext/numo/linalg/lapack/syevd.h +15 -0
- data/ext/numo/linalg/lapack/syevr.c +111 -0
- data/ext/numo/linalg/lapack/syevr.h +15 -0
- data/ext/numo/linalg/lapack/sygv.c +93 -0
- data/ext/numo/linalg/lapack/sygv.h +15 -0
- data/ext/numo/linalg/lapack/sygvd.c +93 -0
- data/ext/numo/linalg/lapack/sygvd.h +15 -0
- data/ext/numo/linalg/lapack/sygvx.c +133 -0
- data/ext/numo/linalg/lapack/sygvx.h +15 -0
- data/ext/numo/linalg/lapack/sytrf.c +72 -0
- data/ext/numo/linalg/lapack/sytrf.h +15 -0
- data/ext/numo/linalg/lapack/trtrs.c +99 -0
- data/ext/numo/linalg/lapack/trtrs.h +15 -0
- data/ext/numo/linalg/lapack/ungqr.c +79 -0
- data/ext/numo/linalg/lapack/ungqr.h +15 -0
- data/ext/numo/linalg/linalg.c +290 -0
- data/ext/numo/linalg/linalg.h +85 -0
- data/ext/numo/linalg/util.c +95 -0
- data/ext/numo/linalg/util.h +17 -0
- data/lib/numo/linalg/version.rb +10 -0
- data/lib/numo/linalg.rb +1309 -0
- data/vendor/tmp/.gitkeep +0 -0
- metadata +146 -0
@@ -0,0 +1,85 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) 2025 Atsushi Tatsuma
|
3
|
+
* All rights reserved.
|
4
|
+
*
|
5
|
+
* Redistribution and use in source and binary forms, with or without
|
6
|
+
* modification, are permitted provided that the following conditions are met:
|
7
|
+
*
|
8
|
+
* * Redistributions of source code must retain the above copyright notice, this
|
9
|
+
* list of conditions and the following disclaimer.
|
10
|
+
*
|
11
|
+
* * Redistributions in binary form must reproduce the above copyright notice,
|
12
|
+
* this list of conditions and the following disclaimer in the documentation
|
13
|
+
* and/or other materials provided with the distribution.
|
14
|
+
*
|
15
|
+
* * Neither the name of the copyright holder nor the names of its
|
16
|
+
* contributors may be used to endorse or promote products derived from
|
17
|
+
* this software without specific prior written permission.
|
18
|
+
*
|
19
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
20
|
+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
21
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
22
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
23
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
24
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
25
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
26
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
27
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
28
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
29
|
+
*/
|
30
|
+
|
31
|
+
#ifndef NUMO_LINALG_ALT_LINALG_H
|
32
|
+
#define NUMO_LINALG_ALT_LINALG_H 1
|
33
|
+
|
34
|
+
#include <string.h>
|
35
|
+
|
36
|
+
#include <ruby.h>
|
37
|
+
|
38
|
+
#include <cblas.h>
|
39
|
+
#include <lapacke.h>
|
40
|
+
#include <openblas_config.h>
|
41
|
+
|
42
|
+
#include <numo/narray.h>
|
43
|
+
#include <numo/template.h>
|
44
|
+
|
45
|
+
#include "converter.h"
|
46
|
+
#include "util.h"
|
47
|
+
|
48
|
+
#include "blas/dot.h"
|
49
|
+
#include "blas/dot_sub.h"
|
50
|
+
#include "blas/gemm.h"
|
51
|
+
#include "blas/gemv.h"
|
52
|
+
#include "blas/nrm2.h"
|
53
|
+
|
54
|
+
#include "lapack/geev.h"
|
55
|
+
#include "lapack/gelsd.h"
|
56
|
+
#include "lapack/geqrf.h"
|
57
|
+
#include "lapack/gesdd.h"
|
58
|
+
#include "lapack/gesv.h"
|
59
|
+
#include "lapack/gesvd.h"
|
60
|
+
#include "lapack/getrf.h"
|
61
|
+
#include "lapack/getri.h"
|
62
|
+
#include "lapack/getrs.h"
|
63
|
+
#include "lapack/heev.h"
|
64
|
+
#include "lapack/heevd.h"
|
65
|
+
#include "lapack/heevr.h"
|
66
|
+
#include "lapack/hegv.h"
|
67
|
+
#include "lapack/hegvd.h"
|
68
|
+
#include "lapack/hegvx.h"
|
69
|
+
#include "lapack/hetrf.h"
|
70
|
+
#include "lapack/lange.h"
|
71
|
+
#include "lapack/orgqr.h"
|
72
|
+
#include "lapack/potrf.h"
|
73
|
+
#include "lapack/potri.h"
|
74
|
+
#include "lapack/potrs.h"
|
75
|
+
#include "lapack/syev.h"
|
76
|
+
#include "lapack/syevd.h"
|
77
|
+
#include "lapack/syevr.h"
|
78
|
+
#include "lapack/sygv.h"
|
79
|
+
#include "lapack/sygvd.h"
|
80
|
+
#include "lapack/sygvx.h"
|
81
|
+
#include "lapack/sytrf.h"
|
82
|
+
#include "lapack/trtrs.h"
|
83
|
+
#include "lapack/ungqr.h"
|
84
|
+
|
85
|
+
#endif /* NUMO_LINALG_ALT_LINALG_H */
|
@@ -0,0 +1,95 @@
|
|
1
|
+
#include "util.h"
|
2
|
+
|
3
|
+
lapack_int get_itype(VALUE val) {
|
4
|
+
const lapack_int itype = NUM2INT(val);
|
5
|
+
|
6
|
+
if (itype != 1 && itype != 2 && itype != 3) {
|
7
|
+
rb_raise(rb_eArgError, "itype must be 1, 2 or 3");
|
8
|
+
}
|
9
|
+
|
10
|
+
return itype;
|
11
|
+
}
|
12
|
+
|
13
|
+
char get_jobz(VALUE val) {
|
14
|
+
const char jobz = NUM2CHR(val);
|
15
|
+
|
16
|
+
if (jobz != 'N' && jobz != 'V') {
|
17
|
+
rb_raise(rb_eArgError, "jobz must be 'N' or 'V'");
|
18
|
+
}
|
19
|
+
|
20
|
+
return jobz;
|
21
|
+
}
|
22
|
+
|
23
|
+
char get_range(VALUE val) {
|
24
|
+
const char range = NUM2CHR(val);
|
25
|
+
|
26
|
+
if (range != 'A' && range != 'V' && range != 'I') {
|
27
|
+
rb_raise(rb_eArgError, "range must be 'A', 'V' or 'I'");
|
28
|
+
}
|
29
|
+
|
30
|
+
return range;
|
31
|
+
}
|
32
|
+
|
33
|
+
char get_uplo(VALUE val) {
|
34
|
+
const char uplo = NUM2CHR(val);
|
35
|
+
|
36
|
+
if (uplo != 'U' && uplo != 'L') {
|
37
|
+
rb_raise(rb_eArgError, "uplo must be 'U' or 'L'");
|
38
|
+
}
|
39
|
+
|
40
|
+
return uplo;
|
41
|
+
}
|
42
|
+
|
43
|
+
int get_matrix_layout(VALUE val) {
|
44
|
+
const char option = NUM2CHR(val);
|
45
|
+
|
46
|
+
switch (option) {
|
47
|
+
case 'r':
|
48
|
+
case 'R':
|
49
|
+
break;
|
50
|
+
case 'c':
|
51
|
+
case 'C':
|
52
|
+
rb_warn("Numo::Linalg does not support column major.");
|
53
|
+
break;
|
54
|
+
}
|
55
|
+
|
56
|
+
return LAPACK_ROW_MAJOR;
|
57
|
+
}
|
58
|
+
|
59
|
+
enum CBLAS_TRANSPOSE get_cblas_trans(VALUE val) {
|
60
|
+
const char option = NUM2CHR(val);
|
61
|
+
enum CBLAS_TRANSPOSE res = CblasNoTrans;
|
62
|
+
|
63
|
+
switch (option) {
|
64
|
+
case 'n':
|
65
|
+
case 'N':
|
66
|
+
res = CblasNoTrans;
|
67
|
+
break;
|
68
|
+
case 't':
|
69
|
+
case 'T':
|
70
|
+
res = CblasTrans;
|
71
|
+
break;
|
72
|
+
case 'c':
|
73
|
+
case 'C':
|
74
|
+
res = CblasConjTrans;
|
75
|
+
break;
|
76
|
+
}
|
77
|
+
|
78
|
+
return res;
|
79
|
+
}
|
80
|
+
|
81
|
+
enum CBLAS_ORDER get_cblas_order(VALUE val) {
|
82
|
+
const char option = NUM2CHR(val);
|
83
|
+
|
84
|
+
switch (option) {
|
85
|
+
case 'r':
|
86
|
+
case 'R':
|
87
|
+
break;
|
88
|
+
case 'c':
|
89
|
+
case 'C':
|
90
|
+
rb_warn("Numo::Linalg does not support column major.");
|
91
|
+
break;
|
92
|
+
}
|
93
|
+
|
94
|
+
return CblasRowMajor;
|
95
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
#ifndef NUMO_LINALG_ALT_UTIL_H
|
2
|
+
#define NUMO_LINALG_ALT_UTIL_H 1
|
3
|
+
|
4
|
+
#include <ruby.h>
|
5
|
+
|
6
|
+
#include <cblas.h>
|
7
|
+
#include <lapacke.h>
|
8
|
+
|
9
|
+
lapack_int get_itype(VALUE val);
|
10
|
+
char get_jobz(VALUE val);
|
11
|
+
char get_range(VALUE val);
|
12
|
+
char get_uplo(VALUE val);
|
13
|
+
int get_matrix_layout(VALUE val);
|
14
|
+
enum CBLAS_TRANSPOSE get_cblas_trans(VALUE val);
|
15
|
+
enum CBLAS_ORDER get_cblas_order(VALUE val);
|
16
|
+
|
17
|
+
#endif // NUMO_LINALG_ALT_UTIL_H
|