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_cggevx_work( int matrix_order, char balanc, char jobvl,
00038 char jobvr, char sense, lapack_int n,
00039 lapack_complex_float* a, lapack_int lda,
00040 lapack_complex_float* b, lapack_int ldb,
00041 lapack_complex_float* alpha,
00042 lapack_complex_float* beta,
00043 lapack_complex_float* vl, lapack_int ldvl,
00044 lapack_complex_float* vr, lapack_int ldvr,
00045 lapack_int* ilo, lapack_int* ihi, float* lscale,
00046 float* rscale, float* abnrm, float* bbnrm,
00047 float* rconde, float* rcondv,
00048 lapack_complex_float* work, lapack_int lwork,
00049 float* rwork, lapack_int* iwork,
00050 lapack_logical* bwork )
00051 {
00052 lapack_int info = 0;
00053 if( matrix_order == LAPACK_COL_MAJOR ) {
00054
00055 LAPACK_cggevx( &balanc, &jobvl, &jobvr, &sense, &n, a, &lda, b, &ldb,
00056 alpha, beta, vl, &ldvl, vr, &ldvr, ilo, ihi, lscale,
00057 rscale, abnrm, bbnrm, rconde, rcondv, work, &lwork,
00058 rwork, iwork, bwork, &info );
00059 if( info < 0 ) {
00060 info = info - 1;
00061 }
00062 } else if( matrix_order == LAPACK_ROW_MAJOR ) {
00063 lapack_int lda_t = MAX(1,n);
00064 lapack_int ldb_t = MAX(1,n);
00065 lapack_int ldvl_t = MAX(1,n);
00066 lapack_int ldvr_t = MAX(1,n);
00067 lapack_complex_float* a_t = NULL;
00068 lapack_complex_float* b_t = NULL;
00069 lapack_complex_float* vl_t = NULL;
00070 lapack_complex_float* vr_t = NULL;
00071
00072 if( lda < n ) {
00073 info = -8;
00074 LAPACKE_xerbla( "LAPACKE_cggevx_work", info );
00075 return info;
00076 }
00077 if( ldb < n ) {
00078 info = -10;
00079 LAPACKE_xerbla( "LAPACKE_cggevx_work", info );
00080 return info;
00081 }
00082 if( ldvl < n ) {
00083 info = -14;
00084 LAPACKE_xerbla( "LAPACKE_cggevx_work", info );
00085 return info;
00086 }
00087 if( ldvr < n ) {
00088 info = -16;
00089 LAPACKE_xerbla( "LAPACKE_cggevx_work", info );
00090 return info;
00091 }
00092
00093 if( lwork == -1 ) {
00094 LAPACK_cggevx( &balanc, &jobvl, &jobvr, &sense, &n, a, &lda_t, b,
00095 &ldb_t, alpha, beta, vl, &ldvl_t, vr, &ldvr_t, ilo,
00096 ihi, lscale, rscale, abnrm, bbnrm, rconde, rcondv,
00097 work, &lwork, rwork, iwork, bwork, &info );
00098 return (info < 0) ? (info - 1) : info;
00099 }
00100
00101 a_t = (lapack_complex_float*)
00102 LAPACKE_malloc( sizeof(lapack_complex_float) * lda_t * MAX(1,n) );
00103 if( a_t == NULL ) {
00104 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00105 goto exit_level_0;
00106 }
00107 b_t = (lapack_complex_float*)
00108 LAPACKE_malloc( sizeof(lapack_complex_float) * ldb_t * MAX(1,n) );
00109 if( b_t == NULL ) {
00110 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00111 goto exit_level_1;
00112 }
00113 if( LAPACKE_lsame( jobvl, 'v' ) ) {
00114 vl_t = (lapack_complex_float*)
00115 LAPACKE_malloc( sizeof(lapack_complex_float) *
00116 ldvl_t * MAX(1,n) );
00117 if( vl_t == NULL ) {
00118 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00119 goto exit_level_2;
00120 }
00121 }
00122 if( LAPACKE_lsame( jobvr, 'v' ) ) {
00123 vr_t = (lapack_complex_float*)
00124 LAPACKE_malloc( sizeof(lapack_complex_float) *
00125 ldvr_t * MAX(1,n) );
00126 if( vr_t == NULL ) {
00127 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00128 goto exit_level_3;
00129 }
00130 }
00131
00132 LAPACKE_cge_trans( matrix_order, n, n, a, lda, a_t, lda_t );
00133 LAPACKE_cge_trans( matrix_order, n, n, b, ldb, b_t, ldb_t );
00134
00135 LAPACK_cggevx( &balanc, &jobvl, &jobvr, &sense, &n, a_t, &lda_t, b_t,
00136 &ldb_t, alpha, beta, vl_t, &ldvl_t, vr_t, &ldvr_t, ilo,
00137 ihi, lscale, rscale, abnrm, bbnrm, rconde, rcondv, work,
00138 &lwork, rwork, iwork, bwork, &info );
00139 if( info < 0 ) {
00140 info = info - 1;
00141 }
00142
00143 LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, n, a_t, lda_t, a, lda );
00144 LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, n, b_t, ldb_t, b, ldb );
00145 if( LAPACKE_lsame( jobvl, 'v' ) ) {
00146 LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, n, vl_t, ldvl_t, vl, ldvl );
00147 }
00148 if( LAPACKE_lsame( jobvr, 'v' ) ) {
00149 LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, n, vr_t, ldvr_t, vr, ldvr );
00150 }
00151
00152 if( LAPACKE_lsame( jobvr, 'v' ) ) {
00153 LAPACKE_free( vr_t );
00154 }
00155 exit_level_3:
00156 if( LAPACKE_lsame( jobvl, 'v' ) ) {
00157 LAPACKE_free( vl_t );
00158 }
00159 exit_level_2:
00160 LAPACKE_free( b_t );
00161 exit_level_1:
00162 LAPACKE_free( a_t );
00163 exit_level_0:
00164 if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
00165 LAPACKE_xerbla( "LAPACKE_cggevx_work", info );
00166 }
00167 } else {
00168 info = -1;
00169 LAPACKE_xerbla( "LAPACKE_cggevx_work", info );
00170 }
00171 return info;
00172 }