nmatrix-lapacke 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (185) hide show
  1. checksums.yaml +7 -0
  2. data/ext/nmatrix/data/complex.h +364 -0
  3. data/ext/nmatrix/data/data.h +638 -0
  4. data/ext/nmatrix/data/meta.h +64 -0
  5. data/ext/nmatrix/data/ruby_object.h +389 -0
  6. data/ext/nmatrix/math/asum.h +120 -0
  7. data/ext/nmatrix/math/cblas_enums.h +36 -0
  8. data/ext/nmatrix/math/cblas_templates_core.h +507 -0
  9. data/ext/nmatrix/math/gemm.h +241 -0
  10. data/ext/nmatrix/math/gemv.h +178 -0
  11. data/ext/nmatrix/math/getrf.h +255 -0
  12. data/ext/nmatrix/math/getrs.h +121 -0
  13. data/ext/nmatrix/math/imax.h +79 -0
  14. data/ext/nmatrix/math/laswp.h +165 -0
  15. data/ext/nmatrix/math/long_dtype.h +49 -0
  16. data/ext/nmatrix/math/math.h +744 -0
  17. data/ext/nmatrix/math/nrm2.h +160 -0
  18. data/ext/nmatrix/math/rot.h +117 -0
  19. data/ext/nmatrix/math/rotg.h +106 -0
  20. data/ext/nmatrix/math/scal.h +71 -0
  21. data/ext/nmatrix/math/trsm.h +332 -0
  22. data/ext/nmatrix/math/util.h +148 -0
  23. data/ext/nmatrix/nm_memory.h +60 -0
  24. data/ext/nmatrix/nmatrix.h +408 -0
  25. data/ext/nmatrix/ruby_constants.h +106 -0
  26. data/ext/nmatrix/storage/common.h +176 -0
  27. data/ext/nmatrix/storage/dense/dense.h +128 -0
  28. data/ext/nmatrix/storage/list/list.h +137 -0
  29. data/ext/nmatrix/storage/storage.h +98 -0
  30. data/ext/nmatrix/storage/yale/class.h +1139 -0
  31. data/ext/nmatrix/storage/yale/iterators/base.h +142 -0
  32. data/ext/nmatrix/storage/yale/iterators/iterator.h +130 -0
  33. data/ext/nmatrix/storage/yale/iterators/row.h +449 -0
  34. data/ext/nmatrix/storage/yale/iterators/row_stored.h +139 -0
  35. data/ext/nmatrix/storage/yale/iterators/row_stored_nd.h +168 -0
  36. data/ext/nmatrix/storage/yale/iterators/stored_diagonal.h +123 -0
  37. data/ext/nmatrix/storage/yale/math/transpose.h +110 -0
  38. data/ext/nmatrix/storage/yale/yale.h +202 -0
  39. data/ext/nmatrix/types.h +54 -0
  40. data/ext/nmatrix/util/io.h +115 -0
  41. data/ext/nmatrix/util/sl_list.h +143 -0
  42. data/ext/nmatrix/util/util.h +78 -0
  43. data/ext/nmatrix_lapacke/extconf.rb +200 -0
  44. data/ext/nmatrix_lapacke/lapacke.cpp +100 -0
  45. data/ext/nmatrix_lapacke/lapacke/include/lapacke.h +16445 -0
  46. data/ext/nmatrix_lapacke/lapacke/include/lapacke_config.h +119 -0
  47. data/ext/nmatrix_lapacke/lapacke/include/lapacke_mangling.h +17 -0
  48. data/ext/nmatrix_lapacke/lapacke/include/lapacke_mangling_with_flags.h +17 -0
  49. data/ext/nmatrix_lapacke/lapacke/include/lapacke_utils.h +579 -0
  50. data/ext/nmatrix_lapacke/lapacke/src/lapacke_cgeev.c +89 -0
  51. data/ext/nmatrix_lapacke/lapacke/src/lapacke_cgeev_work.c +141 -0
  52. data/ext/nmatrix_lapacke/lapacke/src/lapacke_cgesdd.c +106 -0
  53. data/ext/nmatrix_lapacke/lapacke/src/lapacke_cgesdd_work.c +158 -0
  54. data/ext/nmatrix_lapacke/lapacke/src/lapacke_cgesvd.c +94 -0
  55. data/ext/nmatrix_lapacke/lapacke/src/lapacke_cgesvd_work.c +149 -0
  56. data/ext/nmatrix_lapacke/lapacke/src/lapacke_cgetrf.c +51 -0
  57. data/ext/nmatrix_lapacke/lapacke/src/lapacke_cgetrf_work.c +83 -0
  58. data/ext/nmatrix_lapacke/lapacke/src/lapacke_cgetri.c +77 -0
  59. data/ext/nmatrix_lapacke/lapacke/src/lapacke_cgetri_work.c +89 -0
  60. data/ext/nmatrix_lapacke/lapacke/src/lapacke_cgetrs.c +56 -0
  61. data/ext/nmatrix_lapacke/lapacke/src/lapacke_cgetrs_work.c +102 -0
  62. data/ext/nmatrix_lapacke/lapacke/src/lapacke_cpotrf.c +50 -0
  63. data/ext/nmatrix_lapacke/lapacke/src/lapacke_cpotrf_work.c +82 -0
  64. data/ext/nmatrix_lapacke/lapacke/src/lapacke_cpotri.c +50 -0
  65. data/ext/nmatrix_lapacke/lapacke/src/lapacke_cpotri_work.c +82 -0
  66. data/ext/nmatrix_lapacke/lapacke/src/lapacke_cpotrs.c +55 -0
  67. data/ext/nmatrix_lapacke/lapacke/src/lapacke_cpotrs_work.c +101 -0
  68. data/ext/nmatrix_lapacke/lapacke/src/lapacke_dgeev.c +78 -0
  69. data/ext/nmatrix_lapacke/lapacke/src/lapacke_dgeev_work.c +136 -0
  70. data/ext/nmatrix_lapacke/lapacke/src/lapacke_dgesdd.c +88 -0
  71. data/ext/nmatrix_lapacke/lapacke/src/lapacke_dgesdd_work.c +153 -0
  72. data/ext/nmatrix_lapacke/lapacke/src/lapacke_dgesvd.c +83 -0
  73. data/ext/nmatrix_lapacke/lapacke/src/lapacke_dgesvd_work.c +144 -0
  74. data/ext/nmatrix_lapacke/lapacke/src/lapacke_dgetrf.c +50 -0
  75. data/ext/nmatrix_lapacke/lapacke/src/lapacke_dgetrf_work.c +81 -0
  76. data/ext/nmatrix_lapacke/lapacke/src/lapacke_dgetri.c +75 -0
  77. data/ext/nmatrix_lapacke/lapacke/src/lapacke_dgetri_work.c +87 -0
  78. data/ext/nmatrix_lapacke/lapacke/src/lapacke_dgetrs.c +55 -0
  79. data/ext/nmatrix_lapacke/lapacke/src/lapacke_dgetrs_work.c +99 -0
  80. data/ext/nmatrix_lapacke/lapacke/src/lapacke_dpotrf.c +50 -0
  81. data/ext/nmatrix_lapacke/lapacke/src/lapacke_dpotrf_work.c +81 -0
  82. data/ext/nmatrix_lapacke/lapacke/src/lapacke_dpotri.c +50 -0
  83. data/ext/nmatrix_lapacke/lapacke/src/lapacke_dpotri_work.c +81 -0
  84. data/ext/nmatrix_lapacke/lapacke/src/lapacke_dpotrs.c +54 -0
  85. data/ext/nmatrix_lapacke/lapacke/src/lapacke_dpotrs_work.c +97 -0
  86. data/ext/nmatrix_lapacke/lapacke/src/lapacke_sgeev.c +78 -0
  87. data/ext/nmatrix_lapacke/lapacke/src/lapacke_sgeev_work.c +134 -0
  88. data/ext/nmatrix_lapacke/lapacke/src/lapacke_sgesdd.c +88 -0
  89. data/ext/nmatrix_lapacke/lapacke/src/lapacke_sgesdd_work.c +152 -0
  90. data/ext/nmatrix_lapacke/lapacke/src/lapacke_sgesvd.c +83 -0
  91. data/ext/nmatrix_lapacke/lapacke/src/lapacke_sgesvd_work.c +143 -0
  92. data/ext/nmatrix_lapacke/lapacke/src/lapacke_sgetrf.c +50 -0
  93. data/ext/nmatrix_lapacke/lapacke/src/lapacke_sgetrf_work.c +81 -0
  94. data/ext/nmatrix_lapacke/lapacke/src/lapacke_sgetri.c +75 -0
  95. data/ext/nmatrix_lapacke/lapacke/src/lapacke_sgetri_work.c +87 -0
  96. data/ext/nmatrix_lapacke/lapacke/src/lapacke_sgetrs.c +55 -0
  97. data/ext/nmatrix_lapacke/lapacke/src/lapacke_sgetrs_work.c +99 -0
  98. data/ext/nmatrix_lapacke/lapacke/src/lapacke_spotrf.c +50 -0
  99. data/ext/nmatrix_lapacke/lapacke/src/lapacke_spotrf_work.c +81 -0
  100. data/ext/nmatrix_lapacke/lapacke/src/lapacke_spotri.c +50 -0
  101. data/ext/nmatrix_lapacke/lapacke/src/lapacke_spotri_work.c +81 -0
  102. data/ext/nmatrix_lapacke/lapacke/src/lapacke_spotrs.c +54 -0
  103. data/ext/nmatrix_lapacke/lapacke/src/lapacke_spotrs_work.c +97 -0
  104. data/ext/nmatrix_lapacke/lapacke/src/lapacke_zgeev.c +89 -0
  105. data/ext/nmatrix_lapacke/lapacke/src/lapacke_zgeev_work.c +141 -0
  106. data/ext/nmatrix_lapacke/lapacke/src/lapacke_zgesdd.c +106 -0
  107. data/ext/nmatrix_lapacke/lapacke/src/lapacke_zgesdd_work.c +158 -0
  108. data/ext/nmatrix_lapacke/lapacke/src/lapacke_zgesvd.c +94 -0
  109. data/ext/nmatrix_lapacke/lapacke/src/lapacke_zgesvd_work.c +149 -0
  110. data/ext/nmatrix_lapacke/lapacke/src/lapacke_zgetrf.c +51 -0
  111. data/ext/nmatrix_lapacke/lapacke/src/lapacke_zgetrf_work.c +83 -0
  112. data/ext/nmatrix_lapacke/lapacke/src/lapacke_zgetri.c +77 -0
  113. data/ext/nmatrix_lapacke/lapacke/src/lapacke_zgetri_work.c +89 -0
  114. data/ext/nmatrix_lapacke/lapacke/src/lapacke_zgetrs.c +56 -0
  115. data/ext/nmatrix_lapacke/lapacke/src/lapacke_zgetrs_work.c +102 -0
  116. data/ext/nmatrix_lapacke/lapacke/src/lapacke_zpotrf.c +50 -0
  117. data/ext/nmatrix_lapacke/lapacke/src/lapacke_zpotrf_work.c +82 -0
  118. data/ext/nmatrix_lapacke/lapacke/src/lapacke_zpotri.c +50 -0
  119. data/ext/nmatrix_lapacke/lapacke/src/lapacke_zpotri_work.c +82 -0
  120. data/ext/nmatrix_lapacke/lapacke/src/lapacke_zpotrs.c +55 -0
  121. data/ext/nmatrix_lapacke/lapacke/src/lapacke_zpotrs_work.c +101 -0
  122. data/ext/nmatrix_lapacke/lapacke/utils/lapacke_cge_nancheck.c +62 -0
  123. data/ext/nmatrix_lapacke/lapacke/utils/lapacke_cge_trans.c +65 -0
  124. data/ext/nmatrix_lapacke/lapacke/utils/lapacke_cpo_nancheck.c +43 -0
  125. data/ext/nmatrix_lapacke/lapacke/utils/lapacke_cpo_trans.c +45 -0
  126. data/ext/nmatrix_lapacke/lapacke/utils/lapacke_ctr_nancheck.c +85 -0
  127. data/ext/nmatrix_lapacke/lapacke/utils/lapacke_ctr_trans.c +85 -0
  128. data/ext/nmatrix_lapacke/lapacke/utils/lapacke_dge_nancheck.c +62 -0
  129. data/ext/nmatrix_lapacke/lapacke/utils/lapacke_dge_trans.c +65 -0
  130. data/ext/nmatrix_lapacke/lapacke/utils/lapacke_dpo_nancheck.c +43 -0
  131. data/ext/nmatrix_lapacke/lapacke/utils/lapacke_dpo_trans.c +45 -0
  132. data/ext/nmatrix_lapacke/lapacke/utils/lapacke_dtr_nancheck.c +85 -0
  133. data/ext/nmatrix_lapacke/lapacke/utils/lapacke_dtr_trans.c +85 -0
  134. data/ext/nmatrix_lapacke/lapacke/utils/lapacke_lsame.c +41 -0
  135. data/ext/nmatrix_lapacke/lapacke/utils/lapacke_sge_nancheck.c +62 -0
  136. data/ext/nmatrix_lapacke/lapacke/utils/lapacke_sge_trans.c +65 -0
  137. data/ext/nmatrix_lapacke/lapacke/utils/lapacke_spo_nancheck.c +43 -0
  138. data/ext/nmatrix_lapacke/lapacke/utils/lapacke_spo_trans.c +45 -0
  139. data/ext/nmatrix_lapacke/lapacke/utils/lapacke_str_nancheck.c +85 -0
  140. data/ext/nmatrix_lapacke/lapacke/utils/lapacke_str_trans.c +85 -0
  141. data/ext/nmatrix_lapacke/lapacke/utils/lapacke_xerbla.c +46 -0
  142. data/ext/nmatrix_lapacke/lapacke/utils/lapacke_zge_nancheck.c +62 -0
  143. data/ext/nmatrix_lapacke/lapacke/utils/lapacke_zge_trans.c +65 -0
  144. data/ext/nmatrix_lapacke/lapacke/utils/lapacke_zpo_nancheck.c +43 -0
  145. data/ext/nmatrix_lapacke/lapacke/utils/lapacke_zpo_trans.c +45 -0
  146. data/ext/nmatrix_lapacke/lapacke/utils/lapacke_ztr_nancheck.c +85 -0
  147. data/ext/nmatrix_lapacke/lapacke/utils/lapacke_ztr_trans.c +85 -0
  148. data/ext/nmatrix_lapacke/lapacke_nmatrix.h +16 -0
  149. data/ext/nmatrix_lapacke/make_lapacke_cpp.rb +9 -0
  150. data/ext/nmatrix_lapacke/math_lapacke.cpp +967 -0
  151. data/ext/nmatrix_lapacke/math_lapacke/cblas_local.h +576 -0
  152. data/ext/nmatrix_lapacke/math_lapacke/cblas_templates_lapacke.h +51 -0
  153. data/ext/nmatrix_lapacke/math_lapacke/lapacke_templates.h +356 -0
  154. data/ext/nmatrix_lapacke/nmatrix_lapacke.cpp +42 -0
  155. data/lib/nmatrix/lapack_ext_common.rb +69 -0
  156. data/lib/nmatrix/lapacke.rb +213 -0
  157. data/spec/00_nmatrix_spec.rb +730 -0
  158. data/spec/01_enum_spec.rb +190 -0
  159. data/spec/02_slice_spec.rb +389 -0
  160. data/spec/03_nmatrix_monkeys_spec.rb +78 -0
  161. data/spec/2x2_dense_double.mat +0 -0
  162. data/spec/4x4_sparse.mat +0 -0
  163. data/spec/4x5_dense.mat +0 -0
  164. data/spec/blas_spec.rb +193 -0
  165. data/spec/elementwise_spec.rb +303 -0
  166. data/spec/homogeneous_spec.rb +99 -0
  167. data/spec/io/fortran_format_spec.rb +88 -0
  168. data/spec/io/harwell_boeing_spec.rb +98 -0
  169. data/spec/io/test.rua +9 -0
  170. data/spec/io_spec.rb +149 -0
  171. data/spec/lapack_core_spec.rb +482 -0
  172. data/spec/leakcheck.rb +16 -0
  173. data/spec/math_spec.rb +730 -0
  174. data/spec/nmatrix_yale_resize_test_associations.yaml +2802 -0
  175. data/spec/nmatrix_yale_spec.rb +286 -0
  176. data/spec/plugins/lapacke/lapacke_spec.rb +303 -0
  177. data/spec/rspec_monkeys.rb +56 -0
  178. data/spec/rspec_spec.rb +34 -0
  179. data/spec/shortcuts_spec.rb +310 -0
  180. data/spec/slice_set_spec.rb +157 -0
  181. data/spec/spec_helper.rb +140 -0
  182. data/spec/stat_spec.rb +203 -0
  183. data/spec/test.pcd +20 -0
  184. data/spec/utm5940.mtx +83844 -0
  185. metadata +262 -0
