Skip to content

Commit ade62b0

Browse files
committed
LAPACKE: allocate work array in ?lantr_work when row-major
1 parent 606b6eb commit ade62b0

File tree

4 files changed

+56
-4
lines changed

4 files changed

+56
-4
lines changed

LAPACKE/src/lapacke_clantr_work.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ float LAPACKE_clantr_work( int matrix_layout, char norm, char uplo,
4949
} else if( matrix_layout == LAPACK_ROW_MAJOR ) {
5050
lapack_int lda_t = MAX(1,m);
5151
lapack_complex_float* a_t = NULL;
52+
float* work_lapack = NULL;
5253
/* Check leading dimension(s) */
5354
if( lda < n ) {
5455
info = -8;
@@ -62,12 +63,24 @@ float LAPACKE_clantr_work( int matrix_layout, char norm, char uplo,
6263
info = LAPACK_TRANSPOSE_MEMORY_ERROR;
6364
goto exit_level_0;
6465
}
66+
/* Allocate memory for work array(s) */
67+
if( LAPACKE_lsame( norm, 'i' ) ) {
68+
work_lapack = (float*)LAPACKE_malloc( sizeof(float) * MAX(1,m) );
69+
if( work_lapack == NULL ) {
70+
info = LAPACK_WORK_MEMORY_ERROR;
71+
goto exit_level_1;
72+
}
73+
}
6574
/* Transpose input matrices */
6675
LAPACKE_ctr_trans( matrix_layout, uplo, diag, MAX(m,n), a, lda, a_t, lda_t );
6776
/* Call LAPACK function and adjust info */
68-
res = LAPACK_clantr( &norm, &uplo, &diag, &m, &n, a_t, &lda_t, work );
77+
res = LAPACK_clantr( &norm, &uplo, &diag, &m, &n, a_t, &lda_t, work_lapack );
6978
info = 0; /* LAPACK call is ok! */
7079
/* Release memory and exit */
80+
if( work_lapack ) {
81+
LAPACKE_free( work_lapack );
82+
}
83+
exit_level_1:
7184
LAPACKE_free( a_t );
7285
exit_level_0:
7386
if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {

LAPACKE/src/lapacke_dlantr_work.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ double LAPACKE_dlantr_work( int matrix_layout, char norm, char uplo,
4848
} else if( matrix_layout == LAPACK_ROW_MAJOR ) {
4949
lapack_int lda_t = MAX(1,m);
5050
double* a_t = NULL;
51+
double* work_lapack = NULL;
5152
/* Check leading dimension(s) */
5253
if( lda < n ) {
5354
info = -8;
@@ -60,12 +61,24 @@ double LAPACKE_dlantr_work( int matrix_layout, char norm, char uplo,
6061
info = LAPACK_TRANSPOSE_MEMORY_ERROR;
6162
goto exit_level_0;
6263
}
64+
/* Allocate memory for work array(s) */
65+
if( LAPACKE_lsame( norm, 'i' ) ) {
66+
work_lapack = (double*)LAPACKE_malloc( sizeof(double) * MAX(1,m) );
67+
if( work_lapack == NULL ) {
68+
info = LAPACK_WORK_MEMORY_ERROR;
69+
goto exit_level_1;
70+
}
71+
}
6372
/* Transpose input matrices */
6473
LAPACKE_dtr_trans( matrix_layout, uplo, diag, MAX(m,n), a, lda, a_t, lda_t );
6574
/* Call LAPACK function and adjust info */
66-
res = LAPACK_dlantr( &norm, &uplo, &diag, &m, &n, a_t, &lda_t, work );
75+
res = LAPACK_dlantr( &norm, &uplo, &diag, &m, &n, a_t, &lda_t, work_lapack );
6776
info = 0; /* LAPACK call is ok! */
6877
/* Release memory and exit */
78+
if( work_lapack ) {
79+
LAPACKE_free( work_lapack );
80+
}
81+
exit_level_1:
6982
LAPACKE_free( a_t );
7083
exit_level_0:
7184
if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {

LAPACKE/src/lapacke_slantr_work.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ float LAPACKE_slantr_work( int matrix_layout, char norm, char uplo,
4848
} else if( matrix_layout == LAPACK_ROW_MAJOR ) {
4949
lapack_int lda_t = MAX(1,m);
5050
float* a_t = NULL;
51+
float* work_lapack = NULL;
5152
/* Check leading dimension(s) */
5253
if( lda < n ) {
5354
info = -8;
@@ -60,12 +61,24 @@ float LAPACKE_slantr_work( int matrix_layout, char norm, char uplo,
6061
info = LAPACK_TRANSPOSE_MEMORY_ERROR;
6162
goto exit_level_0;
6263
}
64+
/* Allocate memory for work array(s) */
65+
if( LAPACKE_lsame( norm, 'i' ) ) {
66+
work_lapack = (float*)LAPACKE_malloc( sizeof(float) * MAX(1,m) );
67+
if( work_lapack == NULL ) {
68+
info = LAPACK_WORK_MEMORY_ERROR;
69+
goto exit_level_1;
70+
}
71+
}
6372
/* Transpose input matrices */
6473
LAPACKE_str_trans( matrix_layout, uplo, diag, MAX(m,n), a, lda, a_t, lda_t );
6574
/* Call LAPACK function and adjust info */
66-
res = LAPACK_slantr( &norm, &uplo, &diag, &m, &n, a_t, &lda_t, work );
75+
res = LAPACK_slantr( &norm, &uplo, &diag, &m, &n, a_t, &lda_t, work_lapack );
6776
info = 0; /* LAPACK call is ok! */
6877
/* Release memory and exit */
78+
if( work_lapack ) {
79+
LAPACKE_free( work_lapack );
80+
}
81+
exit_level_1:
6982
LAPACKE_free( a_t );
7083
exit_level_0:
7184
if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {

LAPACKE/src/lapacke_zlantr_work.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ double LAPACKE_zlantr_work( int matrix_layout, char norm, char uplo,
4949
} else if( matrix_layout == LAPACK_ROW_MAJOR ) {
5050
lapack_int lda_t = MAX(1,m);
5151
lapack_complex_double* a_t = NULL;
52+
double* work_lapack = NULL;
5253
/* Check leading dimension(s) */
5354
if( lda < n ) {
5455
info = -8;
@@ -62,12 +63,24 @@ double LAPACKE_zlantr_work( int matrix_layout, char norm, char uplo,
6263
info = LAPACK_TRANSPOSE_MEMORY_ERROR;
6364
goto exit_level_0;
6465
}
66+
/* Allocate memory for work array(s) */
67+
if( LAPACKE_lsame( norm, 'i' ) ) {
68+
work_lapack = (double*)LAPACKE_malloc( sizeof(double) * MAX(1,m) );
69+
if( work_lapack == NULL ) {
70+
info = LAPACK_WORK_MEMORY_ERROR;
71+
goto exit_level_1;
72+
}
73+
}
6574
/* Transpose input matrices */
6675
LAPACKE_ztr_trans( matrix_layout, uplo, diag, MAX(m,n), a, lda, a_t, lda_t );
6776
/* Call LAPACK function and adjust info */
68-
res = LAPACK_zlantr( &norm, &uplo, &diag, &m, &n, a_t, &lda_t, work );
77+
res = LAPACK_zlantr( &norm, &uplo, &diag, &m, &n, a_t, &lda_t, work_lapack );
6978
info = 0; /* LAPACK call is ok! */
7079
/* Release memory and exit */
80+
if( work_lapack ) {
81+
LAPACKE_free( work_lapack );
82+
}
83+
exit_level_1:
7184
LAPACKE_free( a_t );
7285
exit_level_0:
7386
if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {

0 commit comments

Comments
 (0)