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_zhesvx( int matrix_order, char fact, char uplo, lapack_int n,
00038 lapack_int nrhs, const lapack_complex_double* a,
00039 lapack_int lda, lapack_complex_double* af,
00040 lapack_int ldaf, lapack_int* ipiv,
00041 const lapack_complex_double* b, lapack_int ldb,
00042 lapack_complex_double* x, lapack_int ldx,
00043 double* rcond, double* ferr, double* berr )
00044 {
00045 lapack_int info = 0;
00046 lapack_int lwork = -1;
00047 double* rwork = NULL;
00048 lapack_complex_double* work = NULL;
00049 lapack_complex_double work_query;
00050 if( matrix_order != LAPACK_COL_MAJOR && matrix_order != LAPACK_ROW_MAJOR ) {
00051 LAPACKE_xerbla( "LAPACKE_zhesvx", -1 );
00052 return -1;
00053 }
00054 #ifndef LAPACK_DISABLE_NAN_CHECK
00055
00056 if( LAPACKE_zhe_nancheck( matrix_order, uplo, n, a, lda ) ) {
00057 return -6;
00058 }
00059 if( LAPACKE_lsame( fact, 'f' ) ) {
00060 if( LAPACKE_zhe_nancheck( matrix_order, uplo, n, af, ldaf ) ) {
00061 return -8;
00062 }
00063 }
00064 if( LAPACKE_zge_nancheck( matrix_order, n, nrhs, b, ldb ) ) {
00065 return -11;
00066 }
00067 #endif
00068
00069 rwork = (double*)LAPACKE_malloc( sizeof(double) * MAX(1,n) );
00070 if( rwork == NULL ) {
00071 info = LAPACK_WORK_MEMORY_ERROR;
00072 goto exit_level_0;
00073 }
00074
00075 info = LAPACKE_zhesvx_work( matrix_order, fact, uplo, n, nrhs, a, lda, af,
00076 ldaf, ipiv, b, ldb, x, ldx, rcond, ferr, berr,
00077 &work_query, lwork, rwork );
00078 if( info != 0 ) {
00079 goto exit_level_1;
00080 }
00081 lwork = LAPACK_Z2INT( work_query );
00082
00083 work = (lapack_complex_double*)
00084 LAPACKE_malloc( sizeof(lapack_complex_double) * lwork );
00085 if( work == NULL ) {
00086 info = LAPACK_WORK_MEMORY_ERROR;
00087 goto exit_level_1;
00088 }
00089
00090 info = LAPACKE_zhesvx_work( matrix_order, fact, uplo, n, nrhs, a, lda, af,
00091 ldaf, ipiv, b, ldb, x, ldx, rcond, ferr, berr,
00092 work, lwork, rwork );
00093
00094 LAPACKE_free( work );
00095 exit_level_1:
00096 LAPACKE_free( rwork );
00097 exit_level_0:
00098 if( info == LAPACK_WORK_MEMORY_ERROR ) {
00099 LAPACKE_xerbla( "LAPACKE_zhesvx", info );
00100 }
00101 return info;
00102 }