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_ztgsna_work( int matrix_order, char job, char howmny,
00038 const lapack_logical* select, lapack_int n,
00039 const lapack_complex_double* a, lapack_int lda,
00040 const lapack_complex_double* b, lapack_int ldb,
00041 const lapack_complex_double* vl,
00042 lapack_int ldvl,
00043 const lapack_complex_double* vr,
00044 lapack_int ldvr, double* s, double* dif,
00045 lapack_int mm, lapack_int* m,
00046 lapack_complex_double* work, lapack_int lwork,
00047 lapack_int* iwork )
00048 {
00049 lapack_int info = 0;
00050 if( matrix_order == LAPACK_COL_MAJOR ) {
00051
00052 LAPACK_ztgsna( &job, &howmny, select, &n, a, &lda, b, &ldb, vl, &ldvl,
00053 vr, &ldvr, s, dif, &mm, m, work, &lwork, iwork, &info );
00054 if( info < 0 ) {
00055 info = info - 1;
00056 }
00057 } else if( matrix_order == LAPACK_ROW_MAJOR ) {
00058 lapack_int lda_t = MAX(1,n);
00059 lapack_int ldb_t = MAX(1,n);
00060 lapack_int ldvl_t = MAX(1,n);
00061 lapack_int ldvr_t = MAX(1,n);
00062 lapack_complex_double* a_t = NULL;
00063 lapack_complex_double* b_t = NULL;
00064 lapack_complex_double* vl_t = NULL;
00065 lapack_complex_double* vr_t = NULL;
00066
00067 if( lda < n ) {
00068 info = -7;
00069 LAPACKE_xerbla( "LAPACKE_ztgsna_work", info );
00070 return info;
00071 }
00072 if( ldb < n ) {
00073 info = -9;
00074 LAPACKE_xerbla( "LAPACKE_ztgsna_work", info );
00075 return info;
00076 }
00077 if( ldvl < mm ) {
00078 info = -11;
00079 LAPACKE_xerbla( "LAPACKE_ztgsna_work", info );
00080 return info;
00081 }
00082 if( ldvr < mm ) {
00083 info = -13;
00084 LAPACKE_xerbla( "LAPACKE_ztgsna_work", info );
00085 return info;
00086 }
00087
00088 if( lwork == -1 ) {
00089 LAPACK_ztgsna( &job, &howmny, select, &n, a, &lda_t, b, &ldb_t, vl,
00090 &ldvl_t, vr, &ldvr_t, s, dif, &mm, m, work, &lwork,
00091 iwork, &info );
00092 return (info < 0) ? (info - 1) : info;
00093 }
00094
00095 a_t = (lapack_complex_double*)
00096 LAPACKE_malloc( sizeof(lapack_complex_double) * lda_t * MAX(1,n) );
00097 if( a_t == NULL ) {
00098 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00099 goto exit_level_0;
00100 }
00101 b_t = (lapack_complex_double*)
00102 LAPACKE_malloc( sizeof(lapack_complex_double) * ldb_t * MAX(1,n) );
00103 if( b_t == NULL ) {
00104 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00105 goto exit_level_1;
00106 }
00107 if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'e' ) ) {
00108 vl_t = (lapack_complex_double*)
00109 LAPACKE_malloc( sizeof(lapack_complex_double) *
00110 ldvl_t * MAX(1,mm) );
00111 if( vl_t == NULL ) {
00112 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00113 goto exit_level_2;
00114 }
00115 }
00116 if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'e' ) ) {
00117 vr_t = (lapack_complex_double*)
00118 LAPACKE_malloc( sizeof(lapack_complex_double) *
00119 ldvr_t * MAX(1,mm) );
00120 if( vr_t == NULL ) {
00121 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00122 goto exit_level_3;
00123 }
00124 }
00125
00126 LAPACKE_zge_trans( matrix_order, n, n, a, lda, a_t, lda_t );
00127 LAPACKE_zge_trans( matrix_order, n, n, b, ldb, b_t, ldb_t );
00128 if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'e' ) ) {
00129 LAPACKE_zge_trans( matrix_order, n, mm, vl, ldvl, vl_t, ldvl_t );
00130 }
00131 if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'e' ) ) {
00132 LAPACKE_zge_trans( matrix_order, n, mm, vr, ldvr, vr_t, ldvr_t );
00133 }
00134
00135 LAPACK_ztgsna( &job, &howmny, select, &n, a_t, &lda_t, b_t, &ldb_t,
00136 vl_t, &ldvl_t, vr_t, &ldvr_t, s, dif, &mm, m, work,
00137 &lwork, iwork, &info );
00138 if( info < 0 ) {
00139 info = info - 1;
00140 }
00141
00142 if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'e' ) ) {
00143 LAPACKE_free( vr_t );
00144 }
00145 exit_level_3:
00146 if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'e' ) ) {
00147 LAPACKE_free( vl_t );
00148 }
00149 exit_level_2:
00150 LAPACKE_free( b_t );
00151 exit_level_1:
00152 LAPACKE_free( a_t );
00153 exit_level_0:
00154 if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
00155 LAPACKE_xerbla( "LAPACKE_ztgsna_work", info );
00156 }
00157 } else {
00158 info = -1;
00159 LAPACKE_xerbla( "LAPACKE_ztgsna_work", info );
00160 }
00161 return info;
00162 }