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