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_dgeesx( int matrix_order, char jobvs, char sort,
00038 LAPACK_D_SELECT2 select, char sense, lapack_int n,
00039 double* a, lapack_int lda, lapack_int* sdim,
00040 double* wr, double* wi, double* vs, lapack_int ldvs,
00041 double* rconde, double* rcondv )
00042 {
00043 lapack_int info = 0;
00044 lapack_int liwork = -1;
00045 lapack_int lwork = -1;
00046 lapack_logical* bwork = NULL;
00047 lapack_int* iwork = NULL;
00048 double* work = NULL;
00049 lapack_int iwork_query;
00050 double work_query;
00051 if( matrix_order != LAPACK_COL_MAJOR && matrix_order != LAPACK_ROW_MAJOR ) {
00052 LAPACKE_xerbla( "LAPACKE_dgeesx", -1 );
00053 return -1;
00054 }
00055 #ifndef LAPACK_DISABLE_NAN_CHECK
00056
00057 if( LAPACKE_dge_nancheck( matrix_order, n, n, a, lda ) ) {
00058 return -7;
00059 }
00060 #endif
00061
00062 if( LAPACKE_lsame( sort, 's' ) ) {
00063 bwork = (lapack_logical*)
00064 LAPACKE_malloc( sizeof(lapack_logical) * MAX(1,n) );
00065 if( bwork == NULL ) {
00066 info = LAPACK_WORK_MEMORY_ERROR;
00067 goto exit_level_0;
00068 }
00069 }
00070
00071 info = LAPACKE_dgeesx_work( matrix_order, jobvs, sort, select, sense, n, a,
00072 lda, sdim, wr, wi, vs, ldvs, rconde, rcondv,
00073 &work_query, lwork, &iwork_query, liwork,
00074 bwork );
00075 if( info != 0 ) {
00076 goto exit_level_1;
00077 }
00078 liwork = (lapack_int)iwork_query;
00079 lwork = (lapack_int)work_query;
00080
00081 if( LAPACKE_lsame( sense, 'b' ) || LAPACKE_lsame( sense, 'v' ) ) {
00082 iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
00083 if( iwork == NULL ) {
00084 info = LAPACK_WORK_MEMORY_ERROR;
00085 goto exit_level_1;
00086 }
00087 }
00088 work = (double*)LAPACKE_malloc( sizeof(double) * lwork );
00089 if( work == NULL ) {
00090 info = LAPACK_WORK_MEMORY_ERROR;
00091 goto exit_level_2;
00092 }
00093
00094 info = LAPACKE_dgeesx_work( matrix_order, jobvs, sort, select, sense, n, a,
00095 lda, sdim, wr, wi, vs, ldvs, rconde, rcondv,
00096 work, lwork, iwork, liwork, bwork );
00097
00098 LAPACKE_free( work );
00099 exit_level_2:
00100 if( LAPACKE_lsame( sense, 'b' ) || LAPACKE_lsame( sense, 'v' ) ) {
00101 LAPACKE_free( iwork );
00102 }
00103 exit_level_1:
00104 if( LAPACKE_lsame( sort, 's' ) ) {
00105 LAPACKE_free( bwork );
00106 }
00107 exit_level_0:
00108 if( info == LAPACK_WORK_MEMORY_ERROR ) {
00109 LAPACKE_xerbla( "LAPACKE_dgeesx", info );
00110 }
00111 return info;
00112 }