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_dsygvx_work( int matrix_order, lapack_int itype, char jobz,
00038 char range, char uplo, lapack_int n, double* a,
00039 lapack_int lda, double* b, lapack_int ldb,
00040 double vl, double vu, lapack_int il,
00041 lapack_int iu, double abstol, lapack_int* m,
00042 double* w, double* z, lapack_int ldz,
00043 double* work, lapack_int lwork,
00044 lapack_int* iwork, lapack_int* ifail )
00045 {
00046 lapack_int info = 0;
00047 if( matrix_order == LAPACK_COL_MAJOR ) {
00048
00049 LAPACK_dsygvx( &itype, &jobz, &range, &uplo, &n, a, &lda, b, &ldb, &vl,
00050 &vu, &il, &iu, &abstol, m, w, z, &ldz, work, &lwork,
00051 iwork, ifail, &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 ldb_t = MAX(1,n);
00061 lapack_int ldz_t = MAX(1,n);
00062 double* a_t = NULL;
00063 double* b_t = NULL;
00064 double* z_t = NULL;
00065
00066 if( lda < n ) {
00067 info = -8;
00068 LAPACKE_xerbla( "LAPACKE_dsygvx_work", info );
00069 return info;
00070 }
00071 if( ldb < n ) {
00072 info = -10;
00073 LAPACKE_xerbla( "LAPACKE_dsygvx_work", info );
00074 return info;
00075 }
00076 if( ldz < ncols_z ) {
00077 info = -19;
00078 LAPACKE_xerbla( "LAPACKE_dsygvx_work", info );
00079 return info;
00080 }
00081
00082 if( lwork == -1 ) {
00083 LAPACK_dsygvx( &itype, &jobz, &range, &uplo, &n, a, &lda_t, b,
00084 &ldb_t, &vl, &vu, &il, &iu, &abstol, m, w, z, &ldz_t,
00085 work, &lwork, iwork, ifail, &info );
00086 return (info < 0) ? (info - 1) : info;
00087 }
00088
00089 a_t = (double*)LAPACKE_malloc( sizeof(double) * lda_t * MAX(1,n) );
00090 if( a_t == NULL ) {
00091 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00092 goto exit_level_0;
00093 }
00094 b_t = (double*)LAPACKE_malloc( sizeof(double) * ldb_t * MAX(1,n) );
00095 if( b_t == NULL ) {
00096 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00097 goto exit_level_1;
00098 }
00099 if( LAPACKE_lsame( jobz, 'v' ) ) {
00100 z_t = (double*)
00101 LAPACKE_malloc( sizeof(double) * ldz_t * MAX(1,ncols_z) );
00102 if( z_t == NULL ) {
00103 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00104 goto exit_level_2;
00105 }
00106 }
00107
00108 LAPACKE_dsy_trans( matrix_order, uplo, n, a, lda, a_t, lda_t );
00109 LAPACKE_dge_trans( matrix_order, n, n, b, ldb, b_t, ldb_t );
00110
00111 LAPACK_dsygvx( &itype, &jobz, &range, &uplo, &n, a_t, &lda_t, b_t,
00112 &ldb_t, &vl, &vu, &il, &iu, &abstol, m, w, z_t, &ldz_t,
00113 work, &lwork, iwork, ifail, &info );
00114 if( info < 0 ) {
00115 info = info - 1;
00116 }
00117
00118 LAPACKE_dsy_trans( LAPACK_COL_MAJOR, uplo, n, a_t, lda_t, a, lda );
00119 LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, n, b_t, ldb_t, b, ldb );
00120 if( LAPACKE_lsame( jobz, 'v' ) ) {
00121 LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, ncols_z, z_t, ldz_t, z,
00122 ldz );
00123 }
00124
00125 if( LAPACKE_lsame( jobz, 'v' ) ) {
00126 LAPACKE_free( z_t );
00127 }
00128 exit_level_2:
00129 LAPACKE_free( b_t );
00130 exit_level_1:
00131 LAPACKE_free( a_t );
00132 exit_level_0:
00133 if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
00134 LAPACKE_xerbla( "LAPACKE_dsygvx_work", info );
00135 }
00136 } else {
00137 info = -1;
00138 LAPACKE_xerbla( "LAPACKE_dsygvx_work", info );
00139 }
00140 return info;
00141 }