Skip to content

Commit 7d5bb9e

Browse files
My last commit contained some errors. LAPACKE interfaces typically handle row-major
layout by transposing the matrix into a temporary array, and then transposing the result back into the originally matrix after the computations have completed. So, in the case where eigenvectors are requested, the entire matrix will be overwritten with the eigenvectors, meaning that we need to copy the entire result back after computations have completed. We changed the interface to copy the entire result back after the computation is done when eigenvectors are requested.
1 parent 2bffa8c commit 7d5bb9e

12 files changed

Lines changed: 60 additions & 13 deletions

LAPACKE/src/lapacke_cheev_work.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ lapack_int LAPACKE_cheev_work( int matrix_layout, char jobz, char uplo,
7878
info = info - 1;
7979
}
8080
/* Transpose output matrices */
81-
LAPACKE_che_trans( LAPACK_COL_MAJOR, uplo, n, a_t, lda_t, a, lda );
81+
if ( jobz == 'V') {
82+
LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, n, a_t, lda_t, a, lda );
83+
} else {
84+
LAPACKE_che_trans( LAPACK_COL_MAJOR, uplo, n, a_t, lda_t, a, lda );
85+
}
8286
/* Release memory and exit */
8387
LAPACKE_free( a_t );
8488
exit_level_0:

LAPACKE/src/lapacke_cheevd_2stage_work.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@ lapack_int LAPACKE_cheevd_2stage_work( int matrix_layout, char jobz, char uplo,
7979
info = info - 1;
8080
}
8181
/* Transpose output matrices */
82-
LAPACKE_che_trans( LAPACK_COL_MAJOR, uplo, n, a_t, lda_t, a, lda );
82+
if ( jobz == 'V') {
83+
LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, n, a_t, lda_t, a, lda );
84+
} else {
85+
LAPACKE_che_trans( LAPACK_COL_MAJOR, uplo, n, a_t, lda_t, a, lda );
86+
}
8387
/* Release memory and exit */
8488
LAPACKE_free( a_t );
8589
exit_level_0:

LAPACKE/src/lapacke_cheevd_work.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,11 @@ lapack_int LAPACKE_cheevd_work( int matrix_layout, char jobz, char uplo,
7979
info = info - 1;
8080
}
8181
/* Transpose output matrices */
82-
LAPACKE_che_trans( LAPACK_COL_MAJOR, uplo, n, a_t, lda_t, a, lda );
83-
82+
if ( jobz == 'V') {
83+
LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, n, a_t, lda_t, a, lda );
84+
} else {
85+
LAPACKE_che_trans( LAPACK_COL_MAJOR, uplo, n, a_t, lda_t, a, lda );
86+
}
8487
/* Release memory and exit */
8588
LAPACKE_free( a_t );
8689
exit_level_0:

LAPACKE/src/lapacke_dsyev_work.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,11 @@ lapack_int LAPACKE_dsyev_work( int matrix_layout, char jobz, char uplo,
7272
info = info - 1;
7373
}
7474
/* Transpose output matrices */
75-
LAPACKE_dsy_trans( LAPACK_COL_MAJOR, uplo, n, a_t, lda_t, a, lda );
75+
if ( jobz == 'V') {
76+
LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, n, a_t, lda_t, a, lda );
77+
} else {
78+
LAPACKE_dsy_trans( LAPACK_COL_MAJOR, uplo, n, a_t, lda_t, a, lda );
79+
}
7680
/* Release memory and exit */
7781
LAPACKE_free( a_t );
7882
exit_level_0:

LAPACKE/src/lapacke_dsyevd_2stage_work.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,11 @@ lapack_int LAPACKE_dsyevd_2stage_work( int matrix_layout, char jobz, char uplo,
7676
info = info - 1;
7777
}
7878
/* Transpose output matrices */
79-
LAPACKE_dsy_trans( LAPACK_COL_MAJOR, uplo, n, a_t, lda_t, a, lda );
79+
if ( jobz == 'V') {
80+
LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, n, a_t, lda_t, a, lda );
81+
} else {
82+
LAPACKE_dsy_trans( LAPACK_COL_MAJOR, uplo, n, a_t, lda_t, a, lda );
83+
}
8084
/* Release memory and exit */
8185
LAPACKE_free( a_t );
8286
exit_level_0:

