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_ztrexc( char *compq, lapack_int *n, lapack_int *ldt,
00055 lapack_int *ldq, lapack_int *ifst,
00056 lapack_int *ilst );
00057 static void init_t( lapack_int size, lapack_complex_double *t );
00058 static void init_q( lapack_int size, lapack_complex_double *q );
00059 static int compare_ztrexc( lapack_complex_double *t, lapack_complex_double *t_i,
00060 lapack_complex_double *q, lapack_complex_double *q_i,
00061 lapack_int info, lapack_int info_i, char compq,
00062 lapack_int ldq, lapack_int ldt, lapack_int n );
00063
00064 int main(void)
00065 {
00066
00067 char compq, compq_i;
00068 lapack_int n, n_i;
00069 lapack_int ldt, ldt_i;
00070 lapack_int ldt_r;
00071 lapack_int ldq, ldq_i;
00072 lapack_int ldq_r;
00073 lapack_int ifst, ifst_i;
00074 lapack_int ilst, ilst_i;
00075 lapack_int info, info_i;
00076 lapack_int i;
00077 int failed;
00078
00079
00080 lapack_complex_double *t = NULL, *t_i = NULL;
00081 lapack_complex_double *q = NULL, *q_i = NULL;
00082 lapack_complex_double *t_save = NULL;
00083 lapack_complex_double *q_save = NULL;
00084 lapack_complex_double *t_r = NULL;
00085 lapack_complex_double *q_r = NULL;
00086
00087
00088 init_scalars_ztrexc( &compq, &n, &ldt, &ldq, &ifst, &ilst );
00089 ldt_r = n+2;
00090 ldq_r = n+2;
00091 compq_i = compq;
00092 n_i = n;
00093 ldt_i = ldt;
00094 ldq_i = ldq;
00095 ifst_i = ifst;
00096 ilst_i = ilst;
00097
00098
00099 t = (lapack_complex_double *)
00100 LAPACKE_malloc( ldt*n * sizeof(lapack_complex_double) );
00101 q = (lapack_complex_double *)
00102 LAPACKE_malloc( ldq*n * sizeof(lapack_complex_double) );
00103
00104
00105 t_i = (lapack_complex_double *)
00106 LAPACKE_malloc( ldt*n * sizeof(lapack_complex_double) );
00107 q_i = (lapack_complex_double *)
00108 LAPACKE_malloc( ldq*n * sizeof(lapack_complex_double) );
00109
00110
00111 t_save = (lapack_complex_double *)
00112 LAPACKE_malloc( ldt*n * sizeof(lapack_complex_double) );
00113 q_save = (lapack_complex_double *)
00114 LAPACKE_malloc( ldq*n * sizeof(lapack_complex_double) );
00115
00116
00117 t_r = (lapack_complex_double *)
00118 LAPACKE_malloc( n*(n+2) * sizeof(lapack_complex_double) );
00119 q_r = (lapack_complex_double *)
00120 LAPACKE_malloc( n*(n+2) * sizeof(lapack_complex_double) );
00121
00122
00123 init_t( ldt*n, t );
00124 init_q( ldq*n, q );
00125
00126
00127 for( i = 0; i < ldt*n; i++ ) {
00128 t_save[i] = t[i];
00129 }
00130 for( i = 0; i < ldq*n; i++ ) {
00131 q_save[i] = q[i];
00132 }
00133
00134
00135 ztrexc_( &compq, &n, t, &ldt, q, &ldq, &ifst, &ilst, &info );
00136
00137
00138
00139 for( i = 0; i < ldt*n; i++ ) {
00140 t_i[i] = t_save[i];
00141 }
00142 for( i = 0; i < ldq*n; i++ ) {
00143 q_i[i] = q_save[i];
00144 }
00145 info_i = LAPACKE_ztrexc_work( LAPACK_COL_MAJOR, compq_i, n_i, t_i, ldt_i,
00146 q_i, ldq_i, ifst_i, ilst_i );
00147
00148 failed = compare_ztrexc( t, t_i, q, q_i, info, info_i, compq, ldq, ldt, n );
00149 if( failed == 0 ) {
00150 printf( "PASSED: column-major middle-level interface to ztrexc\n" );
00151 } else {
00152 printf( "FAILED: column-major middle-level interface to ztrexc\n" );
00153 }
00154
00155
00156
00157 for( i = 0; i < ldt*n; i++ ) {
00158 t_i[i] = t_save[i];
00159 }
00160 for( i = 0; i < ldq*n; i++ ) {
00161 q_i[i] = q_save[i];
00162 }
00163 info_i = LAPACKE_ztrexc( LAPACK_COL_MAJOR, compq_i, n_i, t_i, ldt_i, q_i,
00164 ldq_i, ifst_i, ilst_i );
00165
00166 failed = compare_ztrexc( t, t_i, q, q_i, info, info_i, compq, ldq, ldt, n );
00167 if( failed == 0 ) {
00168 printf( "PASSED: column-major high-level interface to ztrexc\n" );
00169 } else {
00170 printf( "FAILED: column-major high-level interface to ztrexc\n" );
00171 }
00172
00173
00174
00175 for( i = 0; i < ldt*n; i++ ) {
00176 t_i[i] = t_save[i];
00177 }
00178 for( i = 0; i < ldq*n; i++ ) {
00179 q_i[i] = q_save[i];
00180 }
00181
00182 LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, n, t_i, ldt, t_r, n+2 );
00183 if( LAPACKE_lsame( compq, 'v' ) ) {
00184 LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, n, q_i, ldq, q_r, n+2 );
00185 }
00186 info_i = LAPACKE_ztrexc_work( LAPACK_ROW_MAJOR, compq_i, n_i, t_r, ldt_r,
00187 q_r, ldq_r, ifst_i, ilst_i );
00188
00189 LAPACKE_zge_trans( LAPACK_ROW_MAJOR, n, n, t_r, n+2, t_i, ldt );
00190 if( LAPACKE_lsame( compq, 'v' ) ) {
00191 LAPACKE_zge_trans( LAPACK_ROW_MAJOR, n, n, q_r, n+2, q_i, ldq );
00192 }
00193
00194 failed = compare_ztrexc( t, t_i, q, q_i, info, info_i, compq, ldq, ldt, n );
00195 if( failed == 0 ) {
00196 printf( "PASSED: row-major middle-level interface to ztrexc\n" );
00197 } else {
00198 printf( "FAILED: row-major middle-level interface to ztrexc\n" );
00199 }
00200
00201
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
00210
00211 LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, n, t_i, ldt, t_r, n+2 );
00212 if( LAPACKE_lsame( compq, 'v' ) ) {
00213 LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, n, q_i, ldq, q_r, n+2 );
00214 }
00215 info_i = LAPACKE_ztrexc( LAPACK_ROW_MAJOR, compq_i, n_i, t_r, ldt_r, q_r,
00216 ldq_r, ifst_i, ilst_i );
00217
00218 LAPACKE_zge_trans( LAPACK_ROW_MAJOR, n, n, t_r, n+2, t_i, ldt );
00219 if( LAPACKE_lsame( compq, 'v' ) ) {
00220 LAPACKE_zge_trans( LAPACK_ROW_MAJOR, n, n, q_r, n+2, q_i, ldq );
00221 }
00222
00223 failed = compare_ztrexc( t, t_i, q, q_i, info, info_i, compq, ldq, ldt, n );
00224 if( failed == 0 ) {
00225 printf( "PASSED: row-major high-level interface to ztrexc\n" );
00226 } else {
00227 printf( "FAILED: row-major high-level interface to ztrexc\n" );
00228 }
00229
00230
00231 if( t != NULL ) {
00232 LAPACKE_free( t );
00233 }
00234 if( t_i != NULL ) {
00235 LAPACKE_free( t_i );
00236 }
00237 if( t_r != NULL ) {
00238 LAPACKE_free( t_r );
00239 }
00240 if( t_save != NULL ) {
00241 LAPACKE_free( t_save );
00242 }
00243 if( q != NULL ) {
00244 LAPACKE_free( q );
00245 }
00246 if( q_i != NULL ) {
00247 LAPACKE_free( q_i );
00248 }
00249 if( q_r != NULL ) {
00250 LAPACKE_free( q_r );
00251 }
00252 if( q_save != NULL ) {
00253 LAPACKE_free( q_save );
00254 }
00255
00256 return 0;
00257 }
00258
00259
00260 static void init_scalars_ztrexc( char *compq, lapack_int *n, lapack_int *ldt,
00261 lapack_int *ldq, lapack_int *ifst,
00262 lapack_int *ilst )
00263 {
00264 *compq = 'N';
00265 *n = 4;
00266 *ldt = 8;
00267 *ldq = 1;
00268 *ifst = 1;
00269 *ilst = 4;
00270
00271 return;
00272 }
00273
00274
00275 static void init_t( lapack_int size, lapack_complex_double *t ) {
00276 lapack_int i;
00277 for( i = 0; i < size; i++ ) {
00278 t[i] = lapack_make_complex_double( 0.0, 0.0 );
00279 }
00280 t[0] = lapack_make_complex_double( -6.00000000000000000e+000,
00281 -7.00000000000000000e+000 );
00282 t[8] = lapack_make_complex_double( 3.59999999999999990e-001,
00283 -3.59999999999999990e-001 );
00284 t[16] = lapack_make_complex_double( -1.90000000000000000e-001,
00285 4.79999999999999980e-001 );
00286 t[24] = lapack_make_complex_double( 8.80000000000000000e-001,
00287 -2.50000000000000000e-001 );
00288 t[1] = lapack_make_complex_double( 0.00000000000000000e+000,
00289 0.00000000000000000e+000 );
00290 t[9] = lapack_make_complex_double( -5.00000000000000000e+000,
00291 2.00000000000000000e+000 );
00292 t[17] = lapack_make_complex_double( -2.99999999999999990e-002,
00293 -7.19999999999999970e-001 );
00294 t[25] = lapack_make_complex_double( -2.30000000000000010e-001,
00295 1.30000000000000000e-001 );
00296 t[2] = lapack_make_complex_double( 0.00000000000000000e+000,
00297 0.00000000000000000e+000 );
00298 t[10] = lapack_make_complex_double( 0.00000000000000000e+000,
00299 0.00000000000000000e+000 );
00300 t[18] = lapack_make_complex_double( 8.00000000000000000e+000,
00301 -1.00000000000000000e+000 );
00302 t[26] = lapack_make_complex_double( 9.39999999999999950e-001,
00303 5.30000000000000030e-001 );
00304 t[3] = lapack_make_complex_double( 0.00000000000000000e+000,
00305 0.00000000000000000e+000 );
00306 t[11] = lapack_make_complex_double( 0.00000000000000000e+000,
00307 0.00000000000000000e+000 );
00308 t[19] = lapack_make_complex_double( 0.00000000000000000e+000,
00309 0.00000000000000000e+000 );
00310 t[27] = lapack_make_complex_double( 3.00000000000000000e+000,
00311 -4.00000000000000000e+000 );
00312 }
00313 static void init_q( lapack_int size, lapack_complex_double *q ) {
00314 lapack_int i;
00315 for( i = 0; i < size; i++ ) {
00316 q[i] = lapack_make_complex_double( 0.0, 0.0 );
00317 }
00318 q[0] = lapack_make_complex_double( 0.00000000000000000e+000,
00319 0.00000000000000000e+000 );
00320 q[1] = lapack_make_complex_double( 0.00000000000000000e+000,
00321 0.00000000000000000e+000 );
00322 q[2] = lapack_make_complex_double( 0.00000000000000000e+000,
00323 0.00000000000000000e+000 );
00324 q[3] = lapack_make_complex_double( 0.00000000000000000e+000,
00325 0.00000000000000000e+000 );
00326 q[1] = lapack_make_complex_double( 0.00000000000000000e+000,
00327 0.00000000000000000e+000 );
00328 q[2] = lapack_make_complex_double( 0.00000000000000000e+000,
00329 0.00000000000000000e+000 );
00330 q[3] = lapack_make_complex_double( 0.00000000000000000e+000,
00331 0.00000000000000000e+000 );
00332 q[2] = lapack_make_complex_double( 0.00000000000000000e+000,
00333 0.00000000000000000e+000 );
00334 q[3] = lapack_make_complex_double( 0.00000000000000000e+000,
00335 0.00000000000000000e+000 );
00336 q[3] = lapack_make_complex_double( 0.00000000000000000e+000,
00337 0.00000000000000000e+000 );
00338 }
00339
00340
00341
00342 static int compare_ztrexc( lapack_complex_double *t, lapack_complex_double *t_i,
00343 lapack_complex_double *q, lapack_complex_double *q_i,
00344 lapack_int info, lapack_int info_i, char compq,
00345 lapack_int ldq, lapack_int ldt, lapack_int n )
00346 {
00347 lapack_int i;
00348 int failed = 0;
00349 for( i = 0; i < ldt*n; i++ ) {
00350 failed += compare_complex_doubles(t[i],t_i[i]);
00351 }
00352 if( LAPACKE_lsame( compq, 'v' ) ) {
00353 for( i = 0; i < ldq*n; i++ ) {
00354 failed += compare_complex_doubles(q[i],q_i[i]);
00355 }
00356 }
00357 failed += (info == info_i) ? 0 : 1;
00358 if( info != 0 || info_i != 0 ) {
00359 printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00360 }
00361
00362 return failed;
00363 }