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