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_ztrsyl( char *trana, char *tranb, lapack_int *isgn,
00055 lapack_int *m, lapack_int *n, lapack_int *lda,
00056 lapack_int *ldb, lapack_int *ldc );
00057 static void init_a( lapack_int size, lapack_complex_double *a );
00058 static void init_b( lapack_int size, lapack_complex_double *b );
00059 static void init_c( lapack_int size, lapack_complex_double *c );
00060 static int compare_ztrsyl( lapack_complex_double *c, lapack_complex_double *c_i,
00061 double scale, double scale_i, lapack_int info,
00062 lapack_int info_i, lapack_int ldc, lapack_int n );
00063
00064 int main(void)
00065 {
00066
00067 char trana, trana_i;
00068 char tranb, tranb_i;
00069 lapack_int isgn, isgn_i;
00070 lapack_int m, m_i;
00071 lapack_int n, n_i;
00072 lapack_int lda, lda_i;
00073 lapack_int lda_r;
00074 lapack_int ldb, ldb_i;
00075 lapack_int ldb_r;
00076 lapack_int ldc, ldc_i;
00077 lapack_int ldc_r;
00078 double scale, scale_i;
00079 lapack_int info, info_i;
00080 lapack_int i;
00081 int failed;
00082
00083
00084 lapack_complex_double *a = NULL, *a_i = NULL;
00085 lapack_complex_double *b = NULL, *b_i = NULL;
00086 lapack_complex_double *c = NULL, *c_i = NULL;
00087 lapack_complex_double *c_save = NULL;
00088 lapack_complex_double *a_r = NULL;
00089 lapack_complex_double *b_r = NULL;
00090 lapack_complex_double *c_r = NULL;
00091
00092
00093 init_scalars_ztrsyl( &trana, &tranb, &isgn, &m, &n, &lda, &ldb, &ldc );
00094 lda_r = m+2;
00095 ldb_r = n+2;
00096 ldc_r = n+2;
00097 trana_i = trana;
00098 tranb_i = tranb;
00099 isgn_i = isgn;
00100 m_i = m;
00101 n_i = n;
00102 lda_i = lda;
00103 ldb_i = ldb;
00104 ldc_i = ldc;
00105
00106
00107 a = (lapack_complex_double *)
00108 LAPACKE_malloc( lda*m * sizeof(lapack_complex_double) );
00109 b = (lapack_complex_double *)
00110 LAPACKE_malloc( ldb*n * sizeof(lapack_complex_double) );
00111 c = (lapack_complex_double *)
00112 LAPACKE_malloc( ldc*n * sizeof(lapack_complex_double) );
00113
00114
00115 a_i = (lapack_complex_double *)
00116 LAPACKE_malloc( lda*m * sizeof(lapack_complex_double) );
00117 b_i = (lapack_complex_double *)
00118 LAPACKE_malloc( ldb*n * sizeof(lapack_complex_double) );
00119 c_i = (lapack_complex_double *)
00120 LAPACKE_malloc( ldc*n * sizeof(lapack_complex_double) );
00121
00122
00123 c_save = (lapack_complex_double *)
00124 LAPACKE_malloc( ldc*n * sizeof(lapack_complex_double) );
00125
00126
00127 a_r = (lapack_complex_double *)
00128 LAPACKE_malloc( m*(m+2) * sizeof(lapack_complex_double) );
00129 b_r = (lapack_complex_double *)
00130 LAPACKE_malloc( n*(n+2) * sizeof(lapack_complex_double) );
00131 c_r = (lapack_complex_double *)
00132 LAPACKE_malloc( m*(n+2) * sizeof(lapack_complex_double) );
00133
00134
00135 init_a( lda*m, a );
00136 init_b( ldb*n, b );
00137 init_c( ldc*n, c );
00138
00139
00140 for( i = 0; i < ldc*n; i++ ) {
00141 c_save[i] = c[i];
00142 }
00143
00144
00145 ztrsyl_( &trana, &tranb, &isgn, &m, &n, a, &lda, b, &ldb, c, &ldc, &scale,
00146 &info );
00147
00148
00149
00150 for( i = 0; i < lda*m; i++ ) {
00151 a_i[i] = a[i];
00152 }
00153 for( i = 0; i < ldb*n; i++ ) {
00154 b_i[i] = b[i];
00155 }
00156 for( i = 0; i < ldc*n; i++ ) {
00157 c_i[i] = c_save[i];
00158 }
00159 info_i = LAPACKE_ztrsyl_work( LAPACK_COL_MAJOR, trana_i, tranb_i, isgn_i,
00160 m_i, n_i, a_i, lda_i, b_i, ldb_i, c_i, ldc_i,
00161 &scale_i );
00162
00163 failed = compare_ztrsyl( c, c_i, scale, scale_i, info, info_i, ldc, n );
00164 if( failed == 0 ) {
00165 printf( "PASSED: column-major middle-level interface to ztrsyl\n" );
00166 } else {
00167 printf( "FAILED: column-major middle-level interface to ztrsyl\n" );
00168 }
00169
00170
00171
00172 for( i = 0; i < lda*m; i++ ) {
00173 a_i[i] = a[i];
00174 }
00175 for( i = 0; i < ldb*n; i++ ) {
00176 b_i[i] = b[i];
00177 }
00178 for( i = 0; i < ldc*n; i++ ) {
00179 c_i[i] = c_save[i];
00180 }
00181 info_i = LAPACKE_ztrsyl( LAPACK_COL_MAJOR, trana_i, tranb_i, isgn_i, m_i,
00182 n_i, a_i, lda_i, b_i, ldb_i, c_i, ldc_i,
00183 &scale_i );
00184
00185 failed = compare_ztrsyl( c, c_i, scale, scale_i, info, info_i, ldc, n );
00186 if( failed == 0 ) {
00187 printf( "PASSED: column-major high-level interface to ztrsyl\n" );
00188 } else {
00189 printf( "FAILED: column-major high-level interface to ztrsyl\n" );
00190 }
00191
00192
00193
00194 for( i = 0; i < lda*m; i++ ) {
00195 a_i[i] = a[i];
00196 }
00197 for( i = 0; i < ldb*n; i++ ) {
00198 b_i[i] = b[i];
00199 }
00200 for( i = 0; i < ldc*n; i++ ) {
00201 c_i[i] = c_save[i];
00202 }
00203
00204 LAPACKE_zge_trans( LAPACK_COL_MAJOR, m, m, a_i, lda, a_r, m+2 );
00205 LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, n, b_i, ldb, b_r, n+2 );
00206 LAPACKE_zge_trans( LAPACK_COL_MAJOR, m, n, c_i, ldc, c_r, n+2 );
00207 info_i = LAPACKE_ztrsyl_work( LAPACK_ROW_MAJOR, trana_i, tranb_i, isgn_i,
00208 m_i, n_i, a_r, lda_r, b_r, ldb_r, c_r, ldc_r,
00209 &scale_i );
00210
00211 LAPACKE_zge_trans( LAPACK_ROW_MAJOR, m, n, c_r, n+2, c_i, ldc );
00212
00213 failed = compare_ztrsyl( c, c_i, scale, scale_i, info, info_i, ldc, n );
00214 if( failed == 0 ) {
00215 printf( "PASSED: row-major middle-level interface to ztrsyl\n" );
00216 } else {
00217 printf( "FAILED: row-major middle-level interface to ztrsyl\n" );
00218 }
00219
00220
00221
00222 for( i = 0; i < lda*m; i++ ) {
00223 a_i[i] = a[i];
00224 }
00225 for( i = 0; i < ldb*n; i++ ) {
00226 b_i[i] = b[i];
00227 }
00228 for( i = 0; i < ldc*n; i++ ) {
00229 c_i[i] = c_save[i];
00230 }
00231
00232
00233 LAPACKE_zge_trans( LAPACK_COL_MAJOR, m, m, a_i, lda, a_r, m+2 );
00234 LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, n, b_i, ldb, b_r, n+2 );
00235 LAPACKE_zge_trans( LAPACK_COL_MAJOR, m, n, c_i, ldc, c_r, n+2 );
00236 info_i = LAPACKE_ztrsyl( LAPACK_ROW_MAJOR, trana_i, tranb_i, isgn_i, m_i,
00237 n_i, a_r, lda_r, b_r, ldb_r, c_r, ldc_r,
00238 &scale_i );
00239
00240 LAPACKE_zge_trans( LAPACK_ROW_MAJOR, m, n, c_r, n+2, c_i, ldc );
00241
00242 failed = compare_ztrsyl( c, c_i, scale, scale_i, info, info_i, ldc, n );
00243 if( failed == 0 ) {
00244 printf( "PASSED: row-major high-level interface to ztrsyl\n" );
00245 } else {
00246 printf( "FAILED: row-major high-level interface to ztrsyl\n" );
00247 }
00248
00249
00250 if( a != NULL ) {
00251 LAPACKE_free( a );
00252 }
00253 if( a_i != NULL ) {
00254 LAPACKE_free( a_i );
00255 }
00256 if( a_r != NULL ) {
00257 LAPACKE_free( a_r );
00258 }
00259 if( b != NULL ) {
00260 LAPACKE_free( b );
00261 }
00262 if( b_i != NULL ) {
00263 LAPACKE_free( b_i );
00264 }
00265 if( b_r != NULL ) {
00266 LAPACKE_free( b_r );
00267 }
00268 if( c != NULL ) {
00269 LAPACKE_free( c );
00270 }
00271 if( c_i != NULL ) {
00272 LAPACKE_free( c_i );
00273 }
00274 if( c_r != NULL ) {
00275 LAPACKE_free( c_r );
00276 }
00277 if( c_save != NULL ) {
00278 LAPACKE_free( c_save );
00279 }
00280
00281 return 0;
00282 }
00283
00284
00285 static void init_scalars_ztrsyl( char *trana, char *tranb, lapack_int *isgn,
00286 lapack_int *m, lapack_int *n, lapack_int *lda,
00287 lapack_int *ldb, lapack_int *ldc )
00288 {
00289 *trana = 'N';
00290 *tranb = 'N';
00291 *isgn = 1;
00292 *m = 4;
00293 *n = 4;
00294 *lda = 8;
00295 *ldb = 8;
00296 *ldc = 8;
00297
00298 return;
00299 }
00300
00301
00302 static void init_a( lapack_int size, lapack_complex_double *a ) {
00303 lapack_int i;
00304 for( i = 0; i < size; i++ ) {
00305 a[i] = lapack_make_complex_double( 0.0, 0.0 );
00306 }
00307 a[0] = lapack_make_complex_double( -6.00000000000000000e+000,
00308 -7.00000000000000000e+000 );
00309 a[8] = lapack_make_complex_double( 3.59999999999999990e-001,
00310 -3.59999999999999990e-001 );
00311 a[16] = lapack_make_complex_double( -1.90000000000000000e-001,
00312 4.79999999999999980e-001 );
00313 a[24] = lapack_make_complex_double( 8.80000000000000000e-001,
00314 -2.50000000000000000e-001 );
00315 a[1] = lapack_make_complex_double( 0.00000000000000000e+000,
00316 0.00000000000000000e+000 );
00317 a[9] = lapack_make_complex_double( -5.00000000000000000e+000,
00318 2.00000000000000000e+000 );
00319 a[17] = lapack_make_complex_double( -2.99999999999999990e-002,
00320 -7.19999999999999970e-001 );
00321 a[25] = lapack_make_complex_double( -2.30000000000000010e-001,
00322 1.30000000000000000e-001 );
00323 a[2] = lapack_make_complex_double( 0.00000000000000000e+000,
00324 0.00000000000000000e+000 );
00325 a[10] = lapack_make_complex_double( 0.00000000000000000e+000,
00326 0.00000000000000000e+000 );
00327 a[18] = lapack_make_complex_double( 8.00000000000000000e+000,
00328 -1.00000000000000000e+000 );
00329 a[26] = lapack_make_complex_double( 9.39999999999999950e-001,
00330 5.30000000000000030e-001 );
00331 a[3] = lapack_make_complex_double( 0.00000000000000000e+000,
00332 0.00000000000000000e+000 );
00333 a[11] = lapack_make_complex_double( 0.00000000000000000e+000,
00334 0.00000000000000000e+000 );
00335 a[19] = lapack_make_complex_double( 0.00000000000000000e+000,
00336 0.00000000000000000e+000 );
00337 a[27] = lapack_make_complex_double( 3.00000000000000000e+000,
00338 -4.00000000000000000e+000 );
00339 }
00340 static void init_b( lapack_int size, lapack_complex_double *b ) {
00341 lapack_int i;
00342 for( i = 0; i < size; i++ ) {
00343 b[i] = lapack_make_complex_double( 0.0, 0.0 );
00344 }
00345 b[0] = lapack_make_complex_double( 5.00000000000000000e-001,
00346 -2.00000000000000010e-001 );
00347 b[8] = lapack_make_complex_double( -2.89999999999999980e-001,
00348 -1.60000000000000000e-001 );
00349 b[16] = lapack_make_complex_double( -3.70000000000000000e-001,
00350 8.39999999999999970e-001 );
00351 b[24] = lapack_make_complex_double( -5.50000000000000040e-001,
00352 7.29999999999999980e-001 );
00353 b[1] = lapack_make_complex_double( 0.00000000000000000e+000,
00354 0.00000000000000000e+000 );
00355 b[9] = lapack_make_complex_double( -4.00000000000000020e-001,
00356 9.00000000000000020e-001 );
00357 b[17] = lapack_make_complex_double( 5.99999999999999980e-002,
00358 2.20000000000000000e-001 );
00359 b[25] = lapack_make_complex_double( -4.29999999999999990e-001,
00360 1.70000000000000010e-001 );
00361 b[2] = lapack_make_complex_double( 0.00000000000000000e+000,
00362 0.00000000000000000e+000 );
00363 b[10] = lapack_make_complex_double( 0.00000000000000000e+000,
00364 0.00000000000000000e+000 );
00365 b[18] = lapack_make_complex_double( -9.00000000000000020e-001,
00366 -1.00000000000000010e-001 );
00367 b[26] = lapack_make_complex_double( -8.90000000000000010e-001,
00368 -4.19999999999999980e-001 );
00369 b[3] = lapack_make_complex_double( 0.00000000000000000e+000,
00370 0.00000000000000000e+000 );
00371 b[11] = lapack_make_complex_double( 0.00000000000000000e+000,
00372 0.00000000000000000e+000 );
00373 b[19] = lapack_make_complex_double( 0.00000000000000000e+000,
00374 0.00000000000000000e+000 );
00375 b[27] = lapack_make_complex_double( 2.99999999999999990e-001,
00376 -6.99999999999999960e-001 );
00377 }
00378 static void init_c( lapack_int size, lapack_complex_double *c ) {
00379 lapack_int i;
00380 for( i = 0; i < size; i++ ) {
00381 c[i] = lapack_make_complex_double( 0.0, 0.0 );
00382 }
00383 c[0] = lapack_make_complex_double( 6.30000000000000000e-001,
00384 3.49999999999999980e-001 );
00385 c[8] = lapack_make_complex_double( 4.50000000000000010e-001,
00386 -5.60000000000000050e-001 );
00387 c[16] = lapack_make_complex_double( 8.00000000000000020e-002,
00388 -1.40000000000000010e-001 );
00389 c[24] = lapack_make_complex_double( -1.70000000000000010e-001,
00390 -2.30000000000000010e-001 );
00391 c[1] = lapack_make_complex_double( -1.70000000000000010e-001,
00392 8.99999999999999970e-002 );
00393 c[9] = lapack_make_complex_double( -7.00000000000000070e-002,
00394 -3.10000000000000000e-001 );
00395 c[17] = lapack_make_complex_double( 2.70000000000000020e-001,
00396 -5.40000000000000040e-001 );
00397 c[25] = lapack_make_complex_double( 3.49999999999999980e-001,
00398 1.21000000000000000e+000 );
00399 c[2] = lapack_make_complex_double( -9.30000000000000050e-001,
00400 -4.40000000000000000e-001 );
00401 c[10] = lapack_make_complex_double( -3.30000000000000020e-001,
00402 -3.49999999999999980e-001 );
00403 c[18] = lapack_make_complex_double( 4.09999999999999980e-001,
00404 -2.99999999999999990e-002 );
00405 c[26] = lapack_make_complex_double( 5.69999999999999950e-001,
00406 8.39999999999999970e-001 );
00407 c[3] = lapack_make_complex_double( 5.40000000000000040e-001,
00408 2.50000000000000000e-001 );
00409 c[11] = lapack_make_complex_double( -6.20000000000000000e-001,
00410 -5.00000000000000030e-002 );
00411 c[19] = lapack_make_complex_double( -5.20000000000000020e-001,
00412 -1.30000000000000000e-001 );
00413 c[27] = lapack_make_complex_double( 1.10000000000000000e-001,
00414 -8.00000000000000020e-002 );
00415 }
00416
00417
00418
00419 static int compare_ztrsyl( lapack_complex_double *c, lapack_complex_double *c_i,
00420 double scale, double scale_i, lapack_int info,
00421 lapack_int info_i, lapack_int ldc, lapack_int n )
00422 {
00423 lapack_int i;
00424 int failed = 0;
00425 for( i = 0; i < ldc*n; i++ ) {
00426 failed += compare_complex_doubles(c[i],c_i[i]);
00427 }
00428 failed += compare_doubles(scale,scale_i);
00429 failed += (info == info_i) ? 0 : 1;
00430 if( info != 0 || info_i != 0 ) {
00431 printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00432 }
00433
00434 return failed;
00435 }