Go to the documentation of this file.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_zhpevd( int matrix_order, char jobz, char uplo, lapack_int n,
00038 lapack_complex_double* ap, double* w,
00039 lapack_complex_double* z, lapack_int ldz )
00040 {
00041 lapack_int info = 0;
00042 lapack_int liwork = -1;
00043 lapack_int lrwork = -1;
00044 lapack_int lwork = -1;
00045 lapack_int* iwork = NULL;
00046 double* rwork = NULL;
00047 lapack_complex_double* work = NULL;
00048 lapack_int iwork_query;
00049 double rwork_query;
00050 lapack_complex_double work_query;
00051 if( matrix_order != LAPACK_COL_MAJOR && matrix_order != LAPACK_ROW_MAJOR ) {
00052 LAPACKE_xerbla( "LAPACKE_zhpevd", -1 );
00053 return -1;
00054 }
00055 #ifndef LAPACK_DISABLE_NAN_CHECK
00056
00057 if( LAPACKE_zhp_nancheck( n, ap ) ) {
00058 return -5;
00059 }
00060 #endif
00061
00062 info = LAPACKE_zhpevd_work( matrix_order, jobz, uplo, n, ap, w, z, ldz,
00063 &work_query, lwork, &rwork_query, lrwork,
00064 &iwork_query, liwork );
00065 if( info != 0 ) {
00066 goto exit_level_0;
00067 }
00068 liwork = (lapack_int)iwork_query;
00069 lrwork = (lapack_int)rwork_query;
00070 lwork = LAPACK_Z2INT( work_query );
00071
00072 iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
00073 if( iwork == NULL ) {
00074 info = LAPACK_WORK_MEMORY_ERROR;
00075 goto exit_level_0;
00076 }
00077 rwork = (double*)LAPACKE_malloc( sizeof(double) * lrwork );
00078 if( rwork == NULL ) {
00079 info = LAPACK_WORK_MEMORY_ERROR;
00080 goto exit_level_1;
00081 }
00082 work = (lapack_complex_double*)
00083 LAPACKE_malloc( sizeof(lapack_complex_double) * lwork );
00084 if( work == NULL ) {
00085 info = LAPACK_WORK_MEMORY_ERROR;
00086 goto exit_level_2;
00087 }
00088
00089 info = LAPACKE_zhpevd_work( matrix_order, jobz, uplo, n, ap, w, z, ldz,
00090 work, lwork, rwork, lrwork, iwork, liwork );
00091
00092 LAPACKE_free( work );
00093 exit_level_2:
00094 LAPACKE_free( rwork );
00095 exit_level_1:
00096 LAPACKE_free( iwork );
00097 exit_level_0:
00098 if( info == LAPACK_WORK_MEMORY_ERROR ) {
00099 LAPACKE_xerbla( "LAPACKE_zhpevd", info );
00100 }
00101 return info;
00102 }