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_zhpevx_work( int matrix_order, char jobz, char range,
00038 char uplo, lapack_int n,
00039 lapack_complex_double* ap, double vl, double vu,
00040 lapack_int il, lapack_int iu, double abstol,
00041 lapack_int* m, double* w,
00042 lapack_complex_double* z, lapack_int ldz,
00043 lapack_complex_double* work, double* rwork,
00044 lapack_int* iwork, lapack_int* ifail )
00045 {
00046 lapack_int info = 0;
00047 if( matrix_order == LAPACK_COL_MAJOR ) {
00048
00049 LAPACK_zhpevx( &jobz, &range, &uplo, &n, ap, &vl, &vu, &il, &iu,
00050 &abstol, m, w, z, &ldz, work, rwork, iwork, ifail,
00051 &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 ldz_t = MAX(1,n);
00060 lapack_complex_double* z_t = NULL;
00061 lapack_complex_double* ap_t = NULL;
00062
00063 if( ldz < ncols_z ) {
00064 info = -15;
00065 LAPACKE_xerbla( "LAPACKE_zhpevx_work", info );
00066 return info;
00067 }
00068
00069 if( LAPACKE_lsame( jobz, 'v' ) ) {
00070 z_t = (lapack_complex_double*)
00071 LAPACKE_malloc( sizeof(lapack_complex_double) *
00072 ldz_t * MAX(1,ncols_z) );
00073 if( z_t == NULL ) {
00074 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00075 goto exit_level_0;
00076 }
00077 }
00078 ap_t = (lapack_complex_double*)
00079 LAPACKE_malloc( sizeof(lapack_complex_double) *
00080 ( MAX(1,n) * MAX(2,n+1) ) / 2 );
00081 if( ap_t == NULL ) {
00082 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00083 goto exit_level_1;
00084 }
00085
00086 LAPACKE_zhp_trans( matrix_order, uplo, n, ap, ap_t );
00087
00088 LAPACK_zhpevx( &jobz, &range, &uplo, &n, ap_t, &vl, &vu, &il, &iu,
00089 &abstol, m, w, z_t, &ldz_t, work, rwork, iwork, ifail,
00090 &info );
00091 if( info < 0 ) {
00092 info = info - 1;
00093 }
00094
00095 if( LAPACKE_lsame( jobz, 'v' ) ) {
00096 LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, ncols_z, z_t, ldz_t, z,
00097 ldz );
00098 }
00099 LAPACKE_zhp_trans( LAPACK_COL_MAJOR, uplo, n, ap_t, ap );
00100
00101 LAPACKE_free( ap_t );
00102 exit_level_1:
00103 if( LAPACKE_lsame( jobz, 'v' ) ) {
00104 LAPACKE_free( z_t );
00105 }
00106 exit_level_0:
00107 if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
00108 LAPACKE_xerbla( "LAPACKE_zhpevx_work", info );
00109 }
00110 } else {
00111 info = -1;
00112 LAPACKE_xerbla( "LAPACKE_zhpevx_work", info );
00113 }
00114 return info;
00115 }