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_zhegvx( int matrix_order, lapack_int itype, char jobz,
00038 char range, char uplo, lapack_int n,
00039 lapack_complex_double* a, lapack_int lda,
00040 lapack_complex_double* b, lapack_int ldb, double vl,
00041 double vu, lapack_int il, lapack_int iu,
00042 double abstol, lapack_int* m, double* w,
00043 lapack_complex_double* z, lapack_int ldz,
00044 lapack_int* ifail )
00045 {
00046 lapack_int info = 0;
00047 lapack_int lwork = -1;
00048 lapack_int* iwork = NULL;
00049 double* rwork = NULL;
00050 lapack_complex_double* work = NULL;
00051 lapack_complex_double work_query;
00052 if( matrix_order != LAPACK_COL_MAJOR && matrix_order != LAPACK_ROW_MAJOR ) {
00053 LAPACKE_xerbla( "LAPACKE_zhegvx", -1 );
00054 return -1;
00055 }
00056 #ifndef LAPACK_DISABLE_NAN_CHECK
00057
00058 if( LAPACKE_zhe_nancheck( matrix_order, uplo, n, a, lda ) ) {
00059 return -7;
00060 }
00061 if( LAPACKE_d_nancheck( 1, &abstol, 1 ) ) {
00062 return -15;
00063 }
00064 if( LAPACKE_zge_nancheck( matrix_order, n, n, b, ldb ) ) {
00065 return -9;
00066 }
00067 if( LAPACKE_lsame( range, 'v' ) ) {
00068 if( LAPACKE_d_nancheck( 1, &vl, 1 ) ) {
00069 return -11;
00070 }
00071 }
00072 if( LAPACKE_lsame( range, 'v' ) ) {
00073 if( LAPACKE_d_nancheck( 1, &vu, 1 ) ) {
00074 return -12;
00075 }
00076 }
00077 #endif
00078
00079 iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * MAX(1,5*n) );
00080 if( iwork == NULL ) {
00081 info = LAPACK_WORK_MEMORY_ERROR;
00082 goto exit_level_0;
00083 }
00084 rwork = (double*)LAPACKE_malloc( sizeof(double) * MAX(1,7*n) );
00085 if( rwork == NULL ) {
00086 info = LAPACK_WORK_MEMORY_ERROR;
00087 goto exit_level_1;
00088 }
00089
00090 info = LAPACKE_zhegvx_work( matrix_order, itype, jobz, range, uplo, n, a,
00091 lda, b, ldb, vl, vu, il, iu, abstol, m, w, z,
00092 ldz, &work_query, lwork, rwork, iwork, ifail );
00093 if( info != 0 ) {
00094 goto exit_level_2;
00095 }
00096 lwork = LAPACK_Z2INT( work_query );
00097
00098 work = (lapack_complex_double*)
00099 LAPACKE_malloc( sizeof(lapack_complex_double) * lwork );
00100 if( work == NULL ) {
00101 info = LAPACK_WORK_MEMORY_ERROR;
00102 goto exit_level_2;
00103 }
00104
00105 info = LAPACKE_zhegvx_work( matrix_order, itype, jobz, range, uplo, n, a,
00106 lda, b, ldb, vl, vu, il, iu, abstol, m, w, z,
00107 ldz, work, lwork, rwork, iwork, ifail );
00108
00109 LAPACKE_free( work );
00110 exit_level_2:
00111 LAPACKE_free( rwork );
00112 exit_level_1:
00113 LAPACKE_free( iwork );
00114 exit_level_0:
00115 if( info == LAPACK_WORK_MEMORY_ERROR ) {
00116 LAPACKE_xerbla( "LAPACKE_zhegvx", info );
00117 }
00118 return info;
00119 }