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