@@ -875,14 +875,14 @@ VALUE nm_posv(int argc, VALUE* argv) {
875875 Data_Get_Struct (argv [1 ], nmatrix , matrix_b );
876876
877877 int m_b = matrix_b -> shape [0 ]; //no. of rows
878- int n_b = matrix_b -> shape [ 1 ] ; //no. of cols
878+ int n_b = 1 ; //no. of cols
879879 int lda_b = n_b ;
880880
881881 bool lower = (bool )RTEST (argv [2 ]);
882882 char uplo = lower ? 'L' : 'U' ;
883883
884884 nmatrix * result_c = nmatrix_new (matrix_a -> dtype , matrix_a -> stype , 2 , matrix_a -> count , matrix_a -> shape , NULL );
885- nmatrix * result_x = nmatrix_new (matrix_b -> dtype , matrix_b -> stype , 2 , matrix_b -> count , matrix_b -> shape , NULL );
885+ nmatrix * result_x = nmatrix_new (matrix_b -> dtype , matrix_b -> stype , 1 , matrix_b -> count , matrix_b -> shape , NULL );
886886
887887 switch (matrix_a -> dtype ) {
888888 case nm_bool :
@@ -991,9 +991,6 @@ VALUE nm_gesv(int argc, VALUE* argv) {
991991 int n_b = matrix_b -> shape [1 ]; //no. of cols
992992 int lda_b = n_b ;
993993
994- bool lower = (bool )RTEST (argv [2 ]);
995- char uplo = lower ? 'L' : 'U' ;
996-
997994 nmatrix * result_lu = nmatrix_new (matrix_a -> dtype , matrix_a -> stype , 2 , matrix_a -> count , matrix_a -> shape , NULL );
998995 nmatrix * result_x = nmatrix_new (matrix_b -> dtype , matrix_b -> stype , 2 , matrix_b -> count , matrix_b -> shape , NULL );
999996 nmatrix * result_ipiv = nmatrix_new (nm_int , matrix_a -> stype , 1 , n_a , NULL , NULL );
@@ -1095,6 +1092,19 @@ VALUE nm_gesv(int argc, VALUE* argv) {
10951092 * the infinity norm, or the element of largest absolute value of a
10961093 * real matrix A.
10971094 *
1095+ * LANGE = ( max(abs(A(i,j))), NORM = 'M' or 'm'
1096+ * (
1097+ * ( norm1(A), NORM = '1', 'O' or 'o'
1098+ * (
1099+ * ( normI(A), NORM = 'I' or 'i'
1100+ * (
1101+ * ( normF(A), NORM = 'F', 'f', 'E' or 'e'
1102+ *
1103+ * where norm1 denotes the one norm of a matrix (maximum column sum),
1104+ * normI denotes the infinity norm of a matrix (maximum row sum) and
1105+ * normF denotes the Frobenius norm of a matrix (square root of sum of
1106+ * squares). Note that max(abs(A(i,j))) is not a consistent matrix norm.
1107+ *
10981108 */
10991109VALUE nm_lange (int argc , VALUE * argv ) {
11001110 nmatrix * matrix ;
@@ -1104,7 +1114,8 @@ VALUE nm_lange(int argc, VALUE* argv) {
11041114 int n = matrix -> shape [1 ]; //no. of cols
11051115 int lda = n ;
11061116
1107- char norm = NUM2CHAR (argv [1 ]);
1117+ char * norm_str = StringValueCStr (argv [1 ]);
1118+ char norm = norm_str [0 ];
11081119
11091120 switch (matrix -> dtype ) {
11101121 case nm_bool :
@@ -1131,13 +1142,13 @@ VALUE nm_lange(int argc, VALUE* argv) {
11311142 }
11321143 case nm_complex32 :
11331144 {
1134- float complex val = LAPACKE_clange (LAPACK_ROW_MAJOR , norm , m , n , matrix -> elements , lda );
1145+ float val = LAPACKE_clange (LAPACK_ROW_MAJOR , norm , m , n , matrix -> elements , lda );
11351146 return val ;
11361147 break ;
11371148 }
11381149 case nm_complex64 :
11391150 {
1140- double complex val = LAPACKE_zlange (LAPACK_ROW_MAJOR , norm , m , n , matrix -> elements , lda );
1151+ double val = LAPACKE_zlange (LAPACK_ROW_MAJOR , norm , m , n , matrix -> elements , lda );
11411152 return val ;
11421153 break ;
11431154 }
0 commit comments