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_ztrsen( 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_double *t );
00059 static void init_q( lapack_int size, lapack_complex_double *q );
00060 static void init_w( lapack_int size, lapack_complex_double *w );
00061 static void init_work( lapack_int size, lapack_complex_double *work );
00062 static int compare_ztrsen( lapack_complex_double *t, lapack_complex_double *t_i,
00063 lapack_complex_double *q, lapack_complex_double *q_i,
00064 lapack_complex_double *w, lapack_complex_double *w_i,
00065 lapack_int m, lapack_int m_i, double s, double s_i,
00066 double sep, double 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 double s, s_i;
00082 double 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_double *t = NULL, *t_i = NULL;
00091 lapack_complex_double *q = NULL, *q_i = NULL;
00092 lapack_complex_double *w = NULL, *w_i = NULL;
00093 lapack_complex_double *work = NULL, *work_i = NULL;
00094 lapack_complex_double *t_save = NULL;
00095 lapack_complex_double *q_save = NULL;
00096 lapack_complex_double *w_save = NULL;
00097 lapack_complex_double *t_r = NULL;
00098 lapack_complex_double *q_r = NULL;
00099
00100
00101 init_scalars_ztrsen( &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_double *)
00114 LAPACKE_malloc( ldt*n * sizeof(lapack_complex_double) );
00115 q = (lapack_complex_double *)
00116 LAPACKE_malloc( ldq*n * sizeof(lapack_complex_double) );
00117 w = (lapack_complex_double *)
00118 LAPACKE_malloc( n * sizeof(lapack_complex_double) );
00119 work = (lapack_complex_double *)
00120 LAPACKE_malloc( lwork * sizeof(lapack_complex_double) );
00121
00122
00123 select_i = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
00124 t_i = (lapack_complex_double *)
00125 LAPACKE_malloc( ldt*n * sizeof(lapack_complex_double) );
00126 q_i = (lapack_complex_double *)
00127 LAPACKE_malloc( ldq*n * sizeof(lapack_complex_double) );
00128 w_i = (lapack_complex_double *)
00129 LAPACKE_malloc( n * sizeof(lapack_complex_double) );
00130 work_i = (lapack_complex_double *)
00131 LAPACKE_malloc( lwork * sizeof(lapack_complex_double) );
00132
00133
00134 t_save = (lapack_complex_double *)
00135 LAPACKE_malloc( ldt*n * sizeof(lapack_complex_double) );
00136 q_save = (lapack_complex_double *)
00137 LAPACKE_malloc( ldq*n * sizeof(lapack_complex_double) );
00138 w_save = (lapack_complex_double *)
00139 LAPACKE_malloc( n * sizeof(lapack_complex_double) );
00140
00141
00142 t_r = (lapack_complex_double *)
00143 LAPACKE_malloc( n*(n+2) * sizeof(lapack_complex_double) );
00144 q_r = (lapack_complex_double *)
00145 LAPACKE_malloc( n*(n+2) * sizeof(lapack_complex_double) );
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 ztrsen_( &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_ztrsen_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_ztrsen( 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 ztrsen\n" );
00194 } else {
00195 printf( "FAILED: column-major middle-level interface to ztrsen\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_ztrsen( 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_ztrsen( 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 ztrsen\n" );
00222 } else {
00223 printf( "FAILED: column-major high-level interface to ztrsen\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_zge_trans( LAPACK_COL_MAJOR, n, n, t_i, ldt, t_r, n+2 );
00245 if( LAPACKE_lsame( compq, 'v' ) ) {
00246 LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, n, q_i, ldq, q_r, n+2 );
00247 }
00248 info_i = LAPACKE_ztrsen_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_zge_trans( LAPACK_ROW_MAJOR, n, n, t_r, n+2, t_i, ldt );
00253 if( LAPACKE_lsame( compq, 'v' ) ) {
00254 LAPACKE_zge_trans( LAPACK_ROW_MAJOR, n, n, q_r, n+2, q_i, ldq );
00255 }
00256
00257 failed = compare_ztrsen( 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 ztrsen\n" );
00261 } else {
00262 printf( "FAILED: row-major middle-level interface to ztrsen\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_zge_trans( LAPACK_COL_MAJOR, n, n, t_i, ldt, t_r, n+2 );
00285 if( LAPACKE_lsame( compq, 'v' ) ) {
00286 LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, n, q_i, ldq, q_r, n+2 );
00287 }
00288 info_i = LAPACKE_ztrsen( 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_zge_trans( LAPACK_ROW_MAJOR, n, n, t_r, n+2, t_i, ldt );
00292 if( LAPACKE_lsame( compq, 'v' ) ) {
00293 LAPACKE_zge_trans( LAPACK_ROW_MAJOR, n, n, q_r, n+2, q_i, ldq );
00294 }
00295
00296 failed = compare_ztrsen( 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 ztrsen\n" );
00300 } else {
00301 printf( "FAILED: row-major high-level interface to ztrsen\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_ztrsen( 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_double *t ) {
00381 lapack_int i;
00382 for( i = 0; i < size; i++ ) {
00383 t[i] = lapack_make_complex_double( 0.0, 0.0 );
00384 }
00385 t[0] = lapack_make_complex_double( -6.00040000000000000e+000,
00386 -6.99990000000000020e+000 );
00387 t[8] = lapack_make_complex_double( 3.63700000000000020e-001,
00388 -3.65599999999999980e-001 );
00389 t[16] = lapack_make_complex_double( -1.88000000000000000e-001,
00390 4.78700000000000010e-001 );
00391 t[24] = lapack_make_complex_double( 8.78499999999999950e-001,
00392 -2.53900000000000010e-001 );
00393 t[1] = lapack_make_complex_double( 0.00000000000000000e+000,
00394 0.00000000000000000e+000 );
00395 t[9] = lapack_make_complex_double( -5.00000000000000000e+000,
00396 2.00599999999999980e+000 );
00397 t[17] = lapack_make_complex_double( -3.07000000000000020e-002,
00398 -7.21700000000000010e-001 );
00399 t[25] = lapack_make_complex_double( -2.29000000000000010e-001,
00400 1.31300000000000000e-001 );
00401 t[2] = lapack_make_complex_double( 0.00000000000000000e+000,
00402 0.00000000000000000e+000 );
00403 t[10] = lapack_make_complex_double( 0.00000000000000000e+000,
00404 0.00000000000000000e+000 );
00405 t[18] = lapack_make_complex_double( 7.99819999999999980e+000,
00406 -9.96399999999999950e-001 );
00407 t[26] = lapack_make_complex_double( 9.35699999999999980e-001,
00408 5.35900000000000040e-001 );
00409 t[3] = lapack_make_complex_double( 0.00000000000000000e+000,
00410 0.00000000000000000e+000 );
00411 t[11] = lapack_make_complex_double( 0.00000000000000000e+000,
00412 0.00000000000000000e+000 );
00413 t[19] = lapack_make_complex_double( 0.00000000000000000e+000,
00414 0.00000000000000000e+000 );
00415 t[27] = lapack_make_complex_double( 3.00230000000000000e+000,
00416 -3.99980000000000000e+000 );
00417 }
00418 static void init_q( lapack_int size, lapack_complex_double *q ) {
00419 lapack_int i;
00420 for( i = 0; i < size; i++ ) {
00421 q[i] = lapack_make_complex_double( 0.0, 0.0 );
00422 }
00423 q[0] = lapack_make_complex_double( -8.34700000000000000e-001,
00424 -1.36399999999999990e-001 );
00425 q[8] = lapack_make_complex_double( -6.27999999999999950e-002,
00426 3.80599999999999990e-001 );
00427 q[16] = lapack_make_complex_double( 2.76500000000000020e-001,
00428 -8.45999999999999950e-002 );
00429 q[24] = lapack_make_complex_double( 6.32999999999999950e-002,
00430 -2.19900000000000010e-001 );
00431 q[1] = lapack_make_complex_double( 6.64000000000000010e-002,
00432 -2.96800000000000010e-001 );
00433 q[9] = lapack_make_complex_double( 2.36499999999999990e-001,
00434 5.24000000000000020e-001 );
00435 q[17] = lapack_make_complex_double( -5.87700000000000000e-001,
00436 -4.20800000000000010e-001 );
00437 q[25] = lapack_make_complex_double( 8.35000000000000050e-002,
00438 2.18299999999999990e-001 );
00439 q[2] = lapack_make_complex_double( -3.62000000000000030e-002,
00440 -3.21500000000000010e-001 );
00441 q[10] = lapack_make_complex_double( 3.14300000000000020e-001,
00442 -5.47300000000000010e-001 );
00443 q[18] = lapack_make_complex_double( 5.75999999999999980e-002,
00444 -5.73600000000000000e-001 );
00445 q[26] = lapack_make_complex_double( 5.70000000000000020e-003,
00446 -4.05799999999999990e-001 );
00447 q[3] = lapack_make_complex_double( 8.60000000000000000e-003,
00448 2.95800000000000010e-001 );
00449 q[11] = lapack_make_complex_double( -3.41600000000000010e-001,
00450 -7.57000000000000030e-002 );
00451 q[19] = lapack_make_complex_double( -1.90000000000000000e-001,
00452 -1.60000000000000000e-001 );
00453 q[27] = lapack_make_complex_double( 8.32700000000000000e-001,
00454 -1.86799999999999990e-001 );
00455 }
00456 static void init_w( lapack_int size, lapack_complex_double *w ) {
00457 lapack_int i;
00458 for( i = 0; i < size; i++ ) {
00459 w[i] = lapack_make_complex_double( 0.0, 0.0 );
00460 }
00461 }
00462 static void init_work( lapack_int size, lapack_complex_double *work ) {
00463 lapack_int i;
00464 for( i = 0; i < size; i++ ) {
00465 work[i] = lapack_make_complex_double( 0.0, 0.0 );
00466 }
00467 }
00468
00469
00470
00471 static int compare_ztrsen( lapack_complex_double *t, lapack_complex_double *t_i,
00472 lapack_complex_double *q, lapack_complex_double *q_i,
00473 lapack_complex_double *w, lapack_complex_double *w_i,
00474 lapack_int m, lapack_int m_i, double s, double s_i,
00475 double sep, double sep_i, lapack_int info,
00476 lapack_int info_i, char compq, lapack_int ldq,
00477 lapack_int ldt, lapack_int n )
00478 {
00479 lapack_int i;
00480 int failed = 0;
00481 for( i = 0; i < ldt*n; i++ ) {
00482 failed += compare_complex_doubles(t[i],t_i[i]);
00483 }
00484 if( LAPACKE_lsame( compq, 'v' ) ) {
00485 for( i = 0; i < ldq*n; i++ ) {
00486 failed += compare_complex_doubles(q[i],q_i[i]);
00487 }
00488 }
00489 for( i = 0; i < n; i++ ) {
00490 failed += compare_complex_doubles(w[i],w_i[i]);
00491 }
00492 failed += (m == m_i) ? 0 : 1;
00493 failed += compare_doubles(s,s_i);
00494 failed += compare_doubles(sep,sep_i);
00495 failed += (info == info_i) ? 0 : 1;
00496 if( info != 0 || info_i != 0 ) {
00497 printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00498 }
00499
00500 return failed;
00501 }