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_dspgvx_work( int matrix_order, lapack_int itype, char jobz,
00038 char range, char uplo, lapack_int n, double* ap,
00039 double* bp, double vl, double vu, lapack_int il,
00040 lapack_int iu, double abstol, lapack_int* m,
00041 double* w, double* z, lapack_int ldz,
00042 double* work, lapack_int* iwork,
00043 lapack_int* ifail )
00044 {
00045 lapack_int info = 0;
00046 if( matrix_order == LAPACK_COL_MAJOR ) {
00047
00048 LAPACK_dspgvx( &itype, &jobz, &range, &uplo, &n, ap, bp, &vl, &vu, &il,
00049 &iu, &abstol, m, w, z, &ldz, work, iwork, ifail, &info );
00050 if( info < 0 ) {
00051 info = info - 1;
00052 }
00053 } else if( matrix_order == LAPACK_ROW_MAJOR ) {
00054 lapack_int ncols_z = ( LAPACKE_lsame( range, 'a' ) ||
00055 LAPACKE_lsame( range, 'v' ) ) ? n :
00056 ( LAPACKE_lsame( range, 'i' ) ? (iu-il+1) : 1);
00057 lapack_int ldz_t = MAX(1,n);
00058 double* z_t = NULL;
00059 double* ap_t = NULL;
00060 double* bp_t = NULL;
00061
00062 if( ldz < ncols_z ) {
00063 info = -17;
00064 LAPACKE_xerbla( "LAPACKE_dspgvx_work", info );
00065 return info;
00066 }
00067
00068 if( LAPACKE_lsame( jobz, 'v' ) ) {
00069 z_t = (double*)
00070 LAPACKE_malloc( sizeof(double) * ldz_t * MAX(1,ncols_z) );
00071 if( z_t == NULL ) {
00072 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00073 goto exit_level_0;
00074 }
00075 }
00076 ap_t = (double*)
00077 LAPACKE_malloc( sizeof(double) * ( MAX(1,n) * MAX(2,n+1) ) / 2 );
00078 if( ap_t == NULL ) {
00079 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00080 goto exit_level_1;
00081 }
00082 bp_t = (double*)
00083 LAPACKE_malloc( sizeof(double) * ( MAX(1,n) * MAX(2,n+1) ) / 2 );
00084 if( bp_t == NULL ) {
00085 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00086 goto exit_level_2;
00087 }
00088
00089 LAPACKE_dsp_trans( matrix_order, uplo, n, ap, ap_t );
00090 LAPACKE_dsp_trans( matrix_order, uplo, n, bp, bp_t );
00091
00092 LAPACK_dspgvx( &itype, &jobz, &range, &uplo, &n, ap_t, bp_t, &vl, &vu,
00093 &il, &iu, &abstol, m, w, z_t, &ldz_t, work, iwork, ifail,
00094 &info );
00095 if( info < 0 ) {
00096 info = info - 1;
00097 }
00098
00099 if( LAPACKE_lsame( jobz, 'v' ) ) {
00100 LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, ncols_z, z_t, ldz_t, z,
00101 ldz );
00102 }
00103 LAPACKE_dsp_trans( LAPACK_COL_MAJOR, uplo, n, ap_t, ap );
00104 LAPACKE_dsp_trans( LAPACK_COL_MAJOR, uplo, n, bp_t, bp );
00105
00106 LAPACKE_free( bp_t );
00107 exit_level_2:
00108 LAPACKE_free( ap_t );
00109 exit_level_1:
00110 if( LAPACKE_lsame( jobz, 'v' ) ) {
00111 LAPACKE_free( z_t );
00112 }
00113 exit_level_0:
00114 if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
00115 LAPACKE_xerbla( "LAPACKE_dspgvx_work", info );
00116 }
00117 } else {
00118 info = -1;
00119 LAPACKE_xerbla( "LAPACKE_dspgvx_work", info );
00120 }
00121 return info;
00122 }