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_ctgsja_work( int matrix_order, char jobu, char jobv,
00038 char jobq, lapack_int m, lapack_int p,
00039 lapack_int n, lapack_int k, lapack_int l,
00040 lapack_complex_float* a, lapack_int lda,
00041 lapack_complex_float* b, lapack_int ldb,
00042 float tola, float tolb, float* alpha,
00043 float* beta, lapack_complex_float* u,
00044 lapack_int ldu, lapack_complex_float* v,
00045 lapack_int ldv, lapack_complex_float* q,
00046 lapack_int ldq, lapack_complex_float* work,
00047 lapack_int* ncycle )
00048 {
00049 lapack_int info = 0;
00050 if( matrix_order == LAPACK_COL_MAJOR ) {
00051
00052 LAPACK_ctgsja( &jobu, &jobv, &jobq, &m, &p, &n, &k, &l, a, &lda, b,
00053 &ldb, &tola, &tolb, alpha, beta, u, &ldu, v, &ldv, q,
00054 &ldq, work, ncycle, &info );
00055 if( info < 0 ) {
00056 info = info - 1;
00057 }
00058 } else if( matrix_order == LAPACK_ROW_MAJOR ) {
00059 lapack_int lda_t = MAX(1,m);
00060 lapack_int ldb_t = MAX(1,p);
00061 lapack_int ldq_t = MAX(1,n);
00062 lapack_int ldu_t = MAX(1,m);
00063 lapack_int ldv_t = MAX(1,p);
00064 lapack_complex_float* a_t = NULL;
00065 lapack_complex_float* b_t = NULL;
00066 lapack_complex_float* u_t = NULL;
00067 lapack_complex_float* v_t = NULL;
00068 lapack_complex_float* q_t = NULL;
00069
00070 if( lda < n ) {
00071 info = -11;
00072 LAPACKE_xerbla( "LAPACKE_ctgsja_work", info );
00073 return info;
00074 }
00075 if( ldb < n ) {
00076 info = -13;
00077 LAPACKE_xerbla( "LAPACKE_ctgsja_work", info );
00078 return info;
00079 }
00080 if( ldq < n ) {
00081 info = -23;
00082 LAPACKE_xerbla( "LAPACKE_ctgsja_work", info );
00083 return info;
00084 }
00085 if( ldu < m ) {
00086 info = -19;
00087 LAPACKE_xerbla( "LAPACKE_ctgsja_work", info );
00088 return info;
00089 }
00090 if( ldv < p ) {
00091 info = -21;
00092 LAPACKE_xerbla( "LAPACKE_ctgsja_work", info );
00093 return info;
00094 }
00095
00096 a_t = (lapack_complex_float*)
00097 LAPACKE_malloc( sizeof(lapack_complex_float) * lda_t * MAX(1,n) );
00098 if( a_t == NULL ) {
00099 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00100 goto exit_level_0;
00101 }
00102 b_t = (lapack_complex_float*)
00103 LAPACKE_malloc( sizeof(lapack_complex_float) * ldb_t * MAX(1,n) );
00104 if( b_t == NULL ) {
00105 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00106 goto exit_level_1;
00107 }
00108 if( LAPACKE_lsame( jobu, 'i' ) || LAPACKE_lsame( jobu, 'u' ) ) {
00109 u_t = (lapack_complex_float*)
00110 LAPACKE_malloc( sizeof(lapack_complex_float) *
00111 ldu_t * MAX(1,m) );
00112 if( u_t == NULL ) {
00113 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00114 goto exit_level_2;
00115 }
00116 }
00117 if( LAPACKE_lsame( jobv, 'i' ) || LAPACKE_lsame( jobv, 'v' ) ) {
00118 v_t = (lapack_complex_float*)
00119 LAPACKE_malloc( sizeof(lapack_complex_float) *
00120 ldv_t * MAX(1,p) );
00121 if( v_t == NULL ) {
00122 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00123 goto exit_level_3;
00124 }
00125 }
00126 if( LAPACKE_lsame( jobq, 'i' ) || LAPACKE_lsame( jobq, 'q' ) ) {
00127 q_t = (lapack_complex_float*)
00128 LAPACKE_malloc( sizeof(lapack_complex_float) *
00129 ldq_t * MAX(1,n) );
00130 if( q_t == NULL ) {
00131 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00132 goto exit_level_4;
00133 }
00134 }
00135
00136 LAPACKE_cge_trans( matrix_order, m, n, a, lda, a_t, lda_t );
00137 LAPACKE_cge_trans( matrix_order, p, n, b, ldb, b_t, ldb_t );
00138 if( LAPACKE_lsame( jobu, 'u' ) ) {
00139 LAPACKE_cge_trans( matrix_order, m, m, u, ldu, u_t, ldu_t );
00140 }
00141 if( LAPACKE_lsame( jobv, 'v' ) ) {
00142 LAPACKE_cge_trans( matrix_order, p, p, v, ldv, v_t, ldv_t );
00143 }
00144 if( LAPACKE_lsame( jobq, 'q' ) ) {
00145 LAPACKE_cge_trans( matrix_order, n, n, q, ldq, q_t, ldq_t );
00146 }
00147
00148 LAPACK_ctgsja( &jobu, &jobv, &jobq, &m, &p, &n, &k, &l, a_t, &lda_t,
00149 b_t, &ldb_t, &tola, &tolb, alpha, beta, u_t, &ldu_t, v_t,
00150 &ldv_t, q_t, &ldq_t, work, ncycle, &info );
00151 if( info < 0 ) {
00152 info = info - 1;
00153 }
00154
00155 LAPACKE_cge_trans( LAPACK_COL_MAJOR, m, n, a_t, lda_t, a, lda );
00156 LAPACKE_cge_trans( LAPACK_COL_MAJOR, p, n, b_t, ldb_t, b, ldb );
00157 if( LAPACKE_lsame( jobu, 'i' ) || LAPACKE_lsame( jobu, 'u' ) ) {
00158 LAPACKE_cge_trans( LAPACK_COL_MAJOR, m, m, u_t, ldu_t, u, ldu );
00159 }
00160 if( LAPACKE_lsame( jobv, 'i' ) || LAPACKE_lsame( jobv, 'v' ) ) {
00161 LAPACKE_cge_trans( LAPACK_COL_MAJOR, p, p, v_t, ldv_t, v, ldv );
00162 }
00163 if( LAPACKE_lsame( jobq, 'i' ) || LAPACKE_lsame( jobq, 'q' ) ) {
00164 LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, n, q_t, ldq_t, q, ldq );
00165 }
00166
00167 if( LAPACKE_lsame( jobq, 'i' ) || LAPACKE_lsame( jobq, 'q' ) ) {
00168 LAPACKE_free( q_t );
00169 }
00170 exit_level_4:
00171 if( LAPACKE_lsame( jobv, 'i' ) || LAPACKE_lsame( jobv, 'v' ) ) {
00172 LAPACKE_free( v_t );
00173 }
00174 exit_level_3:
00175 if( LAPACKE_lsame( jobu, 'i' ) || LAPACKE_lsame( jobu, 'u' ) ) {
00176 LAPACKE_free( u_t );
00177 }
00178 exit_level_2:
00179 LAPACKE_free( b_t );
00180 exit_level_1:
00181 LAPACKE_free( a_t );
00182 exit_level_0:
00183 if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
00184 LAPACKE_xerbla( "LAPACKE_ctgsja_work", info );
00185 }
00186 } else {
00187 info = -1;
00188 LAPACKE_xerbla( "LAPACKE_ctgsja_work", info );
00189 }
00190 return info;
00191 }