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_strsyl( 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, float *a );
00058 static void init_b( lapack_int size, float *b );
00059 static void init_c( lapack_int size, float *c );
00060 static int compare_strsyl( float *c, float *c_i, float scale, float scale_i,
00061 lapack_int info, lapack_int info_i, lapack_int ldc,
00062 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 float *a = NULL, *a_i = NULL;
00085 float *b = NULL, *b_i = NULL;
00086 float *c = NULL, *c_i = NULL;
00087 float *c_save = NULL;
00088 float *a_r = NULL;
00089 float *b_r = NULL;
00090 float *c_r = NULL;
00091
00092
00093 init_scalars_strsyl( &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 = (float *)LAPACKE_malloc( lda*m * sizeof(float) );
00108 b = (float *)LAPACKE_malloc( ldb*n * sizeof(float) );
00109 c = (float *)LAPACKE_malloc( ldc*n * sizeof(float) );
00110
00111
00112 a_i = (float *)LAPACKE_malloc( lda*m * sizeof(float) );
00113 b_i = (float *)LAPACKE_malloc( ldb*n * sizeof(float) );
00114 c_i = (float *)LAPACKE_malloc( ldc*n * sizeof(float) );
00115
00116
00117 c_save = (float *)LAPACKE_malloc( ldc*n * sizeof(float) );
00118
00119
00120 a_r = (float *)LAPACKE_malloc( m*(m+2) * sizeof(float) );
00121 b_r = (float *)LAPACKE_malloc( n*(n+2) * sizeof(float) );
00122 c_r = (float *)LAPACKE_malloc( m*(n+2) * sizeof(float) );
00123
00124
00125 init_a( lda*m, a );
00126 init_b( ldb*n, b );
00127 init_c( ldc*n, c );
00128
00129
00130 for( i = 0; i < ldc*n; i++ ) {
00131 c_save[i] = c[i];
00132 }
00133
00134
00135 strsyl_( &trana, &tranb, &isgn, &m, &n, a, &lda, b, &ldb, c, &ldc, &scale,
00136 &info );
00137
00138
00139
00140 for( i = 0; i < lda*m; i++ ) {
00141 a_i[i] = a[i];
00142 }
00143 for( i = 0; i < ldb*n; i++ ) {
00144 b_i[i] = b[i];
00145 }
00146 for( i = 0; i < ldc*n; i++ ) {
00147 c_i[i] = c_save[i];
00148 }
00149 info_i = LAPACKE_strsyl_work( LAPACK_COL_MAJOR, trana_i, tranb_i, isgn_i,
00150 m_i, n_i, a_i, lda_i, b_i, ldb_i, c_i, ldc_i,
00151 &scale_i );
00152
00153 failed = compare_strsyl( c, c_i, scale, scale_i, info, info_i, ldc, n );
00154 if( failed == 0 ) {
00155 printf( "PASSED: column-major middle-level interface to strsyl\n" );
00156 } else {
00157 printf( "FAILED: column-major middle-level interface to strsyl\n" );
00158 }
00159
00160
00161
00162 for( i = 0; i < lda*m; i++ ) {
00163 a_i[i] = a[i];
00164 }
00165 for( i = 0; i < ldb*n; i++ ) {
00166 b_i[i] = b[i];
00167 }
00168 for( i = 0; i < ldc*n; i++ ) {
00169 c_i[i] = c_save[i];
00170 }
00171 info_i = LAPACKE_strsyl( LAPACK_COL_MAJOR, trana_i, tranb_i, isgn_i, m_i,
00172 n_i, a_i, lda_i, b_i, ldb_i, c_i, ldc_i,
00173 &scale_i );
00174
00175 failed = compare_strsyl( c, c_i, scale, scale_i, info, info_i, ldc, n );
00176 if( failed == 0 ) {
00177 printf( "PASSED: column-major high-level interface to strsyl\n" );
00178 } else {
00179 printf( "FAILED: column-major high-level interface to strsyl\n" );
00180 }
00181
00182
00183
00184 for( i = 0; i < lda*m; i++ ) {
00185 a_i[i] = a[i];
00186 }
00187 for( i = 0; i < ldb*n; i++ ) {
00188 b_i[i] = b[i];
00189 }
00190 for( i = 0; i < ldc*n; i++ ) {
00191 c_i[i] = c_save[i];
00192 }
00193
00194 LAPACKE_sge_trans( LAPACK_COL_MAJOR, m, m, a_i, lda, a_r, m+2 );
00195 LAPACKE_sge_trans( LAPACK_COL_MAJOR, n, n, b_i, ldb, b_r, n+2 );
00196 LAPACKE_sge_trans( LAPACK_COL_MAJOR, m, n, c_i, ldc, c_r, n+2 );
00197 info_i = LAPACKE_strsyl_work( LAPACK_ROW_MAJOR, trana_i, tranb_i, isgn_i,
00198 m_i, n_i, a_r, lda_r, b_r, ldb_r, c_r, ldc_r,
00199 &scale_i );
00200
00201 LAPACKE_sge_trans( LAPACK_ROW_MAJOR, m, n, c_r, n+2, c_i, ldc );
00202
00203 failed = compare_strsyl( c, c_i, scale, scale_i, info, info_i, ldc, n );
00204 if( failed == 0 ) {
00205 printf( "PASSED: row-major middle-level interface to strsyl\n" );
00206 } else {
00207 printf( "FAILED: row-major middle-level interface to strsyl\n" );
00208 }
00209
00210
00211
00212 for( i = 0; i < lda*m; i++ ) {
00213 a_i[i] = a[i];
00214 }
00215 for( i = 0; i < ldb*n; i++ ) {
00216 b_i[i] = b[i];
00217 }
00218 for( i = 0; i < ldc*n; i++ ) {
00219 c_i[i] = c_save[i];
00220 }
00221
00222
00223 LAPACKE_sge_trans( LAPACK_COL_MAJOR, m, m, a_i, lda, a_r, m+2 );
00224 LAPACKE_sge_trans( LAPACK_COL_MAJOR, n, n, b_i, ldb, b_r, n+2 );
00225 LAPACKE_sge_trans( LAPACK_COL_MAJOR, m, n, c_i, ldc, c_r, n+2 );
00226 info_i = LAPACKE_strsyl( LAPACK_ROW_MAJOR, trana_i, tranb_i, isgn_i, m_i,
00227 n_i, a_r, lda_r, b_r, ldb_r, c_r, ldc_r,
00228 &scale_i );
00229
00230 LAPACKE_sge_trans( LAPACK_ROW_MAJOR, m, n, c_r, n+2, c_i, ldc );
00231
00232 failed = compare_strsyl( c, c_i, scale, scale_i, info, info_i, ldc, n );
00233 if( failed == 0 ) {
00234 printf( "PASSED: row-major high-level interface to strsyl\n" );
00235 } else {
00236 printf( "FAILED: row-major high-level interface to strsyl\n" );
00237 }
00238
00239
00240 if( a != NULL ) {
00241 LAPACKE_free( a );
00242 }
00243 if( a_i != NULL ) {
00244 LAPACKE_free( a_i );
00245 }
00246 if( a_r != NULL ) {
00247 LAPACKE_free( a_r );
00248 }
00249 if( b != NULL ) {
00250 LAPACKE_free( b );
00251 }
00252 if( b_i != NULL ) {
00253 LAPACKE_free( b_i );
00254 }
00255 if( b_r != NULL ) {
00256 LAPACKE_free( b_r );
00257 }
00258 if( c != NULL ) {
00259 LAPACKE_free( c );
00260 }
00261 if( c_i != NULL ) {
00262 LAPACKE_free( c_i );
00263 }
00264 if( c_r != NULL ) {
00265 LAPACKE_free( c_r );
00266 }
00267 if( c_save != NULL ) {
00268 LAPACKE_free( c_save );
00269 }
00270
00271 return 0;
00272 }
00273
00274
00275 static void init_scalars_strsyl( char *trana, char *tranb, lapack_int *isgn,
00276 lapack_int *m, lapack_int *n, lapack_int *lda,
00277 lapack_int *ldb, lapack_int *ldc )
00278 {
00279 *trana = 'N';
00280 *tranb = 'N';
00281 *isgn = 1;
00282 *m = 4;
00283 *n = 4;
00284 *lda = 8;
00285 *ldb = 8;
00286 *ldc = 8;
00287
00288 return;
00289 }
00290
00291
00292 static void init_a( lapack_int size, float *a ) {
00293 lapack_int i;
00294 for( i = 0; i < size; i++ ) {
00295 a[i] = 0;
00296 }
00297 a[0] = 1.000000015e-001;
00298 a[8] = 5.000000000e-001;
00299 a[16] = 6.800000072e-001;
00300 a[24] = -2.099999934e-001;
00301 a[1] = -5.000000000e-001;
00302 a[9] = 1.000000015e-001;
00303 a[17] = -2.399999946e-001;
00304 a[25] = 6.700000167e-001;
00305 a[2] = 0.000000000e+000;
00306 a[10] = 0.000000000e+000;
00307 a[18] = 1.899999976e-001;
00308 a[26] = -3.499999940e-001;
00309 a[3] = 0.000000000e+000;
00310 a[11] = 0.000000000e+000;
00311 a[19] = 0.000000000e+000;
00312 a[27] = -7.200000286e-001;
00313 }
00314 static void init_b( lapack_int size, float *b ) {
00315 lapack_int i;
00316 for( i = 0; i < size; i++ ) {
00317 b[i] = 0;
00318 }
00319 b[0] = -9.900000095e-001;
00320 b[8] = -1.700000018e-001;
00321 b[16] = 3.899999857e-001;
00322 b[24] = 5.799999833e-001;
00323 b[1] = 0.000000000e+000;
00324 b[9] = 4.799999893e-001;
00325 b[17] = -8.399999738e-001;
00326 b[25] = -1.500000060e-001;
00327 b[2] = 0.000000000e+000;
00328 b[10] = 0.000000000e+000;
00329 b[18] = 7.500000000e-001;
00330 b[26] = 2.500000000e-001;
00331 b[3] = 0.000000000e+000;
00332 b[11] = 0.000000000e+000;
00333 b[19] = -2.500000000e-001;
00334 b[27] = 7.500000000e-001;
00335 }
00336 static void init_c( lapack_int size, float *c ) {
00337 lapack_int i;
00338 for( i = 0; i < size; i++ ) {
00339 c[i] = 0;
00340 }
00341 c[0] = 6.299999952e-001;
00342 c[8] = -5.600000024e-001;
00343 c[16] = 7.999999821e-002;
00344 c[24] = -2.300000042e-001;
00345 c[1] = -4.499999881e-001;
00346 c[9] = -3.100000024e-001;
00347 c[17] = 2.700000107e-001;
00348 c[25] = 1.210000038e+000;
00349 c[2] = 2.000000030e-001;
00350 c[10] = -3.499999940e-001;
00351 c[18] = 4.099999964e-001;
00352 c[26] = 8.399999738e-001;
00353 c[3] = 4.900000095e-001;
00354 c[11] = -5.000000075e-002;
00355 c[19] = -5.199999809e-001;
00356 c[27] = -7.999999821e-002;
00357 }
00358
00359
00360
00361 static int compare_strsyl( float *c, float *c_i, float scale, float scale_i,
00362 lapack_int info, lapack_int info_i, lapack_int ldc,
00363 lapack_int n )
00364 {
00365 lapack_int i;
00366 int failed = 0;
00367 for( i = 0; i < ldc*n; i++ ) {
00368 failed += compare_floats(c[i],c_i[i]);
00369 }
00370 failed += compare_floats(scale,scale_i);
00371 failed += (info == info_i) ? 0 : 1;
00372 if( info != 0 || info_i != 0 ) {
00373 printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00374 }
00375
00376 return failed;
00377 }