00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #include "lapacke.h"
00035 #include "lapacke_utils.h"
00036
00037 lapack_int LAPACKE_ssyevr_work( int matrix_order, char jobz, char range,
00038 char uplo, lapack_int n, float* a,
00039 lapack_int lda, float vl, float vu,
00040 lapack_int il, lapack_int iu, float abstol,
00041 lapack_int* m, float* w, float* z,
00042 lapack_int ldz, lapack_int* isuppz, float* work,
00043 lapack_int lwork, lapack_int* iwork,
00044 lapack_int liwork )
00045 {
00046 lapack_int info = 0;
00047 if( matrix_order == LAPACK_COL_MAJOR ) {
00048
00049 LAPACK_ssyevr( &jobz, &range, &uplo, &n, a, &lda, &vl, &vu, &il, &iu,
00050 &abstol, m, w, z, &ldz, isuppz, work, &lwork, iwork,
00051 &liwork, &info );
00052 if( info < 0 ) {
00053 info = info - 1;
00054 }
00055 } else if( matrix_order == LAPACK_ROW_MAJOR ) {
00056 lapack_int ncols_z = ( LAPACKE_lsame( range, 'a' ) ||
00057 LAPACKE_lsame( range, 'v' ) ) ? n :
00058 ( LAPACKE_lsame( range, 'i' ) ? (iu-il+1) : 1);
00059 lapack_int lda_t = MAX(1,n);
00060 lapack_int ldz_t = MAX(1,n);
00061 float* a_t = NULL;
00062 float* z_t = NULL;
00063
00064 if( lda < n ) {
00065 info = -7;
00066 LAPACKE_xerbla( "LAPACKE_ssyevr_work", info );
00067 return info;
00068 }
00069 if( ldz < ncols_z ) {
00070 info = -16;
00071 LAPACKE_xerbla( "LAPACKE_ssyevr_work", info );
00072 return info;
00073 }
00074
00075 if( liwork == -1 || lwork == -1 ) {
00076 LAPACK_ssyevr( &jobz, &range, &uplo, &n, a, &lda_t, &vl, &vu, &il,
00077 &iu, &abstol, m, w, z, &ldz_t, isuppz, work, &lwork,
00078 iwork, &liwork, &info );
00079 return (info < 0) ? (info - 1) : info;
00080 }
00081
00082 a_t = (float*)LAPACKE_malloc( sizeof(float) * lda_t * MAX(1,n) );
00083 if( a_t == NULL ) {
00084 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00085 goto exit_level_0;
00086 }
00087 if( LAPACKE_lsame( jobz, 'v' ) ) {
00088 z_t = (float*)
00089 LAPACKE_malloc( sizeof(float) * ldz_t * MAX(1,ncols_z) );
00090 if( z_t == NULL ) {
00091 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00092 goto exit_level_1;
00093 }
00094 }
00095
00096 LAPACKE_ssy_trans( matrix_order, uplo, n, a, lda, a_t, lda_t );
00097
00098 LAPACK_ssyevr( &jobz, &range, &uplo, &n, a_t, &lda_t, &vl, &vu, &il,
00099 &iu, &abstol, m, w, z_t, &ldz_t, isuppz, work, &lwork,
00100 iwork, &liwork, &info );
00101 if( info < 0 ) {
00102 info = info - 1;
00103 }
00104
00105 LAPACKE_ssy_trans( LAPACK_COL_MAJOR, uplo, n, a_t, lda_t, a, lda );
00106 if( LAPACKE_lsame( jobz, 'v' ) ) {
00107 LAPACKE_sge_trans( LAPACK_COL_MAJOR, n, ncols_z, z_t, ldz_t, z,
00108 ldz );
00109 }
00110
00111 if( LAPACKE_lsame( jobz, 'v' ) ) {
00112 LAPACKE_free( z_t );
00113 }
00114 exit_level_1:
00115 LAPACKE_free( a_t );
00116 exit_level_0:
00117 if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
00118 LAPACKE_xerbla( "LAPACKE_ssyevr_work", info );
00119 }
00120 } else {
00121 info = -1;
00122 LAPACKE_xerbla( "LAPACKE_ssyevr_work", info );
00123 }
00124 return info;
00125 }