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_zggesx_work( int matrix_order, char jobvsl, char jobvsr,
00038 char sort, LAPACK_Z_SELECT2 selctg, char sense,
00039 lapack_int n, lapack_complex_double* a,
00040 lapack_int lda, lapack_complex_double* b,
00041 lapack_int ldb, lapack_int* sdim,
00042 lapack_complex_double* alpha,
00043 lapack_complex_double* beta,
00044 lapack_complex_double* vsl, lapack_int ldvsl,
00045 lapack_complex_double* vsr, lapack_int ldvsr,
00046 double* rconde, double* rcondv,
00047 lapack_complex_double* work, lapack_int lwork,
00048 double* rwork, lapack_int* iwork,
00049 lapack_int liwork, lapack_logical* bwork )
00050 {
00051 lapack_int info = 0;
00052 if( matrix_order == LAPACK_COL_MAJOR ) {
00053
00054 LAPACK_zggesx( &jobvsl, &jobvsr, &sort, selctg, &sense, &n, a, &lda, b,
00055 &ldb, sdim, alpha, beta, vsl, &ldvsl, vsr, &ldvsr,
00056 rconde, rcondv, work, &lwork, rwork, iwork, &liwork,
00057 bwork, &info );
00058 if( info < 0 ) {
00059 info = info - 1;
00060 }
00061 } else if( matrix_order == LAPACK_ROW_MAJOR ) {
00062 lapack_int lda_t = MAX(1,n);
00063 lapack_int ldb_t = MAX(1,n);
00064 lapack_int ldvsl_t = MAX(1,n);
00065 lapack_int ldvsr_t = MAX(1,n);
00066 lapack_complex_double* a_t = NULL;
00067 lapack_complex_double* b_t = NULL;
00068 lapack_complex_double* vsl_t = NULL;
00069 lapack_complex_double* vsr_t = NULL;
00070
00071 if( lda < n ) {
00072 info = -9;
00073 LAPACKE_xerbla( "LAPACKE_zggesx_work", info );
00074 return info;
00075 }
00076 if( ldb < n ) {
00077 info = -11;
00078 LAPACKE_xerbla( "LAPACKE_zggesx_work", info );
00079 return info;
00080 }
00081 if( ldvsl < n ) {
00082 info = -16;
00083 LAPACKE_xerbla( "LAPACKE_zggesx_work", info );
00084 return info;
00085 }
00086 if( ldvsr < n ) {
00087 info = -18;
00088 LAPACKE_xerbla( "LAPACKE_zggesx_work", info );
00089 return info;
00090 }
00091
00092 if( liwork == -1 || lwork == -1 ) {
00093 LAPACK_zggesx( &jobvsl, &jobvsr, &sort, selctg, &sense, &n, a,
00094 &lda_t, b, &ldb_t, sdim, alpha, beta, vsl, &ldvsl_t,
00095 vsr, &ldvsr_t, rconde, rcondv, work, &lwork, rwork,
00096 iwork, &liwork, bwork, &info );
00097 return (info < 0) ? (info - 1) : info;
00098 }
00099
00100 a_t = (lapack_complex_double*)
00101 LAPACKE_malloc( sizeof(lapack_complex_double) * lda_t * MAX(1,n) );
00102 if( a_t == NULL ) {
00103 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00104 goto exit_level_0;
00105 }
00106 b_t = (lapack_complex_double*)
00107 LAPACKE_malloc( sizeof(lapack_complex_double) * ldb_t * MAX(1,n) );
00108 if( b_t == NULL ) {
00109 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00110 goto exit_level_1;
00111 }
00112 if( LAPACKE_lsame( jobvsl, 'v' ) ) {
00113 vsl_t = (lapack_complex_double*)
00114 LAPACKE_malloc( sizeof(lapack_complex_double) *
00115 ldvsl_t * MAX(1,n) );
00116 if( vsl_t == NULL ) {
00117 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00118 goto exit_level_2;
00119 }
00120 }
00121 if( LAPACKE_lsame( jobvsr, 'v' ) ) {
00122 vsr_t = (lapack_complex_double*)
00123 LAPACKE_malloc( sizeof(lapack_complex_double) *
00124 ldvsr_t * MAX(1,n) );
00125 if( vsr_t == NULL ) {
00126 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00127 goto exit_level_3;
00128 }
00129 }
00130
00131 LAPACKE_zge_trans( matrix_order, n, n, a, lda, a_t, lda_t );
00132 LAPACKE_zge_trans( matrix_order, n, n, b, ldb, b_t, ldb_t );
00133
00134 LAPACK_zggesx( &jobvsl, &jobvsr, &sort, selctg, &sense, &n, a_t, &lda_t,
00135 b_t, &ldb_t, sdim, alpha, beta, vsl_t, &ldvsl_t, vsr_t,
00136 &ldvsr_t, rconde, rcondv, work, &lwork, rwork, iwork,
00137 &liwork, bwork, &info );
00138 if( info < 0 ) {
00139 info = info - 1;
00140 }
00141
00142 LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, n, a_t, lda_t, a, lda );
00143 LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, n, b_t, ldb_t, b, ldb );
00144 if( LAPACKE_lsame( jobvsl, 'v' ) ) {
00145 LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, n, vsl_t, ldvsl_t, vsl,
00146 ldvsl );
00147 }
00148 if( LAPACKE_lsame( jobvsr, 'v' ) ) {
00149 LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, n, vsr_t, ldvsr_t, vsr,
00150 ldvsr );
00151 }
00152
00153 if( LAPACKE_lsame( jobvsr, 'v' ) ) {
00154 LAPACKE_free( vsr_t );
00155 }
00156 exit_level_3:
00157 if( LAPACKE_lsame( jobvsl, 'v' ) ) {
00158 LAPACKE_free( vsl_t );
00159 }
00160 exit_level_2:
00161 LAPACKE_free( b_t );
00162 exit_level_1:
00163 LAPACKE_free( a_t );
00164 exit_level_0:
00165 if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
00166 LAPACKE_xerbla( "LAPACKE_zggesx_work", info );
00167 }
00168 } else {
00169 info = -1;
00170 LAPACKE_xerbla( "LAPACKE_zggesx_work", info );
00171 }
00172 return info;
00173 }