nmatrix 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/nmatrix/data/complex.h +20 -55
- data/ext/nmatrix/data/data.cpp +11 -44
- data/ext/nmatrix/data/data.h +174 -311
- data/ext/nmatrix/data/meta.h +1 -7
- data/ext/nmatrix/data/ruby_object.h +3 -85
- data/ext/nmatrix/extconf.rb +2 -73
- data/ext/nmatrix/math.cpp +170 -813
- data/ext/nmatrix/math/asum.h +2 -25
- data/ext/nmatrix/math/{inc.h → cblas_enums.h} +11 -22
- data/ext/nmatrix/math/cblas_templates_core.h +507 -0
- data/ext/nmatrix/math/gemm.h +2 -32
- data/ext/nmatrix/math/gemv.h +1 -35
- data/ext/nmatrix/math/getrf.h +21 -6
- data/ext/nmatrix/math/getrs.h +0 -8
- data/ext/nmatrix/math/imax.h +0 -22
- data/ext/nmatrix/math/long_dtype.h +0 -3
- data/ext/nmatrix/math/math.h +11 -337
- data/ext/nmatrix/math/nrm2.h +2 -23
- data/ext/nmatrix/math/rot.h +1 -25
- data/ext/nmatrix/math/rotg.h +4 -13
- data/ext/nmatrix/math/scal.h +0 -22
- data/ext/nmatrix/math/trsm.h +0 -55
- data/ext/nmatrix/math/util.h +148 -0
- data/ext/nmatrix/nmatrix.cpp +0 -14
- data/ext/nmatrix/nmatrix.h +92 -84
- data/ext/nmatrix/ruby_constants.cpp +0 -2
- data/ext/nmatrix/ruby_constants.h +0 -2
- data/ext/nmatrix/ruby_nmatrix.c +86 -45
- data/ext/nmatrix/storage/dense/dense.cpp +1 -7
- data/ext/nmatrix/storage/storage.h +0 -1
- data/ext/nmatrix/ttable_helper.rb +0 -6
- data/ext/nmatrix/util/io.cpp +1 -1
- data/lib/nmatrix.rb +1 -19
- data/lib/nmatrix/blas.rb +33 -11
- data/lib/nmatrix/io/market.rb +3 -3
- data/lib/nmatrix/lapack_core.rb +181 -0
- data/lib/nmatrix/lapack_plugin.rb +44 -0
- data/lib/nmatrix/math.rb +382 -131
- data/lib/nmatrix/monkeys.rb +2 -3
- data/lib/nmatrix/nmatrix.rb +166 -13
- data/lib/nmatrix/shortcuts.rb +72 -7
- data/lib/nmatrix/version.rb +2 -2
- data/spec/00_nmatrix_spec.rb +154 -5
- data/spec/02_slice_spec.rb +2 -6
- data/spec/03_nmatrix_monkeys_spec.rb +7 -1
- data/spec/blas_spec.rb +60 -33
- data/spec/homogeneous_spec.rb +10 -10
- data/spec/lapack_core_spec.rb +482 -0
- data/spec/math_spec.rb +436 -52
- data/spec/shortcuts_spec.rb +28 -4
- data/spec/spec_helper.rb +14 -2
- data/spec/utm5940.mtx +83844 -0
- metadata +49 -76
- data/.gitignore +0 -27
- data/.rspec +0 -2
- data/.travis.yml +0 -15
- data/CONTRIBUTING.md +0 -82
- data/Gemfile +0 -2
- data/History.txt +0 -677
- data/LICENSE.txt +0 -23
- data/Manifest.txt +0 -92
- data/README.rdoc +0 -150
- data/Rakefile +0 -216
- data/ext/nmatrix/data/rational.h +0 -440
- data/ext/nmatrix/math/geev.h +0 -82
- data/ext/nmatrix/math/ger.h +0 -96
- data/ext/nmatrix/math/gesdd.h +0 -80
- data/ext/nmatrix/math/gesvd.h +0 -78
- data/ext/nmatrix/math/getf2.h +0 -86
- data/ext/nmatrix/math/getri.h +0 -108
- data/ext/nmatrix/math/potrs.h +0 -129
- data/ext/nmatrix/math/swap.h +0 -52
- data/lib/nmatrix/lapack.rb +0 -240
- data/nmatrix.gemspec +0 -55
- data/scripts/mac-brew-gcc.sh +0 -50
- data/scripts/mac-mavericks-brew-gcc.sh +0 -22
- data/spec/lapack_spec.rb +0 -459
data/ext/nmatrix/math/ger.h
DELETED
@@ -1,96 +0,0 @@
|
|
1
|
-
/////////////////////////////////////////////////////////////////////
|
2
|
-
// = NMatrix
|
3
|
-
//
|
4
|
-
// A linear algebra library for scientific computation in Ruby.
|
5
|
-
// NMatrix is part of SciRuby.
|
6
|
-
//
|
7
|
-
// NMatrix was originally inspired by and derived from NArray, by
|
8
|
-
// Masahiro Tanaka: http://narray.rubyforge.org
|
9
|
-
//
|
10
|
-
// == Copyright Information
|
11
|
-
//
|
12
|
-
// SciRuby is Copyright (c) 2010 - 2014, Ruby Science Foundation
|
13
|
-
// NMatrix is Copyright (c) 2012 - 2014, John Woods and the Ruby Science Foundation
|
14
|
-
//
|
15
|
-
// Please see LICENSE.txt for additional copyright notices.
|
16
|
-
//
|
17
|
-
// == Contributing
|
18
|
-
//
|
19
|
-
// By contributing source code to SciRuby, you agree to be bound by
|
20
|
-
// our Contributor Agreement:
|
21
|
-
//
|
22
|
-
// * https://github.com/SciRuby/sciruby/wiki/Contributor-Agreement
|
23
|
-
//
|
24
|
-
// == ger.h
|
25
|
-
//
|
26
|
-
// BLAS level-2 ger function in native C++.
|
27
|
-
//
|
28
|
-
|
29
|
-
#ifndef GER_H
|
30
|
-
#define GER_H
|
31
|
-
|
32
|
-
namespace nm { namespace math {
|
33
|
-
|
34
|
-
template <typename DType>
|
35
|
-
inline int ger(int m, int n, DType alpha, DType* x, int incx, DType* y, int incy, DType* a, int lda) {
|
36
|
-
|
37
|
-
// FIXME: Call BLAS ger if available
|
38
|
-
|
39
|
-
if (m < 0) {
|
40
|
-
return 1;
|
41
|
-
} else if (n < 0) {
|
42
|
-
return 2;
|
43
|
-
} else if (incx == 0) {
|
44
|
-
return 5;
|
45
|
-
} else if (incy == 0) {
|
46
|
-
return 7;
|
47
|
-
} else if (lda < std::max(1,m)) {
|
48
|
-
return 9;
|
49
|
-
}
|
50
|
-
|
51
|
-
if (m == 0 || n == 0 || alpha == 0) return 0; /* Quick return if possible. */
|
52
|
-
|
53
|
-
/* Start the operations. In this version the elements of A are */
|
54
|
-
/* accessed sequentially with one pass through A. */
|
55
|
-
|
56
|
-
// FIXME: These have been unrolled in a way that the compiler can handle. Collapse into a single case, or optimize
|
57
|
-
// FIXME: in a more modern way.
|
58
|
-
|
59
|
-
int jy = incy > 0 ? 0 : -(n-1) * incy;
|
60
|
-
|
61
|
-
if (incx == 1) {
|
62
|
-
|
63
|
-
for (size_t j = 0; j < n; ++j, jy += incy) {
|
64
|
-
if (y[jy] != 0) {
|
65
|
-
DType temp = alpha * y[jy];
|
66
|
-
for (size_t i = 0; i < m; ++i) {
|
67
|
-
a[i + j * lda] += x[i] * temp;
|
68
|
-
}
|
69
|
-
}
|
70
|
-
}
|
71
|
-
|
72
|
-
} else {
|
73
|
-
|
74
|
-
int kx = incx > 0 ? 0 : -(m-1) * incx;
|
75
|
-
|
76
|
-
for (size_t j = 0; j < n; ++j, jy += incy) {
|
77
|
-
if (y[jy] != 0) {
|
78
|
-
DType temp = alpha * y[jy];
|
79
|
-
|
80
|
-
for (size_t i = 0, ix = kx; i < m; ++i, ix += incx) {
|
81
|
-
a[i + j * lda] += x[ix] * temp;
|
82
|
-
}
|
83
|
-
}
|
84
|
-
}
|
85
|
-
|
86
|
-
}
|
87
|
-
|
88
|
-
return 0;
|
89
|
-
|
90
|
-
/* End of DGER . */
|
91
|
-
|
92
|
-
} /* dger_ */
|
93
|
-
|
94
|
-
}} // end nm::math
|
95
|
-
|
96
|
-
#endif // GER_H
|
data/ext/nmatrix/math/gesdd.h
DELETED
@@ -1,80 +0,0 @@
|
|
1
|
-
/////////////////////////////////////////////////////////////////////
|
2
|
-
// = NMatrix
|
3
|
-
//
|
4
|
-
// A linear algebra library for scientific computation in Ruby.
|
5
|
-
// NMatrix is part of SciRuby.
|
6
|
-
//
|
7
|
-
// NMatrix was originally inspired by and derived from NArray, by
|
8
|
-
// Masahiro Tanaka: http://narray.rubyforge.org
|
9
|
-
//
|
10
|
-
// == Copyright Information
|
11
|
-
//
|
12
|
-
// SciRuby is Copyright (c) 2010 - 2014, Ruby Science Foundation
|
13
|
-
// NMatrix is Copyright (c) 2012 - 2014, John Woods and the Ruby Science Foundation
|
14
|
-
//
|
15
|
-
// Please see LICENSE.txt for additional copyright notices.
|
16
|
-
//
|
17
|
-
// == Contributing
|
18
|
-
//
|
19
|
-
// By contributing source code to SciRuby, you agree to be bound by
|
20
|
-
// our Contributor Agreement:
|
21
|
-
//
|
22
|
-
// * https://github.com/SciRuby/sciruby/wiki/Contributor-Agreement
|
23
|
-
//
|
24
|
-
// == gesdd.h
|
25
|
-
//
|
26
|
-
// Header file for interface with LAPACK's xGESDD functions.
|
27
|
-
//
|
28
|
-
|
29
|
-
#ifndef GESDD_H
|
30
|
-
# define GESDD_H
|
31
|
-
|
32
|
-
extern "C" {
|
33
|
-
|
34
|
-
void sgesdd_(char*, int*, int*, float*, int*, float*, float*, int*, float*, int*, float*, int*, int*, int*);
|
35
|
-
void dgesdd_(char*, int*, int*, double*, int*, double*, double*, int*, double*, int*, double*, int*, int*, int*);
|
36
|
-
void cgesdd_(char*, int*, int*, nm::Complex64*, int*, nm::Complex64*, nm::Complex64*, int*, nm::Complex64*, int*, nm::Complex64*, int*, float*, int*, int*);
|
37
|
-
void zgesdd_(char*, int*, int*, nm::Complex128*, int*, nm::Complex128*, nm::Complex128*, int*, nm::Complex128*, int*, nm::Complex128*, int*, double*, int*, int*);
|
38
|
-
}
|
39
|
-
|
40
|
-
namespace nm {
|
41
|
-
namespace math {
|
42
|
-
|
43
|
-
template <typename DType, typename CType>
|
44
|
-
inline int gesdd(char jobz, int m, int n, DType* a, int lda, DType* s, DType* u, int ldu, DType* vt, int ldvt, DType* work, int lwork, int* iwork, CType* rwork) {
|
45
|
-
rb_raise(rb_eNotImpError, "not yet implemented for non-BLAS dtypes");
|
46
|
-
return -1;
|
47
|
-
}
|
48
|
-
|
49
|
-
template <>
|
50
|
-
inline int gesdd(char jobz, int m, int n, float* a, int lda, float* s, float* u, int ldu, float* vt, int ldvt, float* work, int lwork, int* iwork, float* rwork) {
|
51
|
-
int info;
|
52
|
-
sgesdd_(&jobz, &m, &n, a, &lda, s, u, &ldu, vt, &ldvt, work, &lwork, iwork, &info);
|
53
|
-
return info;
|
54
|
-
}
|
55
|
-
|
56
|
-
template <>
|
57
|
-
inline int gesdd(char jobz, int m, int n, double* a, int lda, double* s, double* u, int ldu, double* vt, int ldvt, double* work, int lwork, int* iwork, double* rwork) {
|
58
|
-
int info;
|
59
|
-
dgesdd_(&jobz, &m, &n, a, &lda, s, u, &ldu, vt, &ldvt, work, &lwork, iwork, &info);
|
60
|
-
return info;
|
61
|
-
}
|
62
|
-
|
63
|
-
template <>
|
64
|
-
inline int gesdd(char jobz, int m, int n, nm::Complex64* a, int lda, nm::Complex64* s, nm::Complex64* u, int ldu, nm::Complex64* vt, int ldvt, nm::Complex64* work, int lwork, int* iwork, float* rwork) {
|
65
|
-
int info;
|
66
|
-
cgesdd_(&jobz, &m, &n, a, &lda, s, u, &ldu, vt, &ldvt, work, &lwork, rwork, iwork, &info);
|
67
|
-
return info;
|
68
|
-
}
|
69
|
-
|
70
|
-
template <>
|
71
|
-
inline int gesdd(char jobz, int m, int n, nm::Complex128* a, int lda, nm::Complex128* s, nm::Complex128* u, int ldu, nm::Complex128* vt, int ldvt, nm::Complex128* work, int lwork, int* iwork, double* rwork) {
|
72
|
-
int info;
|
73
|
-
zgesdd_(&jobz, &m, &n, a, &lda, s, u, &ldu, vt, &ldvt, work, &lwork, rwork, iwork, &info);
|
74
|
-
return info;
|
75
|
-
}
|
76
|
-
|
77
|
-
} // end of namespace math
|
78
|
-
} // end of namespace nm
|
79
|
-
|
80
|
-
#endif // GESDD_H
|
data/ext/nmatrix/math/gesvd.h
DELETED
@@ -1,78 +0,0 @@
|
|
1
|
-
/////////////////////////////////////////////////////////////////////
|
2
|
-
// = NMatrix
|
3
|
-
//
|
4
|
-
// A linear algebra library for scientific computation in Ruby.
|
5
|
-
// NMatrix is part of SciRuby.
|
6
|
-
//
|
7
|
-
// NMatrix was originally inspired by and derived from NArray, by
|
8
|
-
// Masahiro Tanaka: http://narray.rubyforge.org
|
9
|
-
//
|
10
|
-
// == Copyright Information
|
11
|
-
//
|
12
|
-
// SciRuby is Copyright (c) 2010 - 2014, Ruby Science Foundation
|
13
|
-
// NMatrix is Copyright (c) 2012 - 2014, John Woods and the Ruby Science Foundation
|
14
|
-
//
|
15
|
-
// Please see LICENSE.txt for additional copyright notices.
|
16
|
-
//
|
17
|
-
// == Contributing
|
18
|
-
//
|
19
|
-
// By contributing source code to SciRuby, you agree to be bound by
|
20
|
-
// our Contributor Agreement:
|
21
|
-
//
|
22
|
-
// * https://github.com/SciRuby/sciruby/wiki/Contributor-Agreement
|
23
|
-
//
|
24
|
-
// == gesvd.h
|
25
|
-
//
|
26
|
-
// Header file for interface with LAPACK's xGESVD functions.
|
27
|
-
//
|
28
|
-
|
29
|
-
#ifndef GESVD_H
|
30
|
-
# define GESVD_H
|
31
|
-
|
32
|
-
extern "C" {
|
33
|
-
void sgesvd_(char*, char*, int*, int*, float*, int*, float*, float*, int*, float*, int*, float*, int*, int*);
|
34
|
-
void dgesvd_(char*, char*, int*, int*, double*, int*, double*, double*, int*, double*, int*, double*, int*, int*);
|
35
|
-
void cgesvd_(char*, char*, int*, int*, nm::Complex64*, int*, nm::Complex64*, nm::Complex64*, int*, nm::Complex64*, int*, nm::Complex64*, int*, float*, int*);
|
36
|
-
void zgesvd_(char*, char*, int*, int*, nm::Complex128*, int*, nm::Complex128*, nm::Complex128*, int*, nm::Complex128*, int*, nm::Complex128*, int*, double*, int*);
|
37
|
-
}
|
38
|
-
|
39
|
-
namespace nm {
|
40
|
-
namespace math {
|
41
|
-
|
42
|
-
template <typename DType, typename CType>
|
43
|
-
inline int gesvd(char jobu, char jobvt, int m, int n, DType* a, int lda, DType* s, DType* u, int ldu, DType* vt, int ldvt, DType* work, int lwork, CType* rwork) {
|
44
|
-
rb_raise(rb_eNotImpError, "not yet implemented for non-BLAS dtypes");
|
45
|
-
return -1;
|
46
|
-
}
|
47
|
-
|
48
|
-
template <>
|
49
|
-
inline int gesvd(char jobu, char jobvt, int m, int n, float* a, int lda, float* s, float* u, int ldu, float* vt, int ldvt, float* work, int lwork, float* rwork) {
|
50
|
-
int info;
|
51
|
-
sgesvd_(&jobu, &jobvt, &m, &n, a, &lda, s, u, &ldu, vt, &ldvt, work, &lwork, &info);
|
52
|
-
return info;
|
53
|
-
}
|
54
|
-
|
55
|
-
template <>
|
56
|
-
inline int gesvd(char jobu, char jobvt, int m, int n, double* a, int lda, double* s, double* u, int ldu, double* vt, int ldvt, double* work, int lwork, double* rwork) {
|
57
|
-
int info;
|
58
|
-
dgesvd_(&jobu, &jobvt, &m, &n, a, &lda, s, u, &ldu, vt, &ldvt, work, &lwork, &info);
|
59
|
-
return info;
|
60
|
-
}
|
61
|
-
|
62
|
-
template <>
|
63
|
-
inline int gesvd(char jobu, char jobvt, int m, int n, nm::Complex64* a, int lda, nm::Complex64* s, nm::Complex64* u, int ldu, nm::Complex64* vt, int ldvt, nm::Complex64* work, int lwork, float* rwork) {
|
64
|
-
int info;
|
65
|
-
cgesvd_(&jobu, &jobvt, &m, &n, a, &lda, s, u, &ldu, vt, &ldvt, work, &lwork, rwork, &info);
|
66
|
-
return info;
|
67
|
-
}
|
68
|
-
|
69
|
-
template <>
|
70
|
-
inline int gesvd(char jobu, char jobvt, int m, int n, nm::Complex128* a, int lda, nm::Complex128* s, nm::Complex128* u, int ldu, nm::Complex128* vt, int ldvt, nm::Complex128* work, int lwork, double* rwork) {
|
71
|
-
int info;
|
72
|
-
zgesvd_(&jobu, &jobvt, &m, &n, a, &lda, s, u, &ldu, vt, &ldvt, work, &lwork, rwork, &info);
|
73
|
-
return info;
|
74
|
-
}
|
75
|
-
|
76
|
-
} // end of namespace math
|
77
|
-
} // end of namespace nm
|
78
|
-
#endif // GESVD_H
|
data/ext/nmatrix/math/getf2.h
DELETED
@@ -1,86 +0,0 @@
|
|
1
|
-
/////////////////////////////////////////////////////////////////////
|
2
|
-
// = NMatrix
|
3
|
-
//
|
4
|
-
// A linear algebra library for scientific computation in Ruby.
|
5
|
-
// NMatrix is part of SciRuby.
|
6
|
-
//
|
7
|
-
// NMatrix was originally inspired by and derived from NArray, by
|
8
|
-
// Masahiro Tanaka: http://narray.rubyforge.org
|
9
|
-
//
|
10
|
-
// == Copyright Information
|
11
|
-
//
|
12
|
-
// SciRuby is Copyright (c) 2010 - 2014, Ruby Science Foundation
|
13
|
-
// NMatrix is Copyright (c) 2012 - 2014, John Woods and the Ruby Science Foundation
|
14
|
-
//
|
15
|
-
// Please see LICENSE.txt for additional copyright notices.
|
16
|
-
//
|
17
|
-
// == Contributing
|
18
|
-
//
|
19
|
-
// By contributing source code to SciRuby, you agree to be bound by
|
20
|
-
// our Contributor Agreement:
|
21
|
-
//
|
22
|
-
// * https://github.com/SciRuby/sciruby/wiki/Contributor-Agreement
|
23
|
-
//
|
24
|
-
// == getf2.h
|
25
|
-
//
|
26
|
-
// LAPACK getf2 function in native C++.
|
27
|
-
//
|
28
|
-
|
29
|
-
#ifndef GETF2_H
|
30
|
-
#define GETF2_H
|
31
|
-
|
32
|
-
namespace nm { namespace math {
|
33
|
-
|
34
|
-
template <typename DType>
|
35
|
-
inline int getf2(const int m, const int n, DType* a, const int lda, int *ipiv) {
|
36
|
-
|
37
|
-
/* Function Body */
|
38
|
-
if (m < 0) return -1; // error
|
39
|
-
else if (n < 0) return -2; // error
|
40
|
-
else if (lda < std::max(1,m)) return -4; // error
|
41
|
-
|
42
|
-
|
43
|
-
if (m == 0 || n == 0) return 0; /* Quick return if possible */
|
44
|
-
|
45
|
-
for (size_t j = 0; j < std::min(m,n); ++j) { // changed
|
46
|
-
|
47
|
-
/* Find pivot and test for singularity. */
|
48
|
-
|
49
|
-
int jp = j - 1 + imax<DType>(m-j+1, &a[j + j * lda], 1);
|
50
|
-
|
51
|
-
ipiv[j] = jp;
|
52
|
-
|
53
|
-
|
54
|
-
if (a[jp + j*lda] != 0) {
|
55
|
-
|
56
|
-
/* Apply the interchange to columns 1:N. */
|
57
|
-
// (Don't swap two columns that are the same.)
|
58
|
-
if (jp != j) swap<DType>(n, &a[j], lda, &a[jp], lda);
|
59
|
-
|
60
|
-
/* Compute elements J+1:M of J-th column. */
|
61
|
-
|
62
|
-
if (j < m-1) {
|
63
|
-
if (std::abs(a[j+j*lda]) >= std::numeric_limits<DType>::min()) {
|
64
|
-
scal<DType>(m-j, 1.0 / a[j+j*lda], &a[j+1+j*lda], 1);
|
65
|
-
} else {
|
66
|
-
for (size_t i = 0; i < m-j; ++i) { // changed
|
67
|
-
a[j+i+j*lda] /= a[j+j*lda];
|
68
|
-
}
|
69
|
-
}
|
70
|
-
}
|
71
|
-
|
72
|
-
} else { // singular matrix
|
73
|
-
return j; // U(j,j) is exactly zero, div by zero if answer is used to solve a system of equations.
|
74
|
-
}
|
75
|
-
|
76
|
-
if (j < std::min(m,n)-1) /* Update trailing submatrix. */
|
77
|
-
ger<DType>(m-j, n-j, -1.0, &a[j+1+j*lda], 1, &a[j+(j+1)*lda], lda, &a[j+1+(j+1)*lda], lda);
|
78
|
-
|
79
|
-
}
|
80
|
-
return 0;
|
81
|
-
} /* dgetf2_ */
|
82
|
-
|
83
|
-
|
84
|
-
}} // end of namespace nm::math
|
85
|
-
|
86
|
-
#endif // GETF2
|
data/ext/nmatrix/math/getri.h
DELETED
@@ -1,108 +0,0 @@
|
|
1
|
-
/////////////////////////////////////////////////////////////////////
|
2
|
-
// = NMatrix
|
3
|
-
//
|
4
|
-
// A linear algebra library for scientific computation in Ruby.
|
5
|
-
// NMatrix is part of SciRuby.
|
6
|
-
//
|
7
|
-
// NMatrix was originally inspired by and derived from NArray, by
|
8
|
-
// Masahiro Tanaka: http://narray.rubyforge.org
|
9
|
-
//
|
10
|
-
// == Copyright Information
|
11
|
-
//
|
12
|
-
// SciRuby is Copyright (c) 2010 - 2014, Ruby Science Foundation
|
13
|
-
// NMatrix is Copyright (c) 2012 - 2014, John Woods and the Ruby Science Foundation
|
14
|
-
//
|
15
|
-
// Please see LICENSE.txt for additional copyright notices.
|
16
|
-
//
|
17
|
-
// == Contributing
|
18
|
-
//
|
19
|
-
// By contributing source code to SciRuby, you agree to be bound by
|
20
|
-
// our Contributor Agreement:
|
21
|
-
//
|
22
|
-
// * https://github.com/SciRuby/sciruby/wiki/Contributor-Agreement
|
23
|
-
//
|
24
|
-
// == getri.h
|
25
|
-
//
|
26
|
-
// getri function in native C++.
|
27
|
-
//
|
28
|
-
|
29
|
-
/*
|
30
|
-
* Automatically Tuned Linear Algebra Software v3.8.4
|
31
|
-
* (C) Copyright 1999 R. Clint Whaley
|
32
|
-
*
|
33
|
-
* Redistribution and use in source and binary forms, with or without
|
34
|
-
* modification, are permitted provided that the following conditions
|
35
|
-
* are met:
|
36
|
-
* 1. Redistributions of source code must retain the above copyright
|
37
|
-
* notice, this list of conditions and the following disclaimer.
|
38
|
-
* 2. Redistributions in binary form must reproduce the above copyright
|
39
|
-
* notice, this list of conditions, and the following disclaimer in the
|
40
|
-
* documentation and/or other materials provided with the distribution.
|
41
|
-
* 3. The name of the ATLAS group or the names of its contributers may
|
42
|
-
* not be used to endorse or promote products derived from this
|
43
|
-
* software without specific written permission.
|
44
|
-
*
|
45
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
46
|
-
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
47
|
-
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
48
|
-
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ATLAS GROUP OR ITS CONTRIBUTORS
|
49
|
-
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
50
|
-
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
51
|
-
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
52
|
-
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
53
|
-
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
54
|
-
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
55
|
-
* POSSIBILITY OF SUCH DAMAGE.
|
56
|
-
*
|
57
|
-
*/
|
58
|
-
|
59
|
-
#ifndef GETRI_H
|
60
|
-
#define GETRI_H
|
61
|
-
|
62
|
-
|
63
|
-
namespace nm { namespace math {
|
64
|
-
|
65
|
-
template <typename DType>
|
66
|
-
inline int getri(const enum CBLAS_ORDER order, const int n, DType* a, const int lda, const int* ipiv) {
|
67
|
-
rb_raise(rb_eNotImpError, "getri not yet implemented for non-BLAS dtypes");
|
68
|
-
return 0;
|
69
|
-
}
|
70
|
-
|
71
|
-
#if defined (HAVE_CLAPACK_H) || defined (HAVE_ATLAS_CLAPACK_H)
|
72
|
-
template <>
|
73
|
-
inline int getri(const enum CBLAS_ORDER order, const int n, float* a, const int lda, const int* ipiv) {
|
74
|
-
return clapack_sgetri(order, n, a, lda, ipiv);
|
75
|
-
}
|
76
|
-
|
77
|
-
template <>
|
78
|
-
inline int getri(const enum CBLAS_ORDER order, const int n, double* a, const int lda, const int* ipiv) {
|
79
|
-
return clapack_dgetri(order, n, a, lda, ipiv);
|
80
|
-
}
|
81
|
-
|
82
|
-
template <>
|
83
|
-
inline int getri(const enum CBLAS_ORDER order, const int n, Complex64* a, const int lda, const int* ipiv) {
|
84
|
-
return clapack_cgetri(order, n, reinterpret_cast<void*>(a), lda, ipiv);
|
85
|
-
}
|
86
|
-
|
87
|
-
template <>
|
88
|
-
inline int getri(const enum CBLAS_ORDER order, const int n, Complex128* a, const int lda, const int* ipiv) {
|
89
|
-
return clapack_zgetri(order, n, reinterpret_cast<void*>(a), lda, ipiv);
|
90
|
-
}
|
91
|
-
#endif
|
92
|
-
|
93
|
-
/*
|
94
|
-
* Function signature conversion for calling LAPACK's getri functions as directly as possible.
|
95
|
-
*
|
96
|
-
* For documentation: http://www.netlib.org/lapack/double/dgetri.f
|
97
|
-
*
|
98
|
-
* This function should normally go in math.cpp, but we need it to be available to nmatrix.cpp.
|
99
|
-
*/
|
100
|
-
template <typename DType>
|
101
|
-
inline int clapack_getri(const enum CBLAS_ORDER order, const int n, void* a, const int lda, const int* ipiv) {
|
102
|
-
return getri<DType>(order, n, reinterpret_cast<DType*>(a), lda, ipiv);
|
103
|
-
}
|
104
|
-
|
105
|
-
|
106
|
-
} } // end nm::math
|
107
|
-
|
108
|
-
#endif // GETRI_H
|