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_dgeevx( int matrix_order, char balanc, char jobvl,
00038 char jobvr, char sense, lapack_int n, double* a,
00039 lapack_int lda, double* wr, double* wi, double* vl,
00040 lapack_int ldvl, double* vr, lapack_int ldvr,
00041 lapack_int* ilo, lapack_int* ihi, double* scale,
00042 double* abnrm, double* rconde, double* rcondv )
00043 {
00044 lapack_int info = 0;
00045 lapack_int lwork = -1;
00046 lapack_int* iwork = NULL;
00047 double* work = NULL;
00048 double work_query;
00049 if( matrix_order != LAPACK_COL_MAJOR && matrix_order != LAPACK_ROW_MAJOR ) {
00050 LAPACKE_xerbla( "LAPACKE_dgeevx", -1 );
00051 return -1;
00052 }
00053 #ifndef LAPACK_DISABLE_NAN_CHECK
00054
00055 if( LAPACKE_dge_nancheck( matrix_order, n, n, a, lda ) ) {
00056 return -7;
00057 }
00058 #endif
00059
00060 if( LAPACKE_lsame( sense, 'b' ) || LAPACKE_lsame( sense, 'v' ) ) {
00061 iwork = (lapack_int*)
00062 LAPACKE_malloc( sizeof(lapack_int) * MAX(1,2*n-2) );
00063 if( iwork == NULL ) {
00064 info = LAPACK_WORK_MEMORY_ERROR;
00065 goto exit_level_0;
00066 }
00067 }
00068
00069 info = LAPACKE_dgeevx_work( matrix_order, balanc, jobvl, jobvr, sense, n, a,
00070 lda, wr, wi, vl, ldvl, vr, ldvr, ilo, ihi,
00071 scale, abnrm, rconde, rcondv, &work_query,
00072 lwork, iwork );
00073 if( info != 0 ) {
00074 goto exit_level_1;
00075 }
00076 lwork = (lapack_int)work_query;
00077
00078 work = (double*)LAPACKE_malloc( sizeof(double) * lwork );
00079 if( work == NULL ) {
00080 info = LAPACK_WORK_MEMORY_ERROR;
00081 goto exit_level_1;
00082 }
00083
00084 info = LAPACKE_dgeevx_work( matrix_order, balanc, jobvl, jobvr, sense, n, a,
00085 lda, wr, wi, vl, ldvl, vr, ldvr, ilo, ihi,
00086 scale, abnrm, rconde, rcondv, work, lwork,
00087 iwork );
00088
00089 LAPACKE_free( work );
00090 exit_level_1:
00091 if( LAPACKE_lsame( sense, 'b' ) || LAPACKE_lsame( sense, 'v' ) ) {
00092 LAPACKE_free( iwork );
00093 }
00094 exit_level_0:
00095 if( info == LAPACK_WORK_MEMORY_ERROR ) {
00096 LAPACKE_xerbla( "LAPACKE_dgeevx", info );
00097 }
00098 return info;
00099 }