Fix bug 137 and 138 submitted by Dan Kortschak
authorjulie <julielangou@users.noreply.github.com>
Thu, 22 Oct 2015 05:29:34 +0000 (05:29 +0000)
committerjulie <julielangou@users.noreply.github.com>
Thu, 22 Oct 2015 05:29:34 +0000 (05:29 +0000)
Applied patch submitted by Dan Kortschak

LAPACKE/src/lapacke_clantr.c
LAPACKE/src/lapacke_clantr_work.c
LAPACKE/src/lapacke_dlantr.c
LAPACKE/src/lapacke_dlantr_work.c
LAPACKE/src/lapacke_slantr.c
LAPACKE/src/lapacke_slantr_work.c
LAPACKE/src/lapacke_zlantr.c
LAPACKE/src/lapacke_zlantr_work.c

index 36ae597..fe123cf 100644 (file)
@@ -53,7 +53,7 @@ float LAPACKE_clantr( int matrix_layout, char norm, char uplo, char diag,
     /* Allocate memory for working array(s) */
     if( LAPACKE_lsame( norm, 'i' ) || LAPACKE_lsame( norm, '1' ) ||
         LAPACKE_lsame( norm, 'O' ) ) {
-        work = (float*)LAPACKE_malloc( sizeof(float) * MAX(1,m) );
+        work = (float*)LAPACKE_malloc( sizeof(float) * MAX(1,MAX(m,n)) );
         if( work == NULL ) {
             info = LAPACK_WORK_MEMORY_ERROR;
             goto exit_level_0;
index 2ac7e88..5c4ba5e 100644 (file)
@@ -47,7 +47,7 @@ float LAPACKE_clantr_work( int matrix_layout, char norm, char uplo,
             info = info - 1;
         }
     } else if( matrix_layout == LAPACK_ROW_MAJOR ) {
-        lapack_int lda_t = MAX(1,n);
+        lapack_int lda_t = MAX(1,m);
         lapack_complex_float* a_t = NULL;
         /* Check leading dimension(s) */
         if( lda < n ) {
@@ -57,13 +57,13 @@ float LAPACKE_clantr_work( int matrix_layout, char norm, char uplo,
         }
         /* Allocate memory for temporary array(s) */
         a_t = (lapack_complex_float*)
-            LAPACKE_malloc( sizeof(lapack_complex_float) * lda_t * MAX(1,n) );
+            LAPACKE_malloc( sizeof(lapack_complex_float) * lda_t * MAX(1,MAX(m,n)) );
         if( a_t == NULL ) {
             info = LAPACK_TRANSPOSE_MEMORY_ERROR;
             goto exit_level_0;
         }
         /* Transpose input matrices */
-        LAPACKE_ctr_trans( matrix_layout, uplo, diag, n, a, lda, a_t, lda_t );
+        LAPACKE_ctr_trans( matrix_layout, uplo, diag, MAX(m,n), a, lda, a_t, lda_t );
         /* Call LAPACK function and adjust info */
         res = LAPACK_clantr( &norm, &uplo, &diag, &m, &n, a_t, &lda_t, work );
         info = 0;  /* LAPACK call is ok! */
index 7ac947f..9f66725 100644 (file)
@@ -53,7 +53,7 @@ double LAPACKE_dlantr( int matrix_layout, char norm, char uplo, char diag,
     /* Allocate memory for working array(s) */
     if( LAPACKE_lsame( norm, 'i' ) || LAPACKE_lsame( norm, '1' ) ||
         LAPACKE_lsame( norm, 'O' ) ) {
-        work = (double*)LAPACKE_malloc( sizeof(double) * MAX(1,m) );
+        work = (double*)LAPACKE_malloc( sizeof(double) * MAX(1,MAX(m,n)) );
         if( work == NULL ) {
             info = LAPACK_WORK_MEMORY_ERROR;
             goto exit_level_0;
index e390c18..ccd37f2 100644 (file)
@@ -46,7 +46,7 @@ double LAPACKE_dlantr_work( int matrix_layout, char norm, char uplo,
             info = info - 1;
         }
     } else if( matrix_layout == LAPACK_ROW_MAJOR ) {
-        lapack_int lda_t = MAX(1,n);
+        lapack_int lda_t = MAX(1,m);
         double* a_t = NULL;
         /* Check leading dimension(s) */
         if( lda < n ) {
@@ -55,13 +55,13 @@ double LAPACKE_dlantr_work( int matrix_layout, char norm, char uplo,
             return info;
         }
         /* Allocate memory for temporary array(s) */
-        a_t = (double*)LAPACKE_malloc( sizeof(double) * lda_t * MAX(1,n) );
+        a_t = (double*)LAPACKE_malloc( sizeof(double) * lda_t * MAX(1,MAX(m,n)) );
         if( a_t == NULL ) {
             info = LAPACK_TRANSPOSE_MEMORY_ERROR;
             goto exit_level_0;
         }
         /* Transpose input matrices */
-        LAPACKE_dtr_trans( matrix_layout, uplo, diag, n, a, lda, a_t, lda_t );
+        LAPACKE_dtr_trans( matrix_layout, uplo, diag, MAX(m,n), a, lda, a_t, lda_t );
         /* Call LAPACK function and adjust info */
         res = LAPACK_dlantr( &norm, &uplo, &diag, &m, &n, a_t, &lda_t, work );
         info = 0;  /* LAPACK call is ok! */
index 6952bd9..daa4bca 100644 (file)
@@ -53,7 +53,7 @@ float LAPACKE_slantr( int matrix_layout, char norm, char uplo, char diag,
     /* Allocate memory for working array(s) */
     if( LAPACKE_lsame( norm, 'i' ) || LAPACKE_lsame( norm, '1' ) ||
         LAPACKE_lsame( norm, 'O' ) ) {
-        work = (float*)LAPACKE_malloc( sizeof(float) * MAX(1,m) );
+        work = (float*)LAPACKE_malloc( sizeof(float) * MAX(1,MAX(m,n)) );
         if( work == NULL ) {
             info = LAPACK_WORK_MEMORY_ERROR;
             goto exit_level_0;
index 6f5c0ad..75a33f1 100644 (file)
@@ -46,7 +46,7 @@ float LAPACKE_slantr_work( int matrix_layout, char norm, char uplo,
             info = info - 1;
         }
     } else if( matrix_layout == LAPACK_ROW_MAJOR ) {
-        lapack_int lda_t = MAX(1,n);
+        lapack_int lda_t = MAX(1,m);
         float* a_t = NULL;
         /* Check leading dimension(s) */
         if( lda < n ) {
@@ -55,13 +55,13 @@ float LAPACKE_slantr_work( int matrix_layout, char norm, char uplo,
             return info;
         }
         /* Allocate memory for temporary array(s) */
-        a_t = (float*)LAPACKE_malloc( sizeof(float) * lda_t * MAX(1,n) );
+        a_t = (float*)LAPACKE_malloc( sizeof(float) * lda_t * MAX(1,MAX(m,n)) );
         if( a_t == NULL ) {
             info = LAPACK_TRANSPOSE_MEMORY_ERROR;
             goto exit_level_0;
         }
         /* Transpose input matrices */
-        LAPACKE_str_trans( matrix_layout, uplo, diag, n, a, lda, a_t, lda_t );
+        LAPACKE_str_trans( matrix_layout, uplo, diag, MAX(m,n), a, lda, a_t, lda_t );
         /* Call LAPACK function and adjust info */
         res = LAPACK_slantr( &norm, &uplo, &diag, &m, &n, a_t, &lda_t, work );
         info = 0;  /* LAPACK call is ok! */
index 37b4054..65339a5 100644 (file)
@@ -53,7 +53,7 @@ double LAPACKE_zlantr( int matrix_layout, char norm, char uplo, char diag,
     /* Allocate memory for working array(s) */
     if( LAPACKE_lsame( norm, 'i' ) || LAPACKE_lsame( norm, '1' ) ||
         LAPACKE_lsame( norm, 'O' ) ) {
-        work = (double*)LAPACKE_malloc( sizeof(double) * MAX(1,m) );
+        work = (double*)LAPACKE_malloc( sizeof(double) * MAX(1,MAX(m,n)) );
         if( work == NULL ) {
             info = LAPACK_WORK_MEMORY_ERROR;
             goto exit_level_0;
index e9f0036..3a924de 100644 (file)
@@ -47,7 +47,7 @@ double LAPACKE_zlantr_work( int matrix_layout, char norm, char uplo,
             info = info - 1;
         }
     } else if( matrix_layout == LAPACK_ROW_MAJOR ) {
-        lapack_int lda_t = MAX(1,n);
+        lapack_int lda_t = MAX(1,m);
         lapack_complex_double* a_t = NULL;
         /* Check leading dimension(s) */
         if( lda < n ) {
@@ -57,13 +57,13 @@ double LAPACKE_zlantr_work( int matrix_layout, char norm, char uplo,
         }
         /* Allocate memory for temporary array(s) */
         a_t = (lapack_complex_double*)
-            LAPACKE_malloc( sizeof(lapack_complex_double) * lda_t * MAX(1,n) );
+            LAPACKE_malloc( sizeof(lapack_complex_double) * lda_t * MAX(1,MAX(m,n)) );
         if( a_t == NULL ) {
             info = LAPACK_TRANSPOSE_MEMORY_ERROR;
             goto exit_level_0;
         }
         /* Transpose input matrices */
-        LAPACKE_ztr_trans( matrix_layout, uplo, diag, n, a, lda, a_t, lda_t );
+        LAPACKE_ztr_trans( matrix_layout, uplo, diag, MAX(m,n), a, lda, a_t, lda_t );
         /* Call LAPACK function and adjust info */
         res = LAPACK_zlantr( &norm, &uplo, &diag, &m, &n, a_t, &lda_t, work );
         info = 0;  /* LAPACK call is ok! */