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