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_dtrsen( char *job, char *compq, lapack_int *n,
00055 lapack_int *ldt, lapack_int *ldq,
00056 lapack_int *lwork, lapack_int *liwork );
00057 static void init_select( lapack_int size, lapack_int *select );
00058 static void init_t( lapack_int size, double *t );
00059 static void init_q( lapack_int size, double *q );
00060 static void init_wr( lapack_int size, double *wr );
00061 static void init_wi( lapack_int size, double *wi );
00062 static void init_work( lapack_int size, double *work );
00063 static void init_iwork( lapack_int size, lapack_int *iwork );
00064 static int compare_dtrsen( double *t, double *t_i, double *q, double *q_i,
00065 double *wr, double *wr_i, double *wi, double *wi_i,
00066 lapack_int m, lapack_int m_i, double s, double s_i,
00067 double sep, double sep_i, lapack_int info,
00068 lapack_int info_i, char compq, lapack_int ldq,
00069 lapack_int ldt, lapack_int n );
00070
00071 int main(void)
00072 {
00073
00074 char job, job_i;
00075 char compq, compq_i;
00076 lapack_int n, n_i;
00077 lapack_int ldt, ldt_i;
00078 lapack_int ldt_r;
00079 lapack_int ldq, ldq_i;
00080 lapack_int ldq_r;
00081 lapack_int m, m_i;
00082 double s, s_i;
00083 double sep, sep_i;
00084 lapack_int lwork, lwork_i;
00085 lapack_int liwork, liwork_i;
00086 lapack_int info, info_i;
00087 lapack_int i;
00088 int failed;
00089
00090
00091 lapack_int *select = NULL, *select_i = NULL;
00092 double *t = NULL, *t_i = NULL;
00093 double *q = NULL, *q_i = NULL;
00094 double *wr = NULL, *wr_i = NULL;
00095 double *wi = NULL, *wi_i = NULL;
00096 double *work = NULL, *work_i = NULL;
00097 lapack_int *iwork = NULL, *iwork_i = NULL;
00098 double *t_save = NULL;
00099 double *q_save = NULL;
00100 double *wr_save = NULL;
00101 double *wi_save = NULL;
00102 double *t_r = NULL;
00103 double *q_r = NULL;
00104
00105
00106 init_scalars_dtrsen( &job, &compq, &n, &ldt, &ldq, &lwork, &liwork );
00107 ldt_r = n+2;
00108 ldq_r = n+2;
00109 job_i = job;
00110 compq_i = compq;
00111 n_i = n;
00112 ldt_i = ldt;
00113 ldq_i = ldq;
00114 lwork_i = lwork;
00115 liwork_i = liwork;
00116
00117
00118 select = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
00119 t = (double *)LAPACKE_malloc( ldt*n * sizeof(double) );
00120 q = (double *)LAPACKE_malloc( ldq*n * sizeof(double) );
00121 wr = (double *)LAPACKE_malloc( n * sizeof(double) );
00122 wi = (double *)LAPACKE_malloc( n * sizeof(double) );
00123 work = (double *)LAPACKE_malloc( lwork * sizeof(double) );
00124 iwork = (lapack_int *)LAPACKE_malloc( liwork * sizeof(lapack_int) );
00125
00126
00127 select_i = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
00128 t_i = (double *)LAPACKE_malloc( ldt*n * sizeof(double) );
00129 q_i = (double *)LAPACKE_malloc( ldq*n * sizeof(double) );
00130 wr_i = (double *)LAPACKE_malloc( n * sizeof(double) );
00131 wi_i = (double *)LAPACKE_malloc( n * sizeof(double) );
00132 work_i = (double *)LAPACKE_malloc( lwork * sizeof(double) );
00133 iwork_i = (lapack_int *)LAPACKE_malloc( liwork * sizeof(lapack_int) );
00134
00135
00136 t_save = (double *)LAPACKE_malloc( ldt*n * sizeof(double) );
00137 q_save = (double *)LAPACKE_malloc( ldq*n * sizeof(double) );
00138 wr_save = (double *)LAPACKE_malloc( n * sizeof(double) );
00139 wi_save = (double *)LAPACKE_malloc( n * sizeof(double) );
00140
00141
00142 t_r = (double *)LAPACKE_malloc( n*(n+2) * sizeof(double) );
00143 q_r = (double *)LAPACKE_malloc( n*(n+2) * sizeof(double) );
00144
00145
00146 init_select( n, select );
00147 init_t( ldt*n, t );
00148 init_q( ldq*n, q );
00149 init_wr( n, wr );
00150 init_wi( n, wi );
00151 init_work( lwork, work );
00152 init_iwork( liwork, iwork );
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 wr_save[i] = wr[i];
00163 }
00164 for( i = 0; i < n; i++ ) {
00165 wi_save[i] = wi[i];
00166 }
00167
00168
00169 dtrsen_( &job, &compq, select, &n, t, &ldt, q, &ldq, wr, wi, &m, &s, &sep,
00170 work, &lwork, iwork, &liwork, &info );
00171
00172
00173
00174 for( i = 0; i < n; i++ ) {
00175 select_i[i] = select[i];
00176 }
00177 for( i = 0; i < ldt*n; i++ ) {
00178 t_i[i] = t_save[i];
00179 }
00180 for( i = 0; i < ldq*n; i++ ) {
00181 q_i[i] = q_save[i];
00182 }
00183 for( i = 0; i < n; i++ ) {
00184 wr_i[i] = wr_save[i];
00185 }
00186 for( i = 0; i < n; i++ ) {
00187 wi_i[i] = wi_save[i];
00188 }
00189 for( i = 0; i < lwork; i++ ) {
00190 work_i[i] = work[i];
00191 }
00192 for( i = 0; i < liwork; i++ ) {
00193 iwork_i[i] = iwork[i];
00194 }
00195 info_i = LAPACKE_dtrsen_work( LAPACK_COL_MAJOR, job_i, compq_i, select_i,
00196 n_i, t_i, ldt_i, q_i, ldq_i, wr_i, wi_i, &m_i,
00197 &s_i, &sep_i, work_i, lwork_i, iwork_i,
00198 liwork_i );
00199
00200 failed = compare_dtrsen( t, t_i, q, q_i, wr, wr_i, wi, wi_i, m, m_i, s, s_i,
00201 sep, sep_i, info, info_i, compq, ldq, ldt, n );
00202 if( failed == 0 ) {
00203 printf( "PASSED: column-major middle-level interface to dtrsen\n" );
00204 } else {
00205 printf( "FAILED: column-major middle-level interface to dtrsen\n" );
00206 }
00207
00208
00209
00210 for( i = 0; i < n; i++ ) {
00211 select_i[i] = select[i];
00212 }
00213 for( i = 0; i < ldt*n; i++ ) {
00214 t_i[i] = t_save[i];
00215 }
00216 for( i = 0; i < ldq*n; i++ ) {
00217 q_i[i] = q_save[i];
00218 }
00219 for( i = 0; i < n; i++ ) {
00220 wr_i[i] = wr_save[i];
00221 }
00222 for( i = 0; i < n; i++ ) {
00223 wi_i[i] = wi_save[i];
00224 }
00225 for( i = 0; i < lwork; i++ ) {
00226 work_i[i] = work[i];
00227 }
00228 for( i = 0; i < liwork; i++ ) {
00229 iwork_i[i] = iwork[i];
00230 }
00231 info_i = LAPACKE_dtrsen( LAPACK_COL_MAJOR, job_i, compq_i, select_i, n_i,
00232 t_i, ldt_i, q_i, ldq_i, wr_i, wi_i, &m_i, &s_i,
00233 &sep_i );
00234
00235 failed = compare_dtrsen( t, t_i, q, q_i, wr, wr_i, wi, wi_i, m, m_i, s, s_i,
00236 sep, sep_i, info, info_i, compq, ldq, ldt, n );
00237 if( failed == 0 ) {
00238 printf( "PASSED: column-major high-level interface to dtrsen\n" );
00239 } else {
00240 printf( "FAILED: column-major high-level interface to dtrsen\n" );
00241 }
00242
00243
00244
00245 for( i = 0; i < n; i++ ) {
00246 select_i[i] = select[i];
00247 }
00248 for( i = 0; i < ldt*n; i++ ) {
00249 t_i[i] = t_save[i];
00250 }
00251 for( i = 0; i < ldq*n; i++ ) {
00252 q_i[i] = q_save[i];
00253 }
00254 for( i = 0; i < n; i++ ) {
00255 wr_i[i] = wr_save[i];
00256 }
00257 for( i = 0; i < n; i++ ) {
00258 wi_i[i] = wi_save[i];
00259 }
00260 for( i = 0; i < lwork; i++ ) {
00261 work_i[i] = work[i];
00262 }
00263 for( i = 0; i < liwork; i++ ) {
00264 iwork_i[i] = iwork[i];
00265 }
00266
00267 LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, n, t_i, ldt, t_r, n+2 );
00268 if( LAPACKE_lsame( compq, 'v' ) ) {
00269 LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, n, q_i, ldq, q_r, n+2 );
00270 }
00271 info_i = LAPACKE_dtrsen_work( LAPACK_ROW_MAJOR, job_i, compq_i, select_i,
00272 n_i, t_r, ldt_r, q_r, ldq_r, wr_i, wi_i, &m_i,
00273 &s_i, &sep_i, work_i, lwork_i, iwork_i,
00274 liwork_i );
00275
00276 LAPACKE_dge_trans( LAPACK_ROW_MAJOR, n, n, t_r, n+2, t_i, ldt );
00277 if( LAPACKE_lsame( compq, 'v' ) ) {
00278 LAPACKE_dge_trans( LAPACK_ROW_MAJOR, n, n, q_r, n+2, q_i, ldq );
00279 }
00280
00281 failed = compare_dtrsen( t, t_i, q, q_i, wr, wr_i, wi, wi_i, m, m_i, s, s_i,
00282 sep, sep_i, info, info_i, compq, ldq, ldt, n );
00283 if( failed == 0 ) {
00284 printf( "PASSED: row-major middle-level interface to dtrsen\n" );
00285 } else {
00286 printf( "FAILED: row-major middle-level interface to dtrsen\n" );
00287 }
00288
00289
00290
00291 for( i = 0; i < n; i++ ) {
00292 select_i[i] = select[i];
00293 }
00294 for( i = 0; i < ldt*n; i++ ) {
00295 t_i[i] = t_save[i];
00296 }
00297 for( i = 0; i < ldq*n; i++ ) {
00298 q_i[i] = q_save[i];
00299 }
00300 for( i = 0; i < n; i++ ) {
00301 wr_i[i] = wr_save[i];
00302 }
00303 for( i = 0; i < n; i++ ) {
00304 wi_i[i] = wi_save[i];
00305 }
00306 for( i = 0; i < lwork; i++ ) {
00307 work_i[i] = work[i];
00308 }
00309 for( i = 0; i < liwork; i++ ) {
00310 iwork_i[i] = iwork[i];
00311 }
00312
00313
00314 LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, n, t_i, ldt, t_r, n+2 );
00315 if( LAPACKE_lsame( compq, 'v' ) ) {
00316 LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, n, q_i, ldq, q_r, n+2 );
00317 }
00318 info_i = LAPACKE_dtrsen( LAPACK_ROW_MAJOR, job_i, compq_i, select_i, n_i,
00319 t_r, ldt_r, q_r, ldq_r, wr_i, wi_i, &m_i, &s_i,
00320 &sep_i );
00321
00322 LAPACKE_dge_trans( LAPACK_ROW_MAJOR, n, n, t_r, n+2, t_i, ldt );
00323 if( LAPACKE_lsame( compq, 'v' ) ) {
00324 LAPACKE_dge_trans( LAPACK_ROW_MAJOR, n, n, q_r, n+2, q_i, ldq );
00325 }
00326
00327 failed = compare_dtrsen( t, t_i, q, q_i, wr, wr_i, wi, wi_i, m, m_i, s, s_i,
00328 sep, sep_i, info, info_i, compq, ldq, ldt, n );
00329 if( failed == 0 ) {
00330 printf( "PASSED: row-major high-level interface to dtrsen\n" );
00331 } else {
00332 printf( "FAILED: row-major high-level interface to dtrsen\n" );
00333 }
00334
00335
00336 if( select != NULL ) {
00337 LAPACKE_free( select );
00338 }
00339 if( select_i != NULL ) {
00340 LAPACKE_free( select_i );
00341 }
00342 if( t != NULL ) {
00343 LAPACKE_free( t );
00344 }
00345 if( t_i != NULL ) {
00346 LAPACKE_free( t_i );
00347 }
00348 if( t_r != NULL ) {
00349 LAPACKE_free( t_r );
00350 }
00351 if( t_save != NULL ) {
00352 LAPACKE_free( t_save );
00353 }
00354 if( q != NULL ) {
00355 LAPACKE_free( q );
00356 }
00357 if( q_i != NULL ) {
00358 LAPACKE_free( q_i );
00359 }
00360 if( q_r != NULL ) {
00361 LAPACKE_free( q_r );
00362 }
00363 if( q_save != NULL ) {
00364 LAPACKE_free( q_save );
00365 }
00366 if( wr != NULL ) {
00367 LAPACKE_free( wr );
00368 }
00369 if( wr_i != NULL ) {
00370 LAPACKE_free( wr_i );
00371 }
00372 if( wr_save != NULL ) {
00373 LAPACKE_free( wr_save );
00374 }
00375 if( wi != NULL ) {
00376 LAPACKE_free( wi );
00377 }
00378 if( wi_i != NULL ) {
00379 LAPACKE_free( wi_i );
00380 }
00381 if( wi_save != NULL ) {
00382 LAPACKE_free( wi_save );
00383 }
00384 if( work != NULL ) {
00385 LAPACKE_free( work );
00386 }
00387 if( work_i != NULL ) {
00388 LAPACKE_free( work_i );
00389 }
00390 if( iwork != NULL ) {
00391 LAPACKE_free( iwork );
00392 }
00393 if( iwork_i != NULL ) {
00394 LAPACKE_free( iwork_i );
00395 }
00396
00397 return 0;
00398 }
00399
00400
00401 static void init_scalars_dtrsen( char *job, char *compq, lapack_int *n,
00402 lapack_int *ldt, lapack_int *ldq,
00403 lapack_int *lwork, lapack_int *liwork )
00404 {
00405 *job = 'B';
00406 *compq = 'V';
00407 *n = 4;
00408 *ldt = 8;
00409 *ldq = 8;
00410 *lwork = 32;
00411 *liwork = 32;
00412
00413 return;
00414 }
00415
00416
00417 static void init_select( lapack_int size, lapack_int *select ) {
00418 lapack_int i;
00419 for( i = 0; i < size; i++ ) {
00420 select[i] = 0;
00421 }
00422 select[0] = -1;
00423 select[1] = 0;
00424 select[2] = 0;
00425 select[3] = -1;
00426 }
00427 static void init_t( lapack_int size, double *t ) {
00428 lapack_int i;
00429 for( i = 0; i < size; i++ ) {
00430 t[i] = 0;
00431 }
00432 t[0] = 7.99499999999999990e-001;
00433 t[8] = -1.14400000000000000e-001;
00434 t[16] = 6.00000000000000010e-003;
00435 t[24] = 3.35999999999999980e-002;
00436 t[1] = 0.00000000000000000e+000;
00437 t[9] = -9.94000000000000020e-002;
00438 t[17] = 2.47799999999999990e-001;
00439 t[25] = 3.47399999999999990e-001;
00440 t[2] = 0.00000000000000000e+000;
00441 t[10] = -6.48299999999999990e-001;
00442 t[18] = -9.94000000000000020e-002;
00443 t[26] = 2.02600000000000000e-001;
00444 t[3] = 0.00000000000000000e+000;
00445 t[11] = 0.00000000000000000e+000;
00446 t[19] = 0.00000000000000000e+000;
00447 t[27] = -1.00700000000000000e-001;
00448 }
00449 static void init_q( lapack_int size, double *q ) {
00450 lapack_int i;
00451 for( i = 0; i < size; i++ ) {
00452 q[i] = 0;
00453 }
00454 q[0] = 6.55100000000000020e-001;
00455 q[8] = 1.03700000000000000e-001;
00456 q[16] = 3.44999999999999970e-001;
00457 q[24] = 6.64100000000000020e-001;
00458 q[1] = 5.23599999999999950e-001;
00459 q[9] = -5.80699999999999990e-001;
00460 q[17] = -6.14099999999999980e-001;
00461 q[25] = -1.06800000000000010e-001;
00462 q[2] = -5.36200000000000010e-001;
00463 q[10] = -3.07300000000000020e-001;
00464 q[18] = -2.93499999999999980e-001;
00465 q[26] = 7.29299999999999950e-001;
00466 q[3] = 9.56000000000000040e-002;
00467 q[11] = 7.46700000000000030e-001;
00468 q[19] = -6.46299999999999990e-001;
00469 q[27] = 1.24900000000000000e-001;
00470 }
00471 static void init_wr( lapack_int size, double *wr ) {
00472 lapack_int i;
00473 for( i = 0; i < size; i++ ) {
00474 wr[i] = 0;
00475 }
00476 }
00477 static void init_wi( lapack_int size, double *wi ) {
00478 lapack_int i;
00479 for( i = 0; i < size; i++ ) {
00480 wi[i] = 0;
00481 }
00482 }
00483 static void init_work( lapack_int size, double *work ) {
00484 lapack_int i;
00485 for( i = 0; i < size; i++ ) {
00486 work[i] = 0;
00487 }
00488 }
00489 static void init_iwork( lapack_int size, lapack_int *iwork ) {
00490 lapack_int i;
00491 for( i = 0; i < size; i++ ) {
00492 iwork[i] = 0;
00493 }
00494 }
00495
00496
00497
00498 static int compare_dtrsen( double *t, double *t_i, double *q, double *q_i,
00499 double *wr, double *wr_i, double *wi, double *wi_i,
00500 lapack_int m, lapack_int m_i, double s, double s_i,
00501 double sep, double sep_i, lapack_int info,
00502 lapack_int info_i, char compq, lapack_int ldq,
00503 lapack_int ldt, lapack_int n )
00504 {
00505 lapack_int i;
00506 int failed = 0;
00507 for( i = 0; i < ldt*n; i++ ) {
00508 failed += compare_doubles(t[i],t_i[i]);
00509 }
00510 if( LAPACKE_lsame( compq, 'v' ) ) {
00511 for( i = 0; i < ldq*n; i++ ) {
00512 failed += compare_doubles(q[i],q_i[i]);
00513 }
00514 }
00515 for( i = 0; i < n; i++ ) {
00516 failed += compare_doubles(wr[i],wr_i[i]);
00517 }
00518 for( i = 0; i < n; i++ ) {
00519 failed += compare_doubles(wi[i],wi_i[i]);
00520 }
00521 failed += (m == m_i) ? 0 : 1;
00522 failed += compare_doubles(s,s_i);
00523 failed += compare_doubles(sep,sep_i);
00524 failed += (info == info_i) ? 0 : 1;
00525 if( info != 0 || info_i != 0 ) {
00526 printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00527 }
00528
00529 return failed;
00530 }