Skip to content

Commit 88d84a6

Browse files
authored
Merge pull request #373 from vladimir-ch/lapacke/lantr-alloc-work
LAPACKE: allocate new work array in ?lantr_work when row-major
2 parents 606b6eb + f703f87 commit 88d84a6

File tree

4 files changed

+56
-20
lines changed

4 files changed

+56
-20
lines changed

LAPACKE/src/lapacke_clantr_work.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,10 @@ float LAPACKE_clantr_work( int matrix_layout, char norm, char uplo,
4343
if( matrix_layout == LAPACK_COL_MAJOR ) {
4444
/* Call LAPACK function and adjust info */
4545
res = LAPACK_clantr( &norm, &uplo, &diag, &m, &n, a, &lda, work );
46-
if( info < 0 ) {
47-
info = info - 1;
48-
}
4946
} else if( matrix_layout == LAPACK_ROW_MAJOR ) {
5047
lapack_int lda_t = MAX(1,m);
5148
lapack_complex_float* a_t = NULL;
49+
float* work_lapack = NULL;
5250
/* Check leading dimension(s) */
5351
if( lda < n ) {
5452
info = -8;
@@ -62,12 +60,23 @@ float LAPACKE_clantr_work( int matrix_layout, char norm, char uplo,
6260
info = LAPACK_TRANSPOSE_MEMORY_ERROR;
6361
goto exit_level_0;
6462
}
63+
/* Allocate memory for work array(s) */
64+
if( LAPACKE_lsame( norm, 'i' ) ) {
65+
work_lapack = (float*)LAPACKE_malloc( sizeof(float) * MAX(1,m) );
66+
if( work_lapack == NULL ) {
67+
info = LAPACK_WORK_MEMORY_ERROR;
68+
goto exit_level_1;
69+
}
70+
}
6571
/* Transpose input matrices */
6672
LAPACKE_ctr_trans( matrix_layout, uplo, diag, MAX(m,n), a, lda, a_t, lda_t );
6773
/* Call LAPACK function and adjust info */
68-
res = LAPACK_clantr( &norm, &uplo, &diag, &m, &n, a_t, &lda_t, work );
69-
info = 0; /* LAPACK call is ok! */
74+
res = LAPACK_clantr( &norm, &uplo, &diag, &m, &n, a_t, &lda_t, work_lapack );
7075
/* Release memory and exit */
76+
if( work_lapack ) {
77+
LAPACKE_free( work_lapack );
78+
}
79+
exit_level_1:
7180
LAPACKE_free( a_t );
7281
exit_level_0:
7382
if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {

LAPACKE/src/lapacke_dlantr_work.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,10 @@ double LAPACKE_dlantr_work( int matrix_layout, char norm, char uplo,
4242
if( matrix_layout == LAPACK_COL_MAJOR ) {
4343
/* Call LAPACK function and adjust info */
4444
res = LAPACK_dlantr( &norm, &uplo, &diag, &m, &n, a, &lda, work );
45-
if( info < 0 ) {
46-
info = info - 1;
47-
}
4845
} else if( matrix_layout == LAPACK_ROW_MAJOR ) {
4946
lapack_int lda_t = MAX(1,m);
5047
double* a_t = NULL;
48+
double* work_lapack = NULL;
5149
/* Check leading dimension(s) */
5250
if( lda < n ) {
5351
info = -8;
@@ -60,12 +58,23 @@ double LAPACKE_dlantr_work( int matrix_layout, char norm, char uplo,
6058
info = LAPACK_TRANSPOSE_MEMORY_ERROR;
6159
goto exit_level_0;
6260
}
61+
/* Allocate memory for work array(s) */
62+
if( LAPACKE_lsame( norm, 'i' ) ) {
63+
work_lapack = (double*)LAPACKE_malloc( sizeof(double) * MAX(1,m) );
64+
if( work_lapack == NULL ) {
65+
info = LAPACK_WORK_MEMORY_ERROR;
66+
goto exit_level_1;
67+
}
68+
}
6369
/* Transpose input matrices */
6470
LAPACKE_dtr_trans( matrix_layout, uplo, diag, MAX(m,n), a, lda, a_t, lda_t );
6571
/* Call LAPACK function and adjust info */
66-
res = LAPACK_dlantr( &norm, &uplo, &diag, &m, &n, a_t, &lda_t, work );
67-
info = 0; /* LAPACK call is ok! */
72+
res = LAPACK_dlantr( &norm, &uplo, &diag, &m, &n, a_t, &lda_t, work_lapack );
6873
/* Release memory and exit */
74+
if( work_lapack ) {
75+
LAPACKE_free( work_lapack );
76+
}
77+
exit_level_1:
6978
LAPACKE_free( a_t );
7079
exit_level_0:
7180
if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {

LAPACKE/src/lapacke_slantr_work.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,10 @@ float LAPACKE_slantr_work( int matrix_layout, char norm, char uplo,
4242
if( matrix_layout == LAPACK_COL_MAJOR ) {
4343
/* Call LAPACK function and adjust info */
4444
res = LAPACK_slantr( &norm, &uplo, &diag, &m, &n, a, &lda, work );
45-
if( info < 0 ) {
46-
info = info - 1;
47-
}
4845
} else if( matrix_layout == LAPACK_ROW_MAJOR ) {
4946
lapack_int lda_t = MAX(1,m);
5047
float* a_t = NULL;
48+
float* work_lapack = NULL;
5149
/* Check leading dimension(s) */
5250
if( lda < n ) {
5351
info = -8;
@@ -60,12 +58,23 @@ float LAPACKE_slantr_work( int matrix_layout, char norm, char uplo,
6058
info = LAPACK_TRANSPOSE_MEMORY_ERROR;
6159
goto exit_level_0;
6260
}
61+
/* Allocate memory for work array(s) */
62+
if( LAPACKE_lsame( norm, 'i' ) ) {
63+
work_lapack = (float*)LAPACKE_malloc( sizeof(float) * MAX(1,m) );
64+
if( work_lapack == NULL ) {
65+
info = LAPACK_WORK_MEMORY_ERROR;
66+
goto exit_level_1;
67+
}
68+
}
6369
/* Transpose input matrices */
6470
LAPACKE_str_trans( matrix_layout, uplo, diag, MAX(m,n), a, lda, a_t, lda_t );
6571
/* Call LAPACK function and adjust info */
66-
res = LAPACK_slantr( &norm, &uplo, &diag, &m, &n, a_t, &lda_t, work );
67-
info = 0; /* LAPACK call is ok! */
72+
res = LAPACK_slantr( &norm, &uplo, &diag, &m, &n, a_t, &lda_t, work_lapack );
6873
/* Release memory and exit */
74+
if( work_lapack ) {
75+
LAPACKE_free( work_lapack );
76+
}
77+
exit_level_1:
6978
LAPACKE_free( a_t );
7079
exit_level_0:
7180
if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {

LAPACKE/src/lapacke_zlantr_work.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,10 @@ double LAPACKE_zlantr_work( int matrix_layout, char norm, char uplo,
4343
if( matrix_layout == LAPACK_COL_MAJOR ) {
4444
/* Call LAPACK function and adjust info */
4545
res = LAPACK_zlantr( &norm, &uplo, &diag, &m, &n, a, &lda, work );
46-
if( info < 0 ) {
47-
info = info - 1;
48-
}
4946
} else if( matrix_layout == LAPACK_ROW_MAJOR ) {
5047
lapack_int lda_t = MAX(1,m);
5148
lapack_complex_double* a_t = NULL;
49+
double* work_lapack = NULL;
5250
/* Check leading dimension(s) */
5351
if( lda < n ) {
5452
info = -8;
@@ -62,12 +60,23 @@ double LAPACKE_zlantr_work( int matrix_layout, char norm, char uplo,
6260
info = LAPACK_TRANSPOSE_MEMORY_ERROR;
6361
goto exit_level_0;
6462
}
63+
/* Allocate memory for work array(s) */
64+
if( LAPACKE_lsame( norm, 'i' ) ) {
65+
work_lapack = (double*)LAPACKE_malloc( sizeof(double) * MAX(1,m) );
66+
if( work_lapack == NULL ) {
67+
info = LAPACK_WORK_MEMORY_ERROR;
68+
goto exit_level_1;
69+
}
70+
}
6571
/* Transpose input matrices */
6672
LAPACKE_ztr_trans( matrix_layout, uplo, diag, MAX(m,n), a, lda, a_t, lda_t );
6773
/* Call LAPACK function and adjust info */
68-
res = LAPACK_zlantr( &norm, &uplo, &diag, &m, &n, a_t, &lda_t, work );
69-
info = 0; /* LAPACK call is ok! */
74+
res = LAPACK_zlantr( &norm, &uplo, &diag, &m, &n, a_t, &lda_t, work_lapack );
7075
/* Release memory and exit */
76+
if( work_lapack ) {
77+
LAPACKE_free( work_lapack );
78+
}
79+
exit_level_1:
7180
LAPACKE_free( a_t );
7281
exit_level_0:
7382
if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {

0 commit comments

Comments
 (0)