nmatrix-lapacke 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/ext/nmatrix/data/complex.h +364 -0
- data/ext/nmatrix/data/data.h +638 -0
- data/ext/nmatrix/data/meta.h +64 -0
- data/ext/nmatrix/data/ruby_object.h +389 -0
- data/ext/nmatrix/math/asum.h +120 -0
- data/ext/nmatrix/math/cblas_enums.h +36 -0
- data/ext/nmatrix/math/cblas_templates_core.h +507 -0
- data/ext/nmatrix/math/gemm.h +241 -0
- data/ext/nmatrix/math/gemv.h +178 -0
- data/ext/nmatrix/math/getrf.h +255 -0
- data/ext/nmatrix/math/getrs.h +121 -0
- data/ext/nmatrix/math/imax.h +79 -0
- data/ext/nmatrix/math/laswp.h +165 -0
- data/ext/nmatrix/math/long_dtype.h +49 -0
- data/ext/nmatrix/math/math.h +744 -0
- data/ext/nmatrix/math/nrm2.h +160 -0
- data/ext/nmatrix/math/rot.h +117 -0
- data/ext/nmatrix/math/rotg.h +106 -0
- data/ext/nmatrix/math/scal.h +71 -0
- data/ext/nmatrix/math/trsm.h +332 -0
- data/ext/nmatrix/math/util.h +148 -0
- data/ext/nmatrix/nm_memory.h +60 -0
- data/ext/nmatrix/nmatrix.h +408 -0
- data/ext/nmatrix/ruby_constants.h +106 -0
- data/ext/nmatrix/storage/common.h +176 -0
- data/ext/nmatrix/storage/dense/dense.h +128 -0
- data/ext/nmatrix/storage/list/list.h +137 -0
- data/ext/nmatrix/storage/storage.h +98 -0
- data/ext/nmatrix/storage/yale/class.h +1139 -0
- data/ext/nmatrix/storage/yale/iterators/base.h +142 -0
- data/ext/nmatrix/storage/yale/iterators/iterator.h +130 -0
- data/ext/nmatrix/storage/yale/iterators/row.h +449 -0
- data/ext/nmatrix/storage/yale/iterators/row_stored.h +139 -0
- data/ext/nmatrix/storage/yale/iterators/row_stored_nd.h +168 -0
- data/ext/nmatrix/storage/yale/iterators/stored_diagonal.h +123 -0
- data/ext/nmatrix/storage/yale/math/transpose.h +110 -0
- data/ext/nmatrix/storage/yale/yale.h +202 -0
- data/ext/nmatrix/types.h +54 -0
- data/ext/nmatrix/util/io.h +115 -0
- data/ext/nmatrix/util/sl_list.h +143 -0
- data/ext/nmatrix/util/util.h +78 -0
- data/ext/nmatrix_lapacke/extconf.rb +200 -0
- data/ext/nmatrix_lapacke/lapacke.cpp +100 -0
- data/ext/nmatrix_lapacke/lapacke/include/lapacke.h +16445 -0
- data/ext/nmatrix_lapacke/lapacke/include/lapacke_config.h +119 -0
- data/ext/nmatrix_lapacke/lapacke/include/lapacke_mangling.h +17 -0
- data/ext/nmatrix_lapacke/lapacke/include/lapacke_mangling_with_flags.h +17 -0
- data/ext/nmatrix_lapacke/lapacke/include/lapacke_utils.h +579 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_cgeev.c +89 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_cgeev_work.c +141 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_cgesdd.c +106 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_cgesdd_work.c +158 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_cgesvd.c +94 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_cgesvd_work.c +149 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_cgetrf.c +51 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_cgetrf_work.c +83 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_cgetri.c +77 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_cgetri_work.c +89 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_cgetrs.c +56 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_cgetrs_work.c +102 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_cpotrf.c +50 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_cpotrf_work.c +82 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_cpotri.c +50 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_cpotri_work.c +82 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_cpotrs.c +55 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_cpotrs_work.c +101 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_dgeev.c +78 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_dgeev_work.c +136 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_dgesdd.c +88 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_dgesdd_work.c +153 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_dgesvd.c +83 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_dgesvd_work.c +144 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_dgetrf.c +50 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_dgetrf_work.c +81 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_dgetri.c +75 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_dgetri_work.c +87 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_dgetrs.c +55 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_dgetrs_work.c +99 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_dpotrf.c +50 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_dpotrf_work.c +81 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_dpotri.c +50 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_dpotri_work.c +81 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_dpotrs.c +54 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_dpotrs_work.c +97 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_sgeev.c +78 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_sgeev_work.c +134 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_sgesdd.c +88 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_sgesdd_work.c +152 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_sgesvd.c +83 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_sgesvd_work.c +143 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_sgetrf.c +50 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_sgetrf_work.c +81 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_sgetri.c +75 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_sgetri_work.c +87 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_sgetrs.c +55 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_sgetrs_work.c +99 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_spotrf.c +50 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_spotrf_work.c +81 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_spotri.c +50 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_spotri_work.c +81 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_spotrs.c +54 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_spotrs_work.c +97 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_zgeev.c +89 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_zgeev_work.c +141 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_zgesdd.c +106 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_zgesdd_work.c +158 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_zgesvd.c +94 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_zgesvd_work.c +149 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_zgetrf.c +51 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_zgetrf_work.c +83 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_zgetri.c +77 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_zgetri_work.c +89 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_zgetrs.c +56 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_zgetrs_work.c +102 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_zpotrf.c +50 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_zpotrf_work.c +82 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_zpotri.c +50 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_zpotri_work.c +82 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_zpotrs.c +55 -0
- data/ext/nmatrix_lapacke/lapacke/src/lapacke_zpotrs_work.c +101 -0
- data/ext/nmatrix_lapacke/lapacke/utils/lapacke_cge_nancheck.c +62 -0
- data/ext/nmatrix_lapacke/lapacke/utils/lapacke_cge_trans.c +65 -0
- data/ext/nmatrix_lapacke/lapacke/utils/lapacke_cpo_nancheck.c +43 -0
- data/ext/nmatrix_lapacke/lapacke/utils/lapacke_cpo_trans.c +45 -0
- data/ext/nmatrix_lapacke/lapacke/utils/lapacke_ctr_nancheck.c +85 -0
- data/ext/nmatrix_lapacke/lapacke/utils/lapacke_ctr_trans.c +85 -0
- data/ext/nmatrix_lapacke/lapacke/utils/lapacke_dge_nancheck.c +62 -0
- data/ext/nmatrix_lapacke/lapacke/utils/lapacke_dge_trans.c +65 -0
- data/ext/nmatrix_lapacke/lapacke/utils/lapacke_dpo_nancheck.c +43 -0
- data/ext/nmatrix_lapacke/lapacke/utils/lapacke_dpo_trans.c +45 -0
- data/ext/nmatrix_lapacke/lapacke/utils/lapacke_dtr_nancheck.c +85 -0
- data/ext/nmatrix_lapacke/lapacke/utils/lapacke_dtr_trans.c +85 -0
- data/ext/nmatrix_lapacke/lapacke/utils/lapacke_lsame.c +41 -0
- data/ext/nmatrix_lapacke/lapacke/utils/lapacke_sge_nancheck.c +62 -0
- data/ext/nmatrix_lapacke/lapacke/utils/lapacke_sge_trans.c +65 -0
- data/ext/nmatrix_lapacke/lapacke/utils/lapacke_spo_nancheck.c +43 -0
- data/ext/nmatrix_lapacke/lapacke/utils/lapacke_spo_trans.c +45 -0
- data/ext/nmatrix_lapacke/lapacke/utils/lapacke_str_nancheck.c +85 -0
- data/ext/nmatrix_lapacke/lapacke/utils/lapacke_str_trans.c +85 -0
- data/ext/nmatrix_lapacke/lapacke/utils/lapacke_xerbla.c +46 -0
- data/ext/nmatrix_lapacke/lapacke/utils/lapacke_zge_nancheck.c +62 -0
- data/ext/nmatrix_lapacke/lapacke/utils/lapacke_zge_trans.c +65 -0
- data/ext/nmatrix_lapacke/lapacke/utils/lapacke_zpo_nancheck.c +43 -0
- data/ext/nmatrix_lapacke/lapacke/utils/lapacke_zpo_trans.c +45 -0
- data/ext/nmatrix_lapacke/lapacke/utils/lapacke_ztr_nancheck.c +85 -0
- data/ext/nmatrix_lapacke/lapacke/utils/lapacke_ztr_trans.c +85 -0
- data/ext/nmatrix_lapacke/lapacke_nmatrix.h +16 -0
- data/ext/nmatrix_lapacke/make_lapacke_cpp.rb +9 -0
- data/ext/nmatrix_lapacke/math_lapacke.cpp +967 -0
- data/ext/nmatrix_lapacke/math_lapacke/cblas_local.h +576 -0
- data/ext/nmatrix_lapacke/math_lapacke/cblas_templates_lapacke.h +51 -0
- data/ext/nmatrix_lapacke/math_lapacke/lapacke_templates.h +356 -0
- data/ext/nmatrix_lapacke/nmatrix_lapacke.cpp +42 -0
- data/lib/nmatrix/lapack_ext_common.rb +69 -0
- data/lib/nmatrix/lapacke.rb +213 -0
- data/spec/00_nmatrix_spec.rb +730 -0
- data/spec/01_enum_spec.rb +190 -0
- data/spec/02_slice_spec.rb +389 -0
- data/spec/03_nmatrix_monkeys_spec.rb +78 -0
- data/spec/2x2_dense_double.mat +0 -0
- data/spec/4x4_sparse.mat +0 -0
- data/spec/4x5_dense.mat +0 -0
- data/spec/blas_spec.rb +193 -0
- data/spec/elementwise_spec.rb +303 -0
- data/spec/homogeneous_spec.rb +99 -0
- data/spec/io/fortran_format_spec.rb +88 -0
- data/spec/io/harwell_boeing_spec.rb +98 -0
- data/spec/io/test.rua +9 -0
- data/spec/io_spec.rb +149 -0
- data/spec/lapack_core_spec.rb +482 -0
- data/spec/leakcheck.rb +16 -0
- data/spec/math_spec.rb +730 -0
- data/spec/nmatrix_yale_resize_test_associations.yaml +2802 -0
- data/spec/nmatrix_yale_spec.rb +286 -0
- data/spec/plugins/lapacke/lapacke_spec.rb +303 -0
- data/spec/rspec_monkeys.rb +56 -0
- data/spec/rspec_spec.rb +34 -0
- data/spec/shortcuts_spec.rb +310 -0
- data/spec/slice_set_spec.rb +157 -0
- data/spec/spec_helper.rb +140 -0
- data/spec/stat_spec.rb +203 -0
- data/spec/test.pcd +20 -0
- data/spec/utm5940.mtx +83844 -0
- metadata +262 -0
@@ -0,0 +1,51 @@
|
|
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
|
+
// == cblas_templaces_lapacke.h
|
25
|
+
//
|
26
|
+
// Define template functions for calling CBLAS functions in the
|
27
|
+
// nm::math::lapacke namespace.
|
28
|
+
//
|
29
|
+
|
30
|
+
#ifndef CBLAS_TEMPLATES_LAPACK_H
|
31
|
+
#define CBLAS_TEMPLATES_LAPACK_H
|
32
|
+
|
33
|
+
//includes so we have access to internal implementations
|
34
|
+
#include "math/rotg.h"
|
35
|
+
#include "math/rot.h"
|
36
|
+
#include "math/asum.h"
|
37
|
+
#include "math/nrm2.h"
|
38
|
+
#include "math/imax.h"
|
39
|
+
#include "math/scal.h"
|
40
|
+
#include "math/gemv.h"
|
41
|
+
#include "math/gemm.h"
|
42
|
+
#include "math/trsm.h"
|
43
|
+
|
44
|
+
namespace nm { namespace math { namespace lapacke {
|
45
|
+
|
46
|
+
//Add cblas templates in the correct namespace
|
47
|
+
#include "math/cblas_templates_core.h"
|
48
|
+
|
49
|
+
}}}
|
50
|
+
|
51
|
+
#endif
|
@@ -0,0 +1,356 @@
|
|
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
|
+
// == lapacke_templates.h
|
25
|
+
//
|
26
|
+
// Templated functions for calling LAPACKE functions directly.
|
27
|
+
//
|
28
|
+
|
29
|
+
#ifndef LAPACKE_TEMPLATES_H
|
30
|
+
#define LAPACKE_TEMPLATES_H
|
31
|
+
|
32
|
+
namespace nm { namespace math { namespace lapacke {
|
33
|
+
|
34
|
+
//getrf
|
35
|
+
template <typename DType>
|
36
|
+
inline int getrf(const enum CBLAS_ORDER order, const int m, const int n, DType* a, const int lda, int* ipiv) {
|
37
|
+
//We don't want to call the internal implementation since the the CLAPACK interface is slightly different than the LAPACKE.
|
38
|
+
rb_raise(rb_eNotImpError, "lapacke_getrf not implemented for non_BLAS dtypes. Try clapack_getrf instead.");
|
39
|
+
return 0;
|
40
|
+
}
|
41
|
+
|
42
|
+
template <>
|
43
|
+
inline int getrf(const enum CBLAS_ORDER order, const int m, const int n, float* a, const int lda, int* ipiv) {
|
44
|
+
return LAPACKE_sgetrf(order, m, n, a, lda, ipiv);
|
45
|
+
}
|
46
|
+
|
47
|
+
template <>
|
48
|
+
inline int getrf(const enum CBLAS_ORDER order, const int m, const int n, double* a, const int lda, int* ipiv) {
|
49
|
+
return LAPACKE_dgetrf(order, m, n, a, lda, ipiv);
|
50
|
+
}
|
51
|
+
|
52
|
+
template <>
|
53
|
+
inline int getrf(const enum CBLAS_ORDER order, const int m, const int n, Complex64* a, const int lda, int* ipiv) {
|
54
|
+
return LAPACKE_cgetrf(order, m, n, a, lda, ipiv);
|
55
|
+
}
|
56
|
+
|
57
|
+
template <>
|
58
|
+
inline int getrf(const enum CBLAS_ORDER order, const int m, const int n, Complex128* a, const int lda, int* ipiv) {
|
59
|
+
return LAPACKE_zgetrf(order, m, n, a, lda, ipiv);
|
60
|
+
}
|
61
|
+
|
62
|
+
template <typename DType>
|
63
|
+
inline int lapacke_getrf(const enum CBLAS_ORDER order, const int m, const int n, void* a, const int lda, int* ipiv) {
|
64
|
+
return getrf<DType>(order, m, n, static_cast<DType*>(a), lda, ipiv);
|
65
|
+
}
|
66
|
+
|
67
|
+
//getri
|
68
|
+
template <typename DType>
|
69
|
+
inline int getri(const enum CBLAS_ORDER order, const int n, DType* a, const int lda, const int* ipiv) {
|
70
|
+
rb_raise(rb_eNotImpError, "getri not yet implemented for non-BLAS dtypes");
|
71
|
+
return 0;
|
72
|
+
}
|
73
|
+
|
74
|
+
template <>
|
75
|
+
inline int getri(const enum CBLAS_ORDER order, const int n, float* a, const int lda, const int* ipiv) {
|
76
|
+
return LAPACKE_sgetri(order, n, a, lda, ipiv);
|
77
|
+
}
|
78
|
+
|
79
|
+
template <>
|
80
|
+
inline int getri(const enum CBLAS_ORDER order, const int n, double* a, const int lda, const int* ipiv) {
|
81
|
+
return LAPACKE_dgetri(order, n, a, lda, ipiv);
|
82
|
+
}
|
83
|
+
|
84
|
+
template <>
|
85
|
+
inline int getri(const enum CBLAS_ORDER order, const int n, Complex64* a, const int lda, const int* ipiv) {
|
86
|
+
return LAPACKE_cgetri(order, n, a, lda, ipiv);
|
87
|
+
}
|
88
|
+
|
89
|
+
template <>
|
90
|
+
inline int getri(const enum CBLAS_ORDER order, const int n, Complex128* a, const int lda, const int* ipiv) {
|
91
|
+
return LAPACKE_zgetri(order, n, a, lda, ipiv);
|
92
|
+
}
|
93
|
+
|
94
|
+
template <typename DType>
|
95
|
+
inline int lapacke_getri(const enum CBLAS_ORDER order, const int n, void* a, const int lda, const int* ipiv) {
|
96
|
+
return getri<DType>(order, n, static_cast<DType*>(a), lda, ipiv);
|
97
|
+
}
|
98
|
+
|
99
|
+
//getrs
|
100
|
+
template <typename DType>
|
101
|
+
inline int getrs(const enum CBLAS_ORDER Order, char Trans, const int N, const int NRHS, const DType* A,
|
102
|
+
const int lda, const int* ipiv, DType* B, const int ldb)
|
103
|
+
{
|
104
|
+
rb_raise(rb_eNotImpError, "lapacke_getrs not implemented for non_BLAS dtypes. Try clapack_getrs instead.");
|
105
|
+
return 0;
|
106
|
+
}
|
107
|
+
|
108
|
+
template <>
|
109
|
+
inline int getrs(const enum CBLAS_ORDER Order, char Trans, const int N, const int NRHS, const float* A,
|
110
|
+
const int lda, const int* ipiv, float* B, const int ldb)
|
111
|
+
{
|
112
|
+
return LAPACKE_sgetrs(Order, Trans, N, NRHS, A, lda, ipiv, B, ldb);
|
113
|
+
}
|
114
|
+
|
115
|
+
template <>
|
116
|
+
inline int getrs(const enum CBLAS_ORDER Order, char Trans, const int N, const int NRHS, const double* A,
|
117
|
+
const int lda, const int* ipiv, double* B, const int ldb)
|
118
|
+
{
|
119
|
+
return LAPACKE_dgetrs(Order, Trans, N, NRHS, A, lda, ipiv, B, ldb);
|
120
|
+
}
|
121
|
+
|
122
|
+
template <>
|
123
|
+
inline int getrs(const enum CBLAS_ORDER Order, char Trans, const int N, const int NRHS, const Complex64* A,
|
124
|
+
const int lda, const int* ipiv, Complex64* B, const int ldb)
|
125
|
+
{
|
126
|
+
return LAPACKE_cgetrs(Order, Trans, N, NRHS, A, lda, ipiv, B, ldb);
|
127
|
+
}
|
128
|
+
|
129
|
+
template <>
|
130
|
+
inline int getrs(const enum CBLAS_ORDER Order, char Trans, const int N, const int NRHS, const Complex128* A,
|
131
|
+
const int lda, const int* ipiv, Complex128* B, const int ldb)
|
132
|
+
{
|
133
|
+
return LAPACKE_zgetrs(Order, Trans, N, NRHS, A, lda, ipiv, B, ldb);
|
134
|
+
}
|
135
|
+
|
136
|
+
template <typename DType>
|
137
|
+
inline int lapacke_getrs(const enum CBLAS_ORDER order, char trans, const int n, const int nrhs,
|
138
|
+
const void* a, const int lda, const int* ipiv, void* b, const int ldb) {
|
139
|
+
return getrs<DType>(order, trans, n, nrhs, static_cast<const DType*>(a), lda, ipiv, static_cast<DType*>(b), ldb);
|
140
|
+
}
|
141
|
+
|
142
|
+
//potrf
|
143
|
+
template <typename DType>
|
144
|
+
inline int potrf(const enum CBLAS_ORDER order, char uplo, const int N, DType* A, const int lda) {
|
145
|
+
rb_raise(rb_eNotImpError, "not implemented for non-BLAS dtypes");
|
146
|
+
return 0;
|
147
|
+
}
|
148
|
+
|
149
|
+
template <>
|
150
|
+
inline int potrf(const enum CBLAS_ORDER order, char uplo, const int N, float* A, const int lda) {
|
151
|
+
return LAPACKE_spotrf(order, uplo, N, A, lda);
|
152
|
+
}
|
153
|
+
|
154
|
+
template <>
|
155
|
+
inline int potrf(const enum CBLAS_ORDER order, char uplo, const int N, double* A, const int lda) {
|
156
|
+
return LAPACKE_dpotrf(order, uplo, N, A, lda);
|
157
|
+
}
|
158
|
+
|
159
|
+
template <>
|
160
|
+
inline int potrf(const enum CBLAS_ORDER order, char uplo, const int N, Complex64* A, const int lda) {
|
161
|
+
return LAPACKE_cpotrf(order, uplo, N, A, lda);
|
162
|
+
}
|
163
|
+
|
164
|
+
template <>
|
165
|
+
inline int potrf(const enum CBLAS_ORDER order, char uplo, const int N, Complex128* A, const int lda) {
|
166
|
+
return LAPACKE_zpotrf(order, uplo, N, A, lda);
|
167
|
+
}
|
168
|
+
|
169
|
+
template <typename DType>
|
170
|
+
inline int lapacke_potrf(const enum CBLAS_ORDER order, char uplo, const int n, void* a, const int lda) {
|
171
|
+
return potrf<DType>(order, uplo, n, static_cast<DType*>(a), lda);
|
172
|
+
}
|
173
|
+
|
174
|
+
//potrs
|
175
|
+
template <typename DType>
|
176
|
+
inline int potrs(const enum CBLAS_ORDER Order, char Uplo, const int N, const int NRHS, const DType* A,
|
177
|
+
const int lda, DType* B, const int ldb)
|
178
|
+
{
|
179
|
+
rb_raise(rb_eNotImpError, "not implemented for non-BLAS dtypes");
|
180
|
+
return 0;
|
181
|
+
}
|
182
|
+
|
183
|
+
template <>
|
184
|
+
inline int potrs<float> (const enum CBLAS_ORDER Order, char Uplo, const int N, const int NRHS, const float* A,
|
185
|
+
const int lda, float* B, const int ldb)
|
186
|
+
{
|
187
|
+
return LAPACKE_spotrs(Order, Uplo, N, NRHS, A, lda, B, ldb);
|
188
|
+
}
|
189
|
+
|
190
|
+
template <>
|
191
|
+
inline int potrs<double>(const enum CBLAS_ORDER Order, char Uplo, const int N, const int NRHS, const double* A,
|
192
|
+
const int lda, double* B, const int ldb)
|
193
|
+
{
|
194
|
+
return LAPACKE_dpotrs(Order, Uplo, N, NRHS, A, lda, B, ldb);
|
195
|
+
}
|
196
|
+
|
197
|
+
template <>
|
198
|
+
inline int potrs<Complex64>(const enum CBLAS_ORDER Order, char Uplo, const int N, const int NRHS, const Complex64* A,
|
199
|
+
const int lda, Complex64* B, const int ldb)
|
200
|
+
{
|
201
|
+
return LAPACKE_cpotrs(Order, Uplo, N, NRHS, A, lda, B, ldb);
|
202
|
+
}
|
203
|
+
|
204
|
+
template <>
|
205
|
+
inline int potrs<Complex128>(const enum CBLAS_ORDER Order, char Uplo, const int N, const int NRHS, const Complex128* A,
|
206
|
+
const int lda, Complex128* B, const int ldb)
|
207
|
+
{
|
208
|
+
return LAPACKE_zpotrs(Order, Uplo, N, NRHS, A, lda, B, ldb);
|
209
|
+
}
|
210
|
+
|
211
|
+
template <typename DType>
|
212
|
+
inline int lapacke_potrs(const enum CBLAS_ORDER order, char uplo, const int n, const int nrhs,
|
213
|
+
const void* a, const int lda, void* b, const int ldb) {
|
214
|
+
return potrs<DType>(order, uplo, n, nrhs, static_cast<const DType*>(a), lda, static_cast<DType*>(b), ldb);
|
215
|
+
}
|
216
|
+
|
217
|
+
//potri
|
218
|
+
template <typename DType>
|
219
|
+
inline int potri(const enum CBLAS_ORDER order, char uplo, const int n, DType* a, const int lda) {
|
220
|
+
rb_raise(rb_eNotImpError, "potri not yet implemented for non-BLAS dtypes");
|
221
|
+
return 0;
|
222
|
+
}
|
223
|
+
|
224
|
+
template <>
|
225
|
+
inline int potri(const enum CBLAS_ORDER order, char uplo, const int n, float* a, const int lda) {
|
226
|
+
return LAPACKE_spotri(order, uplo, n, a, lda);
|
227
|
+
}
|
228
|
+
|
229
|
+
template <>
|
230
|
+
inline int potri(const enum CBLAS_ORDER order, char uplo, const int n, double* a, const int lda) {
|
231
|
+
return LAPACKE_dpotri(order, uplo, n, a, lda);
|
232
|
+
}
|
233
|
+
|
234
|
+
template <>
|
235
|
+
inline int potri(const enum CBLAS_ORDER order, char uplo, const int n, Complex64* a, const int lda) {
|
236
|
+
return LAPACKE_cpotri(order, uplo, n, a, lda);
|
237
|
+
}
|
238
|
+
|
239
|
+
template <>
|
240
|
+
inline int potri(const enum CBLAS_ORDER order, char uplo, const int n, Complex128* a, const int lda) {
|
241
|
+
return LAPACKE_zpotri(order, uplo, n, a, lda);
|
242
|
+
}
|
243
|
+
|
244
|
+
template <typename DType>
|
245
|
+
inline int lapacke_potri(const enum CBLAS_ORDER order, char uplo, const int n, void* a, const int lda) {
|
246
|
+
return potri<DType>(order, uplo, n, static_cast<DType*>(a), lda);
|
247
|
+
}
|
248
|
+
|
249
|
+
//gesvd
|
250
|
+
template <typename DType, typename CType>
|
251
|
+
inline int gesvd(int matrix_layout, char jobu, char jobvt, int m, int n, DType* a, int lda, CType* s, DType* u, int ldu, DType* vt, int ldvt, CType* superb) {
|
252
|
+
rb_raise(rb_eNotImpError, "gesvd not yet implemented for non-BLAS dtypes");
|
253
|
+
return 0;
|
254
|
+
}
|
255
|
+
|
256
|
+
template <>
|
257
|
+
inline int gesvd<float, float>(int matrix_layout, char jobu, char jobvt, int m, int n, float* a, int lda, float* s, float* u, int ldu, float* vt, int ldvt, float* superb) {
|
258
|
+
return LAPACKE_sgesvd(matrix_layout, jobu, jobvt, m, n, a, lda, s, u, ldu, vt, ldvt, superb);
|
259
|
+
}
|
260
|
+
|
261
|
+
template <>
|
262
|
+
inline int gesvd<double, double>(int matrix_layout, char jobu, char jobvt, int m, int n, double* a, int lda, double* s, double* u, int ldu, double* vt, int ldvt, double* superb) {
|
263
|
+
return LAPACKE_dgesvd(matrix_layout, jobu, jobvt, m, n, a, lda, s, u, ldu, vt, ldvt, superb);
|
264
|
+
}
|
265
|
+
|
266
|
+
template <>
|
267
|
+
inline int gesvd<nm::Complex64, float>(int matrix_layout, char jobu, char jobvt, int m, int n, nm::Complex64* a, int lda, float* s, nm::Complex64* u, int ldu, nm::Complex64* vt, int ldvt, float* superb) {
|
268
|
+
return LAPACKE_cgesvd(matrix_layout, jobu, jobvt, m, n, a, lda, s, u, ldu, vt, ldvt, superb);
|
269
|
+
}
|
270
|
+
|
271
|
+
template <>
|
272
|
+
inline int gesvd<nm::Complex128, double>(int matrix_layout, char jobu, char jobvt, int m, int n, nm::Complex128* a, int lda, double* s, nm::Complex128* u, int ldu, nm::Complex128* vt, int ldvt, double* superb) {
|
273
|
+
return LAPACKE_zgesvd(matrix_layout, jobu, jobvt, m, n, a, lda, s, u, ldu, vt, ldvt, superb);
|
274
|
+
}
|
275
|
+
|
276
|
+
template <typename DType, typename CType>
|
277
|
+
inline int lapacke_gesvd(int matrix_layout, char jobu, char jobvt, int m, int n, void* a, int lda, void* s, void* u, int ldu, void* vt, int ldvt, void* superb) {
|
278
|
+
return gesvd<DType,CType>(matrix_layout, jobu, jobvt, m, n, static_cast<DType*>(a), lda, static_cast<CType*>(s), static_cast<DType*>(u), ldu, static_cast<DType*>(vt), ldvt, static_cast<CType*>(superb));
|
279
|
+
}
|
280
|
+
|
281
|
+
//gesdd
|
282
|
+
template <typename DType, typename CType>
|
283
|
+
inline int gesdd(int matrix_layout, char jobz, int m, int n, DType* a, int lda, CType* s, DType* u, int ldu, DType* vt, int ldvt) {
|
284
|
+
rb_raise(rb_eNotImpError, "gesdd not yet implemented for non-BLAS dtypes");
|
285
|
+
return 0;
|
286
|
+
}
|
287
|
+
|
288
|
+
template <>
|
289
|
+
inline int gesdd<float, float>(int matrix_layout, char jobz, int m, int n, float* a, int lda, float* s, float* u, int ldu, float* vt, int ldvt) {
|
290
|
+
return LAPACKE_sgesdd(matrix_layout, jobz, m, n, a, lda, s, u, ldu, vt, ldvt);
|
291
|
+
}
|
292
|
+
|
293
|
+
template <>
|
294
|
+
inline int gesdd<double, double>(int matrix_layout, char jobz, int m, int n, double* a, int lda, double* s, double* u, int ldu, double* vt, int ldvt) {
|
295
|
+
return LAPACKE_dgesdd(matrix_layout, jobz, m, n, a, lda, s, u, ldu, vt, ldvt);
|
296
|
+
}
|
297
|
+
|
298
|
+
template <>
|
299
|
+
inline int gesdd<nm::Complex64, float>(int matrix_layout, char jobz, int m, int n, nm::Complex64* a, int lda, float* s, nm::Complex64* u, int ldu, nm::Complex64* vt, int ldvt) {
|
300
|
+
return LAPACKE_cgesdd(matrix_layout, jobz, m, n, a, lda, s, u, ldu, vt, ldvt);
|
301
|
+
}
|
302
|
+
|
303
|
+
template <>
|
304
|
+
inline int gesdd<nm::Complex128, double>(int matrix_layout, char jobz, int m, int n, nm::Complex128* a, int lda, double* s, nm::Complex128* u, int ldu, nm::Complex128* vt, int ldvt) {
|
305
|
+
return LAPACKE_zgesdd(matrix_layout, jobz, m, n, a, lda, s, u, ldu, vt, ldvt);
|
306
|
+
}
|
307
|
+
|
308
|
+
template <typename DType, typename CType>
|
309
|
+
inline int lapacke_gesdd(int matrix_layout, char jobz, int m, int n, void* a, int lda, void* s, void* u, int ldu, void* vt, int ldvt) {
|
310
|
+
return gesdd<DType,CType>(matrix_layout, jobz, m, n, static_cast<DType*>(a), lda, static_cast<CType*>(s), static_cast<DType*>(u), ldu, static_cast<DType*>(vt), ldvt);
|
311
|
+
}
|
312
|
+
|
313
|
+
//geev
|
314
|
+
//This one is a little tricky. The signature is different for the complex
|
315
|
+
//versions than for the real ones. This is because real matrices can have
|
316
|
+
//complex eigenvalues. For the complex types, the eigenvalues are just
|
317
|
+
//returned in argument that's a complex array, but for real types the real
|
318
|
+
//parts of the eigenvalues are returned
|
319
|
+
//in one (array) argument, and the complex parts in a separate argument.
|
320
|
+
//The solution is that the template takes an vi argument, but it is just
|
321
|
+
//ignored in the specializations for complex types.
|
322
|
+
|
323
|
+
template <typename DType>
|
324
|
+
inline int geev(int matrix_layout, char jobvl, char jobvr, int n, DType* a, int lda, DType* w, DType* wi, DType* vl, int ldvl, DType* vr, int ldvr) {
|
325
|
+
rb_raise(rb_eNotImpError, "not yet implemented for non-BLAS dtypes");
|
326
|
+
return -1;
|
327
|
+
}
|
328
|
+
|
329
|
+
template <>
|
330
|
+
inline int geev(int matrix_layout, char jobvl, char jobvr, int n, float* a, int lda, float* w, float* wi, float* vl, int ldvl, float* vr, int ldvr) {
|
331
|
+
return LAPACKE_sgeev(matrix_layout, jobvl, jobvr, n, a, lda, w, wi, vl, ldvl, vr, ldvr);
|
332
|
+
}
|
333
|
+
|
334
|
+
template <>
|
335
|
+
inline int geev(int matrix_layout, char jobvl, char jobvr, int n, double* a, int lda, double* w, double* wi, double* vl, int ldvl, double* vr, int ldvr) {
|
336
|
+
return LAPACKE_dgeev(matrix_layout, jobvl, jobvr, n, a, lda, w, wi, vl, ldvl, vr, ldvr);
|
337
|
+
}
|
338
|
+
|
339
|
+
template <>
|
340
|
+
inline int geev(int matrix_layout, char jobvl, char jobvr, int n, Complex64* a, int lda, Complex64* w, Complex64* wi, Complex64* vl, int ldvl, Complex64* vr, int ldvr) {
|
341
|
+
return LAPACKE_cgeev(matrix_layout, jobvl, jobvr, n, a, lda, w, vl, ldvl, vr, ldvr);
|
342
|
+
}
|
343
|
+
|
344
|
+
template <>
|
345
|
+
inline int geev(int matrix_layout, char jobvl, char jobvr, int n, Complex128* a, int lda, Complex128* w, Complex128* wi, Complex128* vl, int ldvl, Complex128* vr, int ldvr) {
|
346
|
+
return LAPACKE_zgeev(matrix_layout, jobvl, jobvr, n, a, lda, w, vl, ldvl, vr, ldvr);
|
347
|
+
}
|
348
|
+
|
349
|
+
template <typename DType>
|
350
|
+
inline int lapacke_geev(int matrix_layout, char jobvl, char jobvr, int n, void* a, int lda, void* w, void* wi, void* vl, int ldvl, void* vr, int ldvr) {
|
351
|
+
return geev<DType>(matrix_layout, jobvl, jobvr, n, static_cast<DType*>(a), lda, static_cast<DType*>(w), static_cast<DType*>(wi), static_cast<DType*>(vl), ldvl, static_cast<DType*>(vr), ldvr);
|
352
|
+
}
|
353
|
+
|
354
|
+
}}}
|
355
|
+
|
356
|
+
#endif
|
@@ -0,0 +1,42 @@
|
|
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
|
+
// == nmatrix_lapacke.cpp
|
25
|
+
//
|
26
|
+
// Main file for nmatrix_lapacke extension
|
27
|
+
//
|
28
|
+
|
29
|
+
#include <ruby.h>
|
30
|
+
|
31
|
+
#include "nmatrix.h"
|
32
|
+
|
33
|
+
#include "data/data.h"
|
34
|
+
|
35
|
+
extern "C" {
|
36
|
+
void nm_math_init_lapack();
|
37
|
+
|
38
|
+
void Init_nmatrix_lapacke() {
|
39
|
+
nm_math_init_lapack();
|
40
|
+
}
|
41
|
+
|
42
|
+
}
|