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_ctrsyl( 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_float *a );
00058 static void init_b( lapack_int size, lapack_complex_float *b );
00059 static void init_c( lapack_int size, lapack_complex_float *c );
00060 static int compare_ctrsyl( lapack_complex_float *c, lapack_complex_float *c_i,
00061 float scale, float 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 float scale, scale_i;
00079 lapack_int info, info_i;
00080 lapack_int i;
00081 int failed;
00082
00083
00084 lapack_complex_float *a = NULL, *a_i = NULL;
00085 lapack_complex_float *b = NULL, *b_i = NULL;
00086 lapack_complex_float *c = NULL, *c_i = NULL;
00087 lapack_complex_float *c_save = NULL;
00088 lapack_complex_float *a_r = NULL;
00089 lapack_complex_float *b_r = NULL;
00090 lapack_complex_float *c_r = NULL;
00091
00092
00093 init_scalars_ctrsyl( &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_float *)
00108 LAPACKE_malloc( lda*m * sizeof(lapack_complex_float) );
00109 b = (lapack_complex_float *)
00110 LAPACKE_malloc( ldb*n * sizeof(lapack_complex_float) );
00111 c = (lapack_complex_float *)
00112 LAPACKE_malloc( ldc*n * sizeof(lapack_complex_float) );
00113
00114
00115 a_i = (lapack_complex_float *)
00116 LAPACKE_malloc( lda*m * sizeof(lapack_complex_float) );
00117 b_i = (lapack_complex_float *)
00118 LAPACKE_malloc( ldb*n * sizeof(lapack_complex_float) );
00119 c_i = (lapack_complex_float *)
00120 LAPACKE_malloc( ldc*n * sizeof(lapack_complex_float) );
00121
00122
00123 c_save = (lapack_complex_float *)
00124 LAPACKE_malloc( ldc*n * sizeof(lapack_complex_float) );
00125
00126
00127 a_r = (lapack_complex_float *)
00128 LAPACKE_malloc( m*(m+2) * sizeof(lapack_complex_float) );
00129 b_r = (lapack_complex_float *)
00130 LAPACKE_malloc( n*(n+2) * sizeof(lapack_complex_float) );
00131 c_r = (lapack_complex_float *)
00132 LAPACKE_malloc( m*(n+2) * sizeof(lapack_complex_float) );
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 ctrsyl_( &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_ctrsyl_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_ctrsyl( c, c_i, scale, scale_i, info, info_i, ldc, n );
00164 if( failed == 0 ) {
00165 printf( "PASSED: column-major middle-level interface to ctrsyl\n" );
00166 } else {
00167 printf( "FAILED: column-major middle-level interface to ctrsyl\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_ctrsyl( 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_ctrsyl( c, c_i, scale, scale_i, info, info_i, ldc, n );
00186 if( failed == 0 ) {
00187 printf( "PASSED: column-major high-level interface to ctrsyl\n" );
00188 } else {
00189 printf( "FAILED: column-major high-level interface to ctrsyl\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_cge_trans( LAPACK_COL_MAJOR, m, m, a_i, lda, a_r, m+2 );
00205 LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, n, b_i, ldb, b_r, n+2 );
00206 LAPACKE_cge_trans( LAPACK_COL_MAJOR, m, n, c_i, ldc, c_r, n+2 );
00207 info_i = LAPACKE_ctrsyl_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_cge_trans( LAPACK_ROW_MAJOR, m, n, c_r, n+2, c_i, ldc );
00212
00213 failed = compare_ctrsyl( c, c_i, scale, scale_i, info, info_i, ldc, n );
00214 if( failed == 0 ) {
00215 printf( "PASSED: row-major middle-level interface to ctrsyl\n" );
00216 } else {
00217 printf( "FAILED: row-major middle-level interface to ctrsyl\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_cge_trans( LAPACK_COL_MAJOR, m, m, a_i, lda, a_r, m+2 );
00234 LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, n, b_i, ldb, b_r, n+2 );
00235 LAPACKE_cge_trans( LAPACK_COL_MAJOR, m, n, c_i, ldc, c_r, n+2 );
00236 info_i = LAPACKE_ctrsyl( 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_cge_trans( LAPACK_ROW_MAJOR, m, n, c_r, n+2, c_i, ldc );
00241
00242 failed = compare_ctrsyl( c, c_i, scale, scale_i, info, info_i, ldc, n );
00243 if( failed == 0 ) {
00244 printf( "PASSED: row-major high-level interface to ctrsyl\n" );
00245 } else {
00246 printf( "FAILED: row-major high-level interface to ctrsyl\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_ctrsyl( 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_float *a ) {
00303 lapack_int i;
00304 for( i = 0; i < size; i++ ) {
00305 a[i] = lapack_make_complex_float( 0.0f, 0.0f );
00306 }
00307 a[0] = lapack_make_complex_float( -6.000000000e+000, -7.000000000e+000 );
00308 a[8] = lapack_make_complex_float( 3.600000143e-001, -3.600000143e-001 );
00309 a[16] = lapack_make_complex_float( -1.899999976e-001, 4.799999893e-001 );
00310 a[24] = lapack_make_complex_float( 8.799999952e-001, -2.500000000e-001 );
00311 a[1] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00312 a[9] = lapack_make_complex_float( -5.000000000e+000, 2.000000000e+000 );
00313 a[17] = lapack_make_complex_float( -2.999999933e-002, -7.200000286e-001 );
00314 a[25] = lapack_make_complex_float( -2.300000042e-001, 1.299999952e-001 );
00315 a[2] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00316 a[10] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00317 a[18] = lapack_make_complex_float( 8.000000000e+000, -1.000000000e+000 );
00318 a[26] = lapack_make_complex_float( 9.399999976e-001, 5.299999714e-001 );
00319 a[3] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00320 a[11] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00321 a[19] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00322 a[27] = lapack_make_complex_float( 3.000000000e+000, -4.000000000e+000 );
00323 }
00324 static void init_b( lapack_int size, lapack_complex_float *b ) {
00325 lapack_int i;
00326 for( i = 0; i < size; i++ ) {
00327 b[i] = lapack_make_complex_float( 0.0f, 0.0f );
00328 }
00329 b[0] = lapack_make_complex_float( 5.000000000e-001, -2.000000030e-001 );
00330 b[8] = lapack_make_complex_float( -2.899999917e-001, -1.599999964e-001 );
00331 b[16] = lapack_make_complex_float( -3.700000048e-001, 8.399999738e-001 );
00332 b[24] = lapack_make_complex_float( -5.500000119e-001, 7.300000191e-001 );
00333 b[1] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00334 b[9] = lapack_make_complex_float( -4.000000060e-001, 8.999999762e-001 );
00335 b[17] = lapack_make_complex_float( 5.999999866e-002, 2.199999988e-001 );
00336 b[25] = lapack_make_complex_float( -4.300000072e-001, 1.700000018e-001 );
00337 b[2] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00338 b[10] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00339 b[18] = lapack_make_complex_float( -8.999999762e-001, -1.000000015e-001 );
00340 b[26] = lapack_make_complex_float( -8.899999857e-001, -4.199999869e-001 );
00341 b[3] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00342 b[11] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00343 b[19] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00344 b[27] = lapack_make_complex_float( 3.000000119e-001, -6.999999881e-001 );
00345 }
00346 static void init_c( lapack_int size, lapack_complex_float *c ) {
00347 lapack_int i;
00348 for( i = 0; i < size; i++ ) {
00349 c[i] = lapack_make_complex_float( 0.0f, 0.0f );
00350 }
00351 c[0] = lapack_make_complex_float( 6.299999952e-001, 3.499999940e-001 );
00352 c[8] = lapack_make_complex_float( 4.499999881e-001, -5.600000024e-001 );
00353 c[16] = lapack_make_complex_float( 7.999999821e-002, -1.400000006e-001 );
00354 c[24] = lapack_make_complex_float( -1.700000018e-001, -2.300000042e-001 );
00355 c[1] = lapack_make_complex_float( -1.700000018e-001, 9.000000358e-002 );
00356 c[9] = lapack_make_complex_float( -7.000000030e-002, -3.100000024e-001 );
00357 c[17] = lapack_make_complex_float( 2.700000107e-001, -5.400000215e-001 );
00358 c[25] = lapack_make_complex_float( 3.499999940e-001, 1.210000038e+000 );
00359 c[2] = lapack_make_complex_float( -9.300000072e-001, -4.399999976e-001 );
00360 c[10] = lapack_make_complex_float( -3.300000131e-001, -3.499999940e-001 );
00361 c[18] = lapack_make_complex_float( 4.099999964e-001, -2.999999933e-002 );
00362 c[26] = lapack_make_complex_float( 5.699999928e-001, 8.399999738e-001 );
00363 c[3] = lapack_make_complex_float( 5.400000215e-001, 2.500000000e-001 );
00364 c[11] = lapack_make_complex_float( -6.200000048e-001, -5.000000075e-002 );
00365 c[19] = lapack_make_complex_float( -5.199999809e-001, -1.299999952e-001 );
00366 c[27] = lapack_make_complex_float( 1.099999994e-001, -7.999999821e-002 );
00367 }
00368
00369
00370
00371 static int compare_ctrsyl( lapack_complex_float *c, lapack_complex_float *c_i,
00372 float scale, float scale_i, lapack_int info,
00373 lapack_int info_i, lapack_int ldc, lapack_int n )
00374 {
00375 lapack_int i;
00376 int failed = 0;
00377 for( i = 0; i < ldc*n; i++ ) {
00378 failed += compare_complex_floats(c[i],c_i[i]);
00379 }
00380 failed += compare_floats(scale,scale_i);
00381 failed += (info == info_i) ? 0 : 1;
00382 if( info != 0 || info_i != 0 ) {
00383 printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00384 }
00385
00386 return failed;
00387 }