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_ctgsyl_work( int matrix_order, char trans, lapack_int ijob,
00038 lapack_int m, lapack_int n,
00039 const lapack_complex_float* a, lapack_int lda,
00040 const lapack_complex_float* b, lapack_int ldb,
00041 lapack_complex_float* c, lapack_int ldc,
00042 const lapack_complex_float* d, lapack_int ldd,
00043 const lapack_complex_float* e, lapack_int lde,
00044 lapack_complex_float* f, lapack_int ldf,
00045 float* scale, float* dif,
00046 lapack_complex_float* work, lapack_int lwork,
00047 lapack_int* iwork )
00048 {
00049 lapack_int info = 0;
00050 if( matrix_order == LAPACK_COL_MAJOR ) {
00051
00052 LAPACK_ctgsyl( &trans, &ijob, &m, &n, a, &lda, b, &ldb, c, &ldc, d,
00053 &ldd, e, &lde, f, &ldf, scale, dif, work, &lwork, iwork,
00054 &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,n);
00061 lapack_int ldc_t = MAX(1,m);
00062 lapack_int ldd_t = MAX(1,m);
00063 lapack_int lde_t = MAX(1,n);
00064 lapack_int ldf_t = MAX(1,m);
00065 lapack_complex_float* a_t = NULL;
00066 lapack_complex_float* b_t = NULL;
00067 lapack_complex_float* c_t = NULL;
00068 lapack_complex_float* d_t = NULL;
00069 lapack_complex_float* e_t = NULL;
00070 lapack_complex_float* f_t = NULL;
00071
00072 if( lda < m ) {
00073 info = -7;
00074 LAPACKE_xerbla( "LAPACKE_ctgsyl_work", info );
00075 return info;
00076 }
00077 if( ldb < n ) {
00078 info = -9;
00079 LAPACKE_xerbla( "LAPACKE_ctgsyl_work", info );
00080 return info;
00081 }
00082 if( ldc < n ) {
00083 info = -11;
00084 LAPACKE_xerbla( "LAPACKE_ctgsyl_work", info );
00085 return info;
00086 }
00087 if( ldd < m ) {
00088 info = -13;
00089 LAPACKE_xerbla( "LAPACKE_ctgsyl_work", info );
00090 return info;
00091 }
00092 if( lde < n ) {
00093 info = -15;
00094 LAPACKE_xerbla( "LAPACKE_ctgsyl_work", info );
00095 return info;
00096 }
00097 if( ldf < n ) {
00098 info = -17;
00099 LAPACKE_xerbla( "LAPACKE_ctgsyl_work", info );
00100 return info;
00101 }
00102
00103 if( lwork == -1 ) {
00104 LAPACK_ctgsyl( &trans, &ijob, &m, &n, a, &lda_t, b, &ldb_t, c,
00105 &ldc_t, d, &ldd_t, e, &lde_t, f, &ldf_t, scale, dif,
00106 work, &lwork, iwork, &info );
00107 return (info < 0) ? (info - 1) : info;
00108 }
00109
00110 a_t = (lapack_complex_float*)
00111 LAPACKE_malloc( sizeof(lapack_complex_float) * lda_t * MAX(1,m) );
00112 if( a_t == NULL ) {
00113 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00114 goto exit_level_0;
00115 }
00116 b_t = (lapack_complex_float*)
00117 LAPACKE_malloc( sizeof(lapack_complex_float) * ldb_t * MAX(1,n) );
00118 if( b_t == NULL ) {
00119 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00120 goto exit_level_1;
00121 }
00122 c_t = (lapack_complex_float*)
00123 LAPACKE_malloc( sizeof(lapack_complex_float) * ldc_t * MAX(1,n) );
00124 if( c_t == NULL ) {
00125 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00126 goto exit_level_2;
00127 }
00128 d_t = (lapack_complex_float*)
00129 LAPACKE_malloc( sizeof(lapack_complex_float) * ldd_t * MAX(1,m) );
00130 if( d_t == NULL ) {
00131 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00132 goto exit_level_3;
00133 }
00134 e_t = (lapack_complex_float*)
00135 LAPACKE_malloc( sizeof(lapack_complex_float) * lde_t * MAX(1,n) );
00136 if( e_t == NULL ) {
00137 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00138 goto exit_level_4;
00139 }
00140 f_t = (lapack_complex_float*)
00141 LAPACKE_malloc( sizeof(lapack_complex_float) * ldf_t * MAX(1,n) );
00142 if( f_t == NULL ) {
00143 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00144 goto exit_level_5;
00145 }
00146
00147 LAPACKE_cge_trans( matrix_order, m, m, a, lda, a_t, lda_t );
00148 LAPACKE_cge_trans( matrix_order, n, n, b, ldb, b_t, ldb_t );
00149 LAPACKE_cge_trans( matrix_order, m, n, c, ldc, c_t, ldc_t );
00150 LAPACKE_cge_trans( matrix_order, m, m, d, ldd, d_t, ldd_t );
00151 LAPACKE_cge_trans( matrix_order, n, n, e, lde, e_t, lde_t );
00152 LAPACKE_cge_trans( matrix_order, m, n, f, ldf, f_t, ldf_t );
00153
00154 LAPACK_ctgsyl( &trans, &ijob, &m, &n, a_t, &lda_t, b_t, &ldb_t, c_t,
00155 &ldc_t, d_t, &ldd_t, e_t, &lde_t, f_t, &ldf_t, scale,
00156 dif, work, &lwork, iwork, &info );
00157 if( info < 0 ) {
00158 info = info - 1;
00159 }
00160
00161 LAPACKE_cge_trans( LAPACK_COL_MAJOR, m, n, c_t, ldc_t, c, ldc );
00162 LAPACKE_cge_trans( LAPACK_COL_MAJOR, m, n, f_t, ldf_t, f, ldf );
00163
00164 LAPACKE_free( f_t );
00165 exit_level_5:
00166 LAPACKE_free( e_t );
00167 exit_level_4:
00168 LAPACKE_free( d_t );
00169 exit_level_3:
00170 LAPACKE_free( c_t );
00171 exit_level_2:
00172 LAPACKE_free( b_t );
00173 exit_level_1:
00174 LAPACKE_free( a_t );
00175 exit_level_0:
00176 if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
00177 LAPACKE_xerbla( "LAPACKE_ctgsyl_work", info );
00178 }
00179 } else {
00180 info = -1;
00181 LAPACKE_xerbla( "LAPACKE_ctgsyl_work", info );
00182 }
00183 return info;
00184 }