@@ -0,0 +1,88 @@
1
+ /*****************************************************************************
2
+ Copyright (c) 2011, Intel Corp.
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,
9
+ this list of conditions and the following disclaimer.
10
+ * Redistributions in binary form must reproduce the above copyright
11
+ notice, this list of conditions and the following disclaimer in the
12
+ documentation and/or other materials provided with the distribution.
13
+ * Neither the name of Intel Corporation nor the names of its contributors
14
+ may be used to endorse or promote products derived from this software
15
+ without specific prior written permission.
16
+
17
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27
+ THE POSSIBILITY OF SUCH DAMAGE.
28
+ *****************************************************************************
29
+ * Contents: Native high-level C interface to LAPACK function sgesdd
30
+ * Author: Intel Corporation
31
+ * Generated November, 2011
32
+ *****************************************************************************/
33
+
34
+ #include "lapacke_utils.h"
35
+
36
+ lapack_int LAPACKE_sgesdd( int matrix_order, char jobz, lapack_int m,
37
+ lapack_int n, float* a, lapack_int lda, float* s,
38
+ float* u, lapack_int ldu, float* vt,
39
+ lapack_int ldvt )
40
+ {
41
+ lapack_int info = 0;
42
+ lapack_int lwork = -1;
43
+ lapack_int* iwork = NULL;
44
+ float* work = NULL;
45
+ float work_query;
46
+ if( matrix_order != LAPACK_COL_MAJOR && matrix_order != LAPACK_ROW_MAJOR ) {
47
+ LAPACKE_xerbla( "LAPACKE_sgesdd", -1 );
48
+ return -1;
49
+ }
50
+ #ifndef LAPACK_DISABLE_NAN_CHECK
51
+ /* Optionally check input matrices for NaNs */
52
+ if( LAPACKE_sge_nancheck( matrix_order, m, n, a, lda ) ) {
53
+ return -5;
54
+ }
55
+ #endif
56
+ /* Allocate memory for working array(s) */
57
+ iwork = (lapack_int*)
58
+ LAPACKE_malloc( sizeof(lapack_int) * MAX(1,8*MIN(m,n)) );
59
+ if( iwork == NULL ) {
60
+ info = LAPACK_WORK_MEMORY_ERROR;
61
+ goto exit_level_0;
62
+ }
63
+ /* Query optimal working array(s) size */
64
+ info = LAPACKE_sgesdd_work( matrix_order, jobz, m, n, a, lda, s, u, ldu, vt,
65
+ ldvt, &work_query, lwork, iwork );
66
+ if( info != 0 ) {
67
+ goto exit_level_1;
68
+ }
69
+ lwork = (lapack_int)work_query;
70
+ /* Allocate memory for work arrays */
71
+ work = (float*)LAPACKE_malloc( sizeof(float) * lwork );
72
+ if( work == NULL ) {
73
+ info = LAPACK_WORK_MEMORY_ERROR;
74
+ goto exit_level_1;
75
+ }
76
+ /* Call middle-level interface */
77
+ info = LAPACKE_sgesdd_work( matrix_order, jobz, m, n, a, lda, s, u, ldu, vt,
78
+ ldvt, work, lwork, iwork );
79
+ /* Release memory and exit */
80
+ LAPACKE_free( work );
81
+ exit_level_1:
82
+ LAPACKE_free( iwork );
83
+ exit_level_0:
84
+ if( info == LAPACK_WORK_MEMORY_ERROR ) {
85
+ LAPACKE_xerbla( "LAPACKE_sgesdd", info );
86
+ }
87
+ return info;
88
+ }
@@ -0,0 +1,152 @@
1
+ /*****************************************************************************
2
+ Copyright (c) 2011, Intel Corp.
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,
9
+ this list of conditions and the following disclaimer.
10
+ * Redistributions in binary form must reproduce the above copyright
11
+ notice, this list of conditions and the following disclaimer in the
12
+ documentation and/or other materials provided with the distribution.
13
+ * Neither the name of Intel Corporation nor the names of its contributors
14
+ may be used to endorse or promote products derived from this software
15
+ without specific prior written permission.
16
+
17
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27
+ THE POSSIBILITY OF SUCH DAMAGE.
28
+ *****************************************************************************
29
+ * Contents: Native middle-level C interface to LAPACK function sgesdd
30
+ * Author: Intel Corporation
31
+ * Generated November, 2011
32
+ *****************************************************************************/
33
+
34
+ #include "lapacke_utils.h"
35
+
36
+ lapack_int LAPACKE_sgesdd_work( int matrix_order, char jobz, lapack_int m,
37
+ lapack_int n, float* a, lapack_int lda,
38
+ float* s, float* u, lapack_int ldu, float* vt,
39
+ lapack_int ldvt, float* work, lapack_int lwork,
40
+ lapack_int* iwork )
41
+ {
42
+ lapack_int info = 0;
43
+ if( matrix_order == LAPACK_COL_MAJOR ) {
44
+ /* Call LAPACK function and adjust info */
45
+ LAPACK_sgesdd( &jobz, &m, &n, a, &lda, s, u, &ldu, vt, &ldvt, work,
46
+ &lwork, iwork, &info );
47
+ if( info < 0 ) {
48
+ info = info - 1;
49
+ }
50
+ } else if( matrix_order == LAPACK_ROW_MAJOR ) {
51
+ lapack_int nrows_u = ( LAPACKE_lsame( jobz, 'a' ) ||
52
+ LAPACKE_lsame( jobz, 's' ) ||
53
+ ( LAPACKE_lsame( jobz, 'o' ) && m<n) ) ? m : 1;
54
+ lapack_int ncols_u = ( LAPACKE_lsame( jobz, 'a' ) ||
55
+ ( LAPACKE_lsame( jobz, 'o' ) && m<n) ) ? m :
56
+ ( LAPACKE_lsame( jobz, 's' ) ? MIN(m,n) : 1);
57
+ lapack_int nrows_vt = ( LAPACKE_lsame( jobz, 'a' ) ||
58
+ ( LAPACKE_lsame( jobz, 'o' ) && m<n) ) ? n :
59
+ ( LAPACKE_lsame( jobz, 's' ) ? MIN(m,n) : 1);
60
+ lapack_int lda_t = MAX(1,m);
61
+ lapack_int ldu_t = MAX(1,nrows_u);
62
+ lapack_int ldvt_t = MAX(1,nrows_vt);
63
+ float* a_t = NULL;
64
+ float* u_t = NULL;
65
+ float* vt_t = NULL;
66
+ /* Check leading dimension(s) */
67
+ if( lda < n ) {
68
+ info = -6;
69
+ LAPACKE_xerbla( "LAPACKE_sgesdd_work", info );
70
+ return info;
71
+ }
72
+ if( ldu < ncols_u ) {
73
+ info = -9;
74
+ LAPACKE_xerbla( "LAPACKE_sgesdd_work", info );
75
+ return info;
76
+ }
77
+ if( ldvt < n ) {
78
+ info = -11;
79
+ LAPACKE_xerbla( "LAPACKE_sgesdd_work", info );
80
+ return info;
81
+ }
82
+ /* Query optimal working array(s) size if requested */
83
+ if( lwork == -1 ) {
84
+ LAPACK_sgesdd( &jobz, &m, &n, a, &lda_t, s, u, &ldu_t, vt, &ldvt_t,
85
+ work, &lwork, iwork, &info );
86
+ return (info < 0) ? (info - 1) : info;
87
+ }
88
+ /* Allocate memory for temporary array(s) */
89
+ a_t = (float*)LAPACKE_malloc( sizeof(float) * lda_t * MAX(1,n) );
90
+ if( a_t == NULL ) {
91
+ info = LAPACK_TRANSPOSE_MEMORY_ERROR;
92
+ goto exit_level_0;
93
+ }
94
+ if( LAPACKE_lsame( jobz, 'a' ) || LAPACKE_lsame( jobz, 's' ) ||
95
+ ( LAPACKE_lsame( jobz, 'o' ) && (m<n) ) ) {
96
+ u_t = (float*)
97
+ LAPACKE_malloc( sizeof(float) * ldu_t * MAX(1,ncols_u) );
98
+ if( u_t == NULL ) {
99
+ info = LAPACK_TRANSPOSE_MEMORY_ERROR;
100
+ goto exit_level_1;
101
+ }
102
+ }
103
+ if( LAPACKE_lsame( jobz, 'a' ) || LAPACKE_lsame( jobz, 's' ) ||
104
+ ( LAPACKE_lsame( jobz, 'o' ) && (m>=n) ) ) {
105
+ vt_t = (float*)LAPACKE_malloc( sizeof(float) * ldvt_t * MAX(1,n) );
106
+ if( vt_t == NULL ) {
107
+ info = LAPACK_TRANSPOSE_MEMORY_ERROR;
108
+ goto exit_level_2;
109
+ }
110
+ }
111
+ /* Transpose input matrices */
112
+ LAPACKE_sge_trans( matrix_order, m, n, a, lda, a_t, lda_t );
113
+ /* Call LAPACK function and adjust info */
114
+ LAPACK_sgesdd( &jobz, &m, &n, a_t, &lda_t, s, u_t, &ldu_t, vt_t,
115
+ &ldvt_t, work, &lwork, iwork, &info );
116
+ if( info < 0 ) {
117
+ info = info - 1;
118
+ }
119
+ /* Transpose output matrices */
120
+ LAPACKE_sge_trans( LAPACK_COL_MAJOR, m, n, a_t, lda_t, a, lda );
121
+ if( LAPACKE_lsame( jobz, 'a' ) || LAPACKE_lsame( jobz, 's' ) ||
122
+ ( LAPACKE_lsame( jobz, 'o' ) && (m<n) ) ) {
123
+ LAPACKE_sge_trans( LAPACK_COL_MAJOR, nrows_u, ncols_u, u_t, ldu_t,
124
+ u, ldu );
125
+ }
126
+ if( LAPACKE_lsame( jobz, 'a' ) || LAPACKE_lsame( jobz, 's' ) ||
127
+ ( LAPACKE_lsame( jobz, 'o' ) && (m>=n) ) ) {
128
+ LAPACKE_sge_trans( LAPACK_COL_MAJOR, nrows_vt, n, vt_t, ldvt_t, vt,
129
+ ldvt );
130
+ }
131
+ /* Release memory and exit */
132
+ if( LAPACKE_lsame( jobz, 'a' ) || LAPACKE_lsame( jobz, 's' ) ||
133
+ ( LAPACKE_lsame( jobz, 'o' ) && (m>=n) ) ) {
134
+ LAPACKE_free( vt_t );
135
+ }
136
+ exit_level_2:
137
+ if( LAPACKE_lsame( jobz, 'a' ) || LAPACKE_lsame( jobz, 's' ) ||
138
+ ( LAPACKE_lsame( jobz, 'o' ) && (m<n) ) ) {
139
+ LAPACKE_free( u_t );
140
+ }
141
+ exit_level_1:
142
+ LAPACKE_free( a_t );
143
+ exit_level_0:
144
+ if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
145
+ LAPACKE_xerbla( "LAPACKE_sgesdd_work", info );
146
+ }
147
+ } else {
148
+ info = -1;
149
+ LAPACKE_xerbla( "LAPACKE_sgesdd_work", info );
150
+ }
151
+ return info;
152
+ }
@@ -0,0 +1,83 @@
1
+ /*****************************************************************************
2
+ Copyright (c) 2011, Intel Corp.
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,
9
+ this list of conditions and the following disclaimer.
10
+ * Redistributions in binary form must reproduce the above copyright
11
+ notice, this list of conditions and the following disclaimer in the
12
+ documentation and/or other materials provided with the distribution.
13
+ * Neither the name of Intel Corporation nor the names of its contributors
14
+ may be used to endorse or promote products derived from this software
15
+ without specific prior written permission.
16
+
17
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27
+ THE POSSIBILITY OF SUCH DAMAGE.
28
+ *****************************************************************************
29
+ * Contents: Native high-level C interface to LAPACK function sgesvd
30
+ * Author: Intel Corporation
31
+ * Generated November, 2011
32
+ *****************************************************************************/
33
+
34
+ #include "lapacke_utils.h"
35
+
36
+ lapack_int LAPACKE_sgesvd( int matrix_order, char jobu, char jobvt,
37
+ lapack_int m, lapack_int n, float* a, lapack_int lda,
38
+ float* s, float* u, lapack_int ldu, float* vt,
39
+ lapack_int ldvt, float* superb )
40
+ {
41
+ lapack_int info = 0;
42
+ lapack_int lwork = -1;
43
+ float* work = NULL;
44
+ float work_query;
45
+ lapack_int i;
46
+ if( matrix_order != LAPACK_COL_MAJOR && matrix_order != LAPACK_ROW_MAJOR ) {
47
+ LAPACKE_xerbla( "LAPACKE_sgesvd", -1 );
48
+ return -1;
49
+ }
50
+ #ifndef LAPACK_DISABLE_NAN_CHECK
51
+ /* Optionally check input matrices for NaNs */
52
+ if( LAPACKE_sge_nancheck( matrix_order, m, n, a, lda ) ) {
53
+ return -6;
54
+ }
55
+ #endif
56
+ /* Query optimal working array(s) size */
57
+ info = LAPACKE_sgesvd_work( matrix_order, jobu, jobvt, m, n, a, lda, s, u,
58
+ ldu, vt, ldvt, &work_query, lwork );
59
+ if( info != 0 ) {
60
+ goto exit_level_0;
61
+ }
62
+ lwork = (lapack_int)work_query;
63
+ /* Allocate memory for work arrays */
64
+ work = (float*)LAPACKE_malloc( sizeof(float) * lwork );
65
+ if( work == NULL ) {
66
+ info = LAPACK_WORK_MEMORY_ERROR;
67
+ goto exit_level_0;
68
+ }
69
+ /* Call middle-level interface */
70
+ info = LAPACKE_sgesvd_work( matrix_order, jobu, jobvt, m, n, a, lda, s, u,
71
+ ldu, vt, ldvt, work, lwork );
72
+ /* Backup significant data from working array(s) */
73
+ for( i=0; i<MIN(m,n)-1; i++ ) {
74
+ superb[i] = work[i+1];
75
+ }
76
+ /* Release memory and exit */
77
+ LAPACKE_free( work );
78
+ exit_level_0:
79
+ if( info == LAPACK_WORK_MEMORY_ERROR ) {
80
+ LAPACKE_xerbla( "LAPACKE_sgesvd", info );
81
+ }
82
+ return info;
83
+ }
@@ -0,0 +1,143 @@
1
+ /*****************************************************************************
2
+ Copyright (c) 2011, Intel Corp.
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,
9
+ this list of conditions and the following disclaimer.
10
+ * Redistributions in binary form must reproduce the above copyright
11
+ notice, this list of conditions and the following disclaimer in the
12
+ documentation and/or other materials provided with the distribution.
13
+ * Neither the name of Intel Corporation nor the names of its contributors
14
+ may be used to endorse or promote products derived from this software
15
+ without specific prior written permission.
16
+
17
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27
+ THE POSSIBILITY OF SUCH DAMAGE.
28
+ *****************************************************************************
29
+ * Contents: Native middle-level C interface to LAPACK function sgesvd
30
+ * Author: Intel Corporation
31
+ * Generated November, 2011
32
+ *****************************************************************************/
33
+
34
+ #include "lapacke_utils.h"
35
+
36
+ lapack_int LAPACKE_sgesvd_work( int matrix_order, char jobu, char jobvt,
37
+ lapack_int m, lapack_int n, float* a,
38
+ lapack_int lda, float* s, float* u,
39
+ lapack_int ldu, float* vt, lapack_int ldvt,
40
+ float* work, lapack_int lwork )
41
+ {
42
+ lapack_int info = 0;
43
+ if( matrix_order == LAPACK_COL_MAJOR ) {
44
+ /* Call LAPACK function and adjust info */
45
+ LAPACK_sgesvd( &jobu, &jobvt, &m, &n, a, &lda, s, u, &ldu, vt, &ldvt,
46
+ work, &lwork, &info );
47
+ if( info < 0 ) {
48
+ info = info - 1;
49
+ }
50
+ } else if( matrix_order == LAPACK_ROW_MAJOR ) {
51
+ lapack_int nrows_u = ( LAPACKE_lsame( jobu, 'a' ) ||
52
+ LAPACKE_lsame( jobu, 's' ) ) ? m : 1;
53
+ lapack_int ncols_u = LAPACKE_lsame( jobu, 'a' ) ? m :
54
+ ( LAPACKE_lsame( jobu, 's' ) ? MIN(m,n) : 1);
55
+ lapack_int nrows_vt = LAPACKE_lsame( jobvt, 'a' ) ? n :
56
+ ( LAPACKE_lsame( jobvt, 's' ) ? MIN(m,n) : 1);
57
+ lapack_int lda_t = MAX(1,m);
58
+ lapack_int ldu_t = MAX(1,nrows_u);
59
+ lapack_int ldvt_t = MAX(1,nrows_vt);
60
+ float* a_t = NULL;
61
+ float* u_t = NULL;
62
+ float* vt_t = NULL;
63
+ /* Check leading dimension(s) */
64
+ if( lda < n ) {
65
+ info = -7;
66
+ LAPACKE_xerbla( "LAPACKE_sgesvd_work", info );
67
+ return info;
68
+ }
69
+ if( ldu < ncols_u ) {
70
+ info = -10;
71
+ LAPACKE_xerbla( "LAPACKE_sgesvd_work", info );
72
+ return info;
73
+ }
74
+ if( ldvt < n ) {
75
+ info = -12;
76
+ LAPACKE_xerbla( "LAPACKE_sgesvd_work", info );
77
+ return info;
78
+ }
79
+ /* Query optimal working array(s) size if requested */
80
+ if( lwork == -1 ) {
81
+ LAPACK_sgesvd( &jobu, &jobvt, &m, &n, a, &lda_t, s, u, &ldu_t, vt,
82
+ &ldvt_t, work, &lwork, &info );
83
+ return (info < 0) ? (info - 1) : info;
84
+ }
85
+ /* Allocate memory for temporary array(s) */
86
+ a_t = (float*)LAPACKE_malloc( sizeof(float) * lda_t * MAX(1,n) );
87
+ if( a_t == NULL ) {
88
+ info = LAPACK_TRANSPOSE_MEMORY_ERROR;
89
+ goto exit_level_0;
90
+ }
91
+ if( LAPACKE_lsame( jobu, 'a' ) || LAPACKE_lsame( jobu, 's' ) ) {
92
+ u_t = (float*)
93
+ LAPACKE_malloc( sizeof(float) * ldu_t * MAX(1,ncols_u) );
94
+ if( u_t == NULL ) {
95
+ info = LAPACK_TRANSPOSE_MEMORY_ERROR;
96
+ goto exit_level_1;
97
+ }
98
+ }
99
+ if( LAPACKE_lsame( jobvt, 'a' ) || LAPACKE_lsame( jobvt, 's' ) ) {
100
+ vt_t = (float*)LAPACKE_malloc( sizeof(float) * ldvt_t * MAX(1,n) );
101
+ if( vt_t == NULL ) {
102
+ info = LAPACK_TRANSPOSE_MEMORY_ERROR;
103
+ goto exit_level_2;
104
+ }
105
+ }
106
+ /* Transpose input matrices */
107
+ LAPACKE_sge_trans( matrix_order, m, n, a, lda, a_t, lda_t );
108
+ /* Call LAPACK function and adjust info */
109
+ LAPACK_sgesvd( &jobu, &jobvt, &m, &n, a_t, &lda_t, s, u_t, &ldu_t, vt_t,
110
+ &ldvt_t, work, &lwork, &info );
111
+ if( info < 0 ) {
112
+ info = info - 1;
113
+ }
114
+ /* Transpose output matrices */
115
+ LAPACKE_sge_trans( LAPACK_COL_MAJOR, m, n, a_t, lda_t, a, lda );
116
+ if( LAPACKE_lsame( jobu, 'a' ) || LAPACKE_lsame( jobu, 's' ) ) {
117
+ LAPACKE_sge_trans( LAPACK_COL_MAJOR, nrows_u, ncols_u, u_t, ldu_t,
118
+ u, ldu );
119
+ }
120
+ if( LAPACKE_lsame( jobvt, 'a' ) || LAPACKE_lsame( jobvt, 's' ) ) {
121
+ LAPACKE_sge_trans( LAPACK_COL_MAJOR, nrows_vt, n, vt_t, ldvt_t, vt,
122
+ ldvt );
123
+ }
124
+ /* Release memory and exit */
125
+ if( LAPACKE_lsame( jobvt, 'a' ) || LAPACKE_lsame( jobvt, 's' ) ) {
126
+ LAPACKE_free( vt_t );
127
+ }
128
+ exit_level_2:
129
+ if( LAPACKE_lsame( jobu, 'a' ) || LAPACKE_lsame( jobu, 's' ) ) {
130
+ LAPACKE_free( u_t );
131
+ }
132
+ exit_level_1:
133
+ LAPACKE_free( a_t );
134
+ exit_level_0:
135
+ if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
136
+ LAPACKE_xerbla( "LAPACKE_sgesvd_work", info );
137
+ }
138
+ } else {
139
+ info = -1;
140
+ LAPACKE_xerbla( "LAPACKE_sgesvd_work", info );
141
+ }
142
+ return info;
143
+ }