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
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 #include <stdio.h>
00050 #include "lapacke.h"
00051 #include "lapacke_utils.h"
00052 #include "test_utils.h"
00053
00054 static void init_scalars_ctrsen( char *job, char *compq, lapack_int *n,
00055 lapack_int *ldt, lapack_int *ldq,
00056 lapack_int *lwork );
00057 static void init_select( lapack_int size, lapack_int *select );
00058 static void init_t( lapack_int size, lapack_complex_float *t );
00059 static void init_q( lapack_int size, lapack_complex_float *q );
00060 static void init_w( lapack_int size, lapack_complex_float *w );
00061 static void init_work( lapack_int size, lapack_complex_float *work );
00062 static int compare_ctrsen( lapack_complex_float *t, lapack_complex_float *t_i,
00063 lapack_complex_float *q, lapack_complex_float *q_i,
00064 lapack_complex_float *w, lapack_complex_float *w_i,
00065 lapack_int m, lapack_int m_i, float s, float s_i,
00066 float sep, float sep_i, lapack_int info,
00067 lapack_int info_i, char compq, lapack_int ldq,
00068 lapack_int ldt, lapack_int n );
00069
00070 int main(void)
00071 {
00072
00073 char job, job_i;
00074 char compq, compq_i;
00075 lapack_int n, n_i;
00076 lapack_int ldt, ldt_i;
00077 lapack_int ldt_r;
00078 lapack_int ldq, ldq_i;
00079 lapack_int ldq_r;
00080 lapack_int m, m_i;
00081 float s, s_i;
00082 float sep, sep_i;
00083 lapack_int lwork, lwork_i;
00084 lapack_int info, info_i;
00085 lapack_int i;
00086 int failed;
00087
00088
00089 lapack_int *select = NULL, *select_i = NULL;
00090 lapack_complex_float *t = NULL, *t_i = NULL;
00091 lapack_complex_float *q = NULL, *q_i = NULL;
00092 lapack_complex_float *w = NULL, *w_i = NULL;
00093 lapack_complex_float *work = NULL, *work_i = NULL;
00094 lapack_complex_float *t_save = NULL;
00095 lapack_complex_float *q_save = NULL;
00096 lapack_complex_float *w_save = NULL;
00097 lapack_complex_float *t_r = NULL;
00098 lapack_complex_float *q_r = NULL;
00099
00100
00101 init_scalars_ctrsen( &job, &compq, &n, &ldt, &ldq, &lwork );
00102 ldt_r = n+2;
00103 ldq_r = n+2;
00104 job_i = job;
00105 compq_i = compq;
00106 n_i = n;
00107 ldt_i = ldt;
00108 ldq_i = ldq;
00109 lwork_i = lwork;
00110
00111
00112 select = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
00113 t = (lapack_complex_float *)
00114 LAPACKE_malloc( ldt*n * sizeof(lapack_complex_float) );
00115 q = (lapack_complex_float *)
00116 LAPACKE_malloc( ldq*n * sizeof(lapack_complex_float) );
00117 w = (lapack_complex_float *)
00118 LAPACKE_malloc( n * sizeof(lapack_complex_float) );
00119 work = (lapack_complex_float *)
00120 LAPACKE_malloc( lwork * sizeof(lapack_complex_float) );
00121
00122
00123 select_i = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
00124 t_i = (lapack_complex_float *)
00125 LAPACKE_malloc( ldt*n * sizeof(lapack_complex_float) );
00126 q_i = (lapack_complex_float *)
00127 LAPACKE_malloc( ldq*n * sizeof(lapack_complex_float) );
00128 w_i = (lapack_complex_float *)
00129 LAPACKE_malloc( n * sizeof(lapack_complex_float) );
00130 work_i = (lapack_complex_float *)
00131 LAPACKE_malloc( lwork * sizeof(lapack_complex_float) );
00132
00133
00134 t_save = (lapack_complex_float *)
00135 LAPACKE_malloc( ldt*n * sizeof(lapack_complex_float) );
00136 q_save = (lapack_complex_float *)
00137 LAPACKE_malloc( ldq*n * sizeof(lapack_complex_float) );
00138 w_save = (lapack_complex_float *)
00139 LAPACKE_malloc( n * sizeof(lapack_complex_float) );
00140
00141
00142 t_r = (lapack_complex_float *)
00143 LAPACKE_malloc( n*(n+2) * sizeof(lapack_complex_float) );
00144 q_r = (lapack_complex_float *)
00145 LAPACKE_malloc( n*(n+2) * sizeof(lapack_complex_float) );
00146
00147
00148 init_select( n, select );
00149 init_t( ldt*n, t );
00150 init_q( ldq*n, q );
00151 init_w( n, w );
00152 init_work( lwork, work );
00153
00154
00155 for( i = 0; i < ldt*n; i++ ) {
00156 t_save[i] = t[i];
00157 }
00158 for( i = 0; i < ldq*n; i++ ) {
00159 q_save[i] = q[i];
00160 }
00161 for( i = 0; i < n; i++ ) {
00162 w_save[i] = w[i];
00163 }
00164
00165
00166 ctrsen_( &job, &compq, select, &n, t, &ldt, q, &ldq, w, &m, &s, &sep, work,
00167 &lwork, &info );
00168
00169
00170
00171 for( i = 0; i < n; i++ ) {
00172 select_i[i] = select[i];
00173 }
00174 for( i = 0; i < ldt*n; i++ ) {
00175 t_i[i] = t_save[i];
00176 }
00177 for( i = 0; i < ldq*n; i++ ) {
00178 q_i[i] = q_save[i];
00179 }
00180 for( i = 0; i < n; i++ ) {
00181 w_i[i] = w_save[i];
00182 }
00183 for( i = 0; i < lwork; i++ ) {
00184 work_i[i] = work[i];
00185 }
00186 info_i = LAPACKE_ctrsen_work( LAPACK_COL_MAJOR, job_i, compq_i, select_i,
00187 n_i, t_i, ldt_i, q_i, ldq_i, w_i, &m_i, &s_i,
00188 &sep_i, work_i, lwork_i );
00189
00190 failed = compare_ctrsen( t, t_i, q, q_i, w, w_i, m, m_i, s, s_i, sep, sep_i,
00191 info, info_i, compq, ldq, ldt, n );
00192 if( failed == 0 ) {
00193 printf( "PASSED: column-major middle-level interface to ctrsen\n" );
00194 } else {
00195 printf( "FAILED: column-major middle-level interface to ctrsen\n" );
00196 }
00197
00198
00199
00200 for( i = 0; i < n; i++ ) {
00201 select_i[i] = select[i];
00202 }
00203 for( i = 0; i < ldt*n; i++ ) {
00204 t_i[i] = t_save[i];
00205 }
00206 for( i = 0; i < ldq*n; i++ ) {
00207 q_i[i] = q_save[i];
00208 }
00209 for( i = 0; i < n; i++ ) {
00210 w_i[i] = w_save[i];
00211 }
00212 for( i = 0; i < lwork; i++ ) {
00213 work_i[i] = work[i];
00214 }
00215 info_i = LAPACKE_ctrsen( LAPACK_COL_MAJOR, job_i, compq_i, select_i, n_i,
00216 t_i, ldt_i, q_i, ldq_i, w_i, &m_i, &s_i, &sep_i );
00217
00218 failed = compare_ctrsen( t, t_i, q, q_i, w, w_i, m, m_i, s, s_i, sep, sep_i,
00219 info, info_i, compq, ldq, ldt, n );
00220 if( failed == 0 ) {
00221 printf( "PASSED: column-major high-level interface to ctrsen\n" );
00222 } else {
00223 printf( "FAILED: column-major high-level interface to ctrsen\n" );
00224 }
00225
00226
00227
00228 for( i = 0; i < n; i++ ) {
00229 select_i[i] = select[i];
00230 }
00231 for( i = 0; i < ldt*n; i++ ) {
00232 t_i[i] = t_save[i];
00233 }
00234 for( i = 0; i < ldq*n; i++ ) {
00235 q_i[i] = q_save[i];
00236 }
00237 for( i = 0; i < n; i++ ) {
00238 w_i[i] = w_save[i];
00239 }
00240 for( i = 0; i < lwork; i++ ) {
00241 work_i[i] = work[i];
00242 }
00243
00244 LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, n, t_i, ldt, t_r, n+2 );
00245 if( LAPACKE_lsame( compq, 'v' ) ) {
00246 LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, n, q_i, ldq, q_r, n+2 );
00247 }
00248 info_i = LAPACKE_ctrsen_work( LAPACK_ROW_MAJOR, job_i, compq_i, select_i,
00249 n_i, t_r, ldt_r, q_r, ldq_r, w_i, &m_i, &s_i,
00250 &sep_i, work_i, lwork_i );
00251
00252 LAPACKE_cge_trans( LAPACK_ROW_MAJOR, n, n, t_r, n+2, t_i, ldt );
00253 if( LAPACKE_lsame( compq, 'v' ) ) {
00254 LAPACKE_cge_trans( LAPACK_ROW_MAJOR, n, n, q_r, n+2, q_i, ldq );
00255 }
00256
00257 failed = compare_ctrsen( t, t_i, q, q_i, w, w_i, m, m_i, s, s_i, sep, sep_i,
00258 info, info_i, compq, ldq, ldt, n );
00259 if( failed == 0 ) {
00260 printf( "PASSED: row-major middle-level interface to ctrsen\n" );
00261 } else {
00262 printf( "FAILED: row-major middle-level interface to ctrsen\n" );
00263 }
00264
00265
00266
00267 for( i = 0; i < n; i++ ) {
00268 select_i[i] = select[i];
00269 }
00270 for( i = 0; i < ldt*n; i++ ) {
00271 t_i[i] = t_save[i];
00272 }
00273 for( i = 0; i < ldq*n; i++ ) {
00274 q_i[i] = q_save[i];
00275 }
00276 for( i = 0; i < n; i++ ) {
00277 w_i[i] = w_save[i];
00278 }
00279 for( i = 0; i < lwork; i++ ) {
00280 work_i[i] = work[i];
00281 }
00282
00283
00284 LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, n, t_i, ldt, t_r, n+2 );
00285 if( LAPACKE_lsame( compq, 'v' ) ) {
00286 LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, n, q_i, ldq, q_r, n+2 );
00287 }
00288 info_i = LAPACKE_ctrsen( LAPACK_ROW_MAJOR, job_i, compq_i, select_i, n_i,
00289 t_r, ldt_r, q_r, ldq_r, w_i, &m_i, &s_i, &sep_i );
00290
00291 LAPACKE_cge_trans( LAPACK_ROW_MAJOR, n, n, t_r, n+2, t_i, ldt );
00292 if( LAPACKE_lsame( compq, 'v' ) ) {
00293 LAPACKE_cge_trans( LAPACK_ROW_MAJOR, n, n, q_r, n+2, q_i, ldq );
00294 }
00295
00296 failed = compare_ctrsen( t, t_i, q, q_i, w, w_i, m, m_i, s, s_i, sep, sep_i,
00297 info, info_i, compq, ldq, ldt, n );
00298 if( failed == 0 ) {
00299 printf( "PASSED: row-major high-level interface to ctrsen\n" );
00300 } else {
00301 printf( "FAILED: row-major high-level interface to ctrsen\n" );
00302 }
00303
00304
00305 if( select != NULL ) {
00306 LAPACKE_free( select );
00307 }
00308 if( select_i != NULL ) {
00309 LAPACKE_free( select_i );
00310 }
00311 if( t != NULL ) {
00312 LAPACKE_free( t );
00313 }
00314 if( t_i != NULL ) {
00315 LAPACKE_free( t_i );
00316 }
00317 if( t_r != NULL ) {
00318 LAPACKE_free( t_r );
00319 }
00320 if( t_save != NULL ) {
00321 LAPACKE_free( t_save );
00322 }
00323 if( q != NULL ) {
00324 LAPACKE_free( q );
00325 }
00326 if( q_i != NULL ) {
00327 LAPACKE_free( q_i );
00328 }
00329 if( q_r != NULL ) {
00330 LAPACKE_free( q_r );
00331 }
00332 if( q_save != NULL ) {
00333 LAPACKE_free( q_save );
00334 }
00335 if( w != NULL ) {
00336 LAPACKE_free( w );
00337 }
00338 if( w_i != NULL ) {
00339 LAPACKE_free( w_i );
00340 }
00341 if( w_save != NULL ) {
00342 LAPACKE_free( w_save );
00343 }
00344 if( work != NULL ) {
00345 LAPACKE_free( work );
00346 }
00347 if( work_i != NULL ) {
00348 LAPACKE_free( work_i );
00349 }
00350
00351 return 0;
00352 }
00353
00354
00355 static void init_scalars_ctrsen( char *job, char *compq, lapack_int *n,
00356 lapack_int *ldt, lapack_int *ldq,
00357 lapack_int *lwork )
00358 {
00359 *job = 'B';
00360 *compq = 'V';
00361 *n = 4;
00362 *ldt = 8;
00363 *ldq = 8;
00364 *lwork = 32;
00365
00366 return;
00367 }
00368
00369
00370 static void init_select( lapack_int size, lapack_int *select ) {
00371 lapack_int i;
00372 for( i = 0; i < size; i++ ) {
00373 select[i] = 0;
00374 }
00375 select[0] = -1;
00376 select[1] = 0;
00377 select[2] = 0;
00378 select[3] = -1;
00379 }
00380 static void init_t( lapack_int size, lapack_complex_float *t ) {
00381 lapack_int i;
00382 for( i = 0; i < size; i++ ) {
00383 t[i] = lapack_make_complex_float( 0.0f, 0.0f );
00384 }
00385 t[0] = lapack_make_complex_float( -6.000400066e+000, -6.999899864e+000 );
00386 t[8] = lapack_make_complex_float( 3.637000024e-001, -3.655999899e-001 );
00387 t[16] = lapack_make_complex_float( -1.879999936e-001, 4.787000120e-001 );
00388 t[24] = lapack_make_complex_float( 8.784999847e-001, -2.538999915e-001 );
00389 t[1] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00390 t[9] = lapack_make_complex_float( -5.000000000e+000, 2.006000042e+000 );
00391 t[17] = lapack_make_complex_float( -3.070000000e-002, -7.217000127e-001 );
00392 t[25] = lapack_make_complex_float( -2.290000021e-001, 1.313000023e-001 );
00393 t[2] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00394 t[10] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00395 t[18] = lapack_make_complex_float( 7.998199940e+000, -9.963999987e-001 );
00396 t[26] = lapack_make_complex_float( 9.356999993e-001, 5.358999968e-001 );
00397 t[3] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00398 t[11] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00399 t[19] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00400 t[27] = lapack_make_complex_float( 3.002300024e+000, -3.999799967e+000 );
00401 }
00402 static void init_q( lapack_int size, lapack_complex_float *q ) {
00403 lapack_int i;
00404 for( i = 0; i < size; i++ ) {
00405 q[i] = lapack_make_complex_float( 0.0f, 0.0f );
00406 }
00407 q[0] = lapack_make_complex_float( -8.346999884e-001, -1.363999993e-001 );
00408 q[8] = lapack_make_complex_float( -6.279999763e-002, 3.806000054e-001 );
00409 q[16] = lapack_make_complex_float( 2.764999866e-001, -8.460000157e-002 );
00410 q[24] = lapack_make_complex_float( 6.329999864e-002, -2.198999971e-001 );
00411 q[1] = lapack_make_complex_float( 6.639999896e-002, -2.967999876e-001 );
00412 q[9] = lapack_make_complex_float( 2.364999950e-001, 5.239999890e-001 );
00413 q[17] = lapack_make_complex_float( -5.877000093e-001, -4.208000004e-001 );
00414 q[25] = lapack_make_complex_float( 8.349999785e-002, 2.182999998e-001 );
00415 q[2] = lapack_make_complex_float( -3.620000184e-002, -3.215000033e-001 );
00416 q[10] = lapack_make_complex_float( 3.143000007e-001, -5.472999811e-001 );
00417 q[18] = lapack_make_complex_float( 5.759999901e-002, -5.735999942e-001 );
00418 q[26] = lapack_make_complex_float( 5.700000096e-003, -4.058000147e-001 );
00419 q[3] = lapack_make_complex_float( 8.600000292e-003, 2.958000004e-001 );
00420 q[11] = lapack_make_complex_float( -3.416000009e-001, -7.569999993e-002 );
00421 q[19] = lapack_make_complex_float( -1.899999976e-001, -1.599999964e-001 );
00422 q[27] = lapack_make_complex_float( 8.327000141e-001, -1.868000031e-001 );
00423 }
00424 static void init_w( lapack_int size, lapack_complex_float *w ) {
00425 lapack_int i;
00426 for( i = 0; i < size; i++ ) {
00427 w[i] = lapack_make_complex_float( 0.0f, 0.0f );
00428 }
00429 }
00430 static void init_work( lapack_int size, lapack_complex_float *work ) {
00431 lapack_int i;
00432 for( i = 0; i < size; i++ ) {
00433 work[i] = lapack_make_complex_float( 0.0f, 0.0f );
00434 }
00435 }
00436
00437
00438
00439 static int compare_ctrsen( lapack_complex_float *t, lapack_complex_float *t_i,
00440 lapack_complex_float *q, lapack_complex_float *q_i,
00441 lapack_complex_float *w, lapack_complex_float *w_i,
00442 lapack_int m, lapack_int m_i, float s, float s_i,
00443 float sep, float sep_i, lapack_int info,
00444 lapack_int info_i, char compq, lapack_int ldq,
00445 lapack_int ldt, lapack_int n )
00446 {
00447 lapack_int i;
00448 int failed = 0;
00449 for( i = 0; i < ldt*n; i++ ) {
00450 failed += compare_complex_floats(t[i],t_i[i]);
00451 }
00452 if( LAPACKE_lsame( compq, 'v' ) ) {
00453 for( i = 0; i < ldq*n; i++ ) {
00454 failed += compare_complex_floats(q[i],q_i[i]);
00455 }
00456 }
00457 for( i = 0; i < n; i++ ) {
00458 failed += compare_complex_floats(w[i],w_i[i]);
00459 }
00460 failed += (m == m_i) ? 0 : 1;
00461 failed += compare_floats(s,s_i);
00462 failed += compare_floats(sep,sep_i);
00463 failed += (info == info_i) ? 0 : 1;
00464 if( info != 0 || info_i != 0 ) {
00465 printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00466 }
00467
00468 return failed;
00469 }