LAPACKE/src/lapacke_dsyevd_work.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,11 @@ lapack_int LAPACKE_dsyevd_work( int matrix_layout, char jobz, char uplo,
7676
info = info - 1;
7777
}
7878
/* Transpose output matrices */
79-
LAPACKE_dsy_trans( LAPACK_COL_MAJOR, uplo, n, a_t, lda_t, a, lda );
79+
if ( jobz == 'V') {
80+
LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, n, a_t, lda_t, a, lda );
81+
} else {
82+
LAPACKE_dsy_trans( LAPACK_COL_MAJOR, uplo, n, a_t, lda_t, a, lda );
83+
}
8084
/* Release memory and exit */
8185
LAPACKE_free( a_t );
8286
exit_level_0:

LAPACKE/src/lapacke_ssyev_work.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,11 @@ lapack_int LAPACKE_ssyev_work( int matrix_layout, char jobz, char uplo,
7272
info = info - 1;
7373
}
7474
/* Transpose output matrices */
75-
LAPACKE_ssy_trans( LAPACK_COL_MAJOR, uplo, n, a_t, lda_t, a, lda );
75+
if ( jobz == 'V') {
76+
LAPACKE_sge_trans( LAPACK_COL_MAJOR, n, n, a_t, lda_t, a, lda );
77+
} else {
78+
LAPACKE_ssy_trans( LAPACK_COL_MAJOR, uplo, n, a_t, lda_t, a, lda );
79+
}
7680
/* Release memory and exit */
7781
LAPACKE_free( a_t );
7882
exit_level_0:

LAPACKE/src/lapacke_ssyevd_2stage_work.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,11 @@ lapack_int LAPACKE_ssyevd_2stage_work( int matrix_layout, char jobz, char uplo,
7676
info = info - 1;
7777
}
7878
/* Transpose output matrices */
79-
LAPACKE_ssy_trans( LAPACK_COL_MAJOR, uplo, n, a_t, lda_t, a, lda );
79+
if ( jobz == 'V') {
80+
LAPACKE_sge_trans( LAPACK_COL_MAJOR, n, n, a_t, lda_t, a, lda );
81+
} else {
82+
LAPACKE_ssy_trans( LAPACK_COL_MAJOR, uplo, n, a_t, lda_t, a, lda );
83+
}
8084
/* Release memory and exit */
8185
LAPACKE_free( a_t );
8286
exit_level_0:

LAPACKE/src/lapacke_ssyevd_work.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,11 @@ lapack_int LAPACKE_ssyevd_work( int matrix_layout, char jobz, char uplo,
7676
info = info - 1;
7777
}
7878
/* Transpose output matrices */
79-
LAPACKE_ssy_trans( LAPACK_COL_MAJOR, uplo, n, a_t, lda_t, a, lda );
79+
if ( jobz == 'V') {
80+
LAPACKE_sge_trans( LAPACK_COL_MAJOR, n, n, a_t, lda_t, a, lda );
81+
} else {
82+
LAPACKE_ssy_trans( LAPACK_COL_MAJOR, uplo, n, a_t, lda_t, a, lda );
83+
}
8084
/* Release memory and exit */
8185
LAPACKE_free( a_t );
8286
exit_level_0:

LAPACKE/src/lapacke_zheev_work.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ lapack_int LAPACKE_zheev_work( int matrix_layout, char jobz, char uplo,
7878
info = info - 1;
7979
}
8080
/* Transpose output matrices */
81-
LAPACKE_zhe_trans( LAPACK_COL_MAJOR, uplo, n, a_t, lda_t, a, lda );
81+
if ( jobz == 'V') {
82+
LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, n, a_t, lda_t, a, lda );
83+
} else {
84+
LAPACKE_zhe_trans( LAPACK_COL_MAJOR, uplo, n, a_t, lda_t, a, lda );
85+
}
8286
/* Release memory and exit */
8387
LAPACKE_free( a_t );
8488
exit_level_0:

0 commit comments

Comments
 (0)