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_zsytrs( char *uplo, lapack_int *n, lapack_int *nrhs,
00055 lapack_int *lda, lapack_int *ldb );
00056 static void init_a( lapack_int size, lapack_complex_double *a );
00057 static void init_ipiv( lapack_int size, lapack_int *ipiv );
00058 static void init_b( lapack_int size, lapack_complex_double *b );
00059 static int compare_zsytrs( lapack_complex_double *b, lapack_complex_double *b_i,
00060 lapack_int info, lapack_int info_i, lapack_int ldb,
00061 lapack_int nrhs );
00062
00063 int main(void)
00064 {
00065
00066 char uplo, uplo_i;
00067 lapack_int n, n_i;
00068 lapack_int nrhs, nrhs_i;
00069 lapack_int lda, lda_i;
00070 lapack_int lda_r;
00071 lapack_int ldb, ldb_i;
00072 lapack_int ldb_r;
00073 lapack_int info, info_i;
00074 lapack_int i;
00075 int failed;
00076
00077
00078 lapack_complex_double *a = NULL, *a_i = NULL;
00079 lapack_int *ipiv = NULL, *ipiv_i = NULL;
00080 lapack_complex_double *b = NULL, *b_i = NULL;
00081 lapack_complex_double *b_save = NULL;
00082 lapack_complex_double *a_r = NULL;
00083 lapack_complex_double *b_r = NULL;
00084
00085
00086 init_scalars_zsytrs( &uplo, &n, &nrhs, &lda, &ldb );
00087 lda_r = n+2;
00088 ldb_r = nrhs+2;
00089 uplo_i = uplo;
00090 n_i = n;
00091 nrhs_i = nrhs;
00092 lda_i = lda;
00093 ldb_i = ldb;
00094
00095
00096 a = (lapack_complex_double *)
00097 LAPACKE_malloc( lda*n * sizeof(lapack_complex_double) );
00098 ipiv = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
00099 b = (lapack_complex_double *)
00100 LAPACKE_malloc( ldb*nrhs * sizeof(lapack_complex_double) );
00101
00102
00103 a_i = (lapack_complex_double *)
00104 LAPACKE_malloc( lda*n * sizeof(lapack_complex_double) );
00105 ipiv_i = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
00106 b_i = (lapack_complex_double *)
00107 LAPACKE_malloc( ldb*nrhs * sizeof(lapack_complex_double) );
00108
00109
00110 b_save = (lapack_complex_double *)
00111 LAPACKE_malloc( ldb*nrhs * sizeof(lapack_complex_double) );
00112
00113
00114 a_r = (lapack_complex_double *)
00115 LAPACKE_malloc( n*(n+2) * sizeof(lapack_complex_double) );
00116 b_r = (lapack_complex_double *)
00117 LAPACKE_malloc( n*(nrhs+2) * sizeof(lapack_complex_double) );
00118
00119
00120 init_a( lda*n, a );
00121 init_ipiv( n, ipiv );
00122 init_b( ldb*nrhs, b );
00123
00124
00125 for( i = 0; i < ldb*nrhs; i++ ) {
00126 b_save[i] = b[i];
00127 }
00128
00129
00130 zsytrs_( &uplo, &n, &nrhs, a, &lda, ipiv, b, &ldb, &info );
00131
00132
00133
00134 for( i = 0; i < lda*n; i++ ) {
00135 a_i[i] = a[i];
00136 }
00137 for( i = 0; i < n; i++ ) {
00138 ipiv_i[i] = ipiv[i];
00139 }
00140 for( i = 0; i < ldb*nrhs; i++ ) {
00141 b_i[i] = b_save[i];
00142 }
00143 info_i = LAPACKE_zsytrs_work( LAPACK_COL_MAJOR, uplo_i, n_i, nrhs_i, a_i,
00144 lda_i, ipiv_i, b_i, ldb_i );
00145
00146 failed = compare_zsytrs( b, b_i, info, info_i, ldb, nrhs );
00147 if( failed == 0 ) {
00148 printf( "PASSED: column-major middle-level interface to zsytrs\n" );
00149 } else {
00150 printf( "FAILED: column-major middle-level interface to zsytrs\n" );
00151 }
00152
00153
00154
00155 for( i = 0; i < lda*n; i++ ) {
00156 a_i[i] = a[i];
00157 }
00158 for( i = 0; i < n; i++ ) {
00159 ipiv_i[i] = ipiv[i];
00160 }
00161 for( i = 0; i < ldb*nrhs; i++ ) {
00162 b_i[i] = b_save[i];
00163 }
00164 info_i = LAPACKE_zsytrs( LAPACK_COL_MAJOR, uplo_i, n_i, nrhs_i, a_i, lda_i,
00165 ipiv_i, b_i, ldb_i );
00166
00167 failed = compare_zsytrs( b, b_i, info, info_i, ldb, nrhs );
00168 if( failed == 0 ) {
00169 printf( "PASSED: column-major high-level interface to zsytrs\n" );
00170 } else {
00171 printf( "FAILED: column-major high-level interface to zsytrs\n" );
00172 }
00173
00174
00175
00176 for( i = 0; i < lda*n; i++ ) {
00177 a_i[i] = a[i];
00178 }
00179 for( i = 0; i < n; i++ ) {
00180 ipiv_i[i] = ipiv[i];
00181 }
00182 for( i = 0; i < ldb*nrhs; i++ ) {
00183 b_i[i] = b_save[i];
00184 }
00185
00186 LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, n, a_i, lda, a_r, n+2 );
00187 LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, nrhs, b_i, ldb, b_r, nrhs+2 );
00188 info_i = LAPACKE_zsytrs_work( LAPACK_ROW_MAJOR, uplo_i, n_i, nrhs_i, a_r,
00189 lda_r, ipiv_i, b_r, ldb_r );
00190
00191 LAPACKE_zge_trans( LAPACK_ROW_MAJOR, n, nrhs, b_r, nrhs+2, b_i, ldb );
00192
00193 failed = compare_zsytrs( b, b_i, info, info_i, ldb, nrhs );
00194 if( failed == 0 ) {
00195 printf( "PASSED: row-major middle-level interface to zsytrs\n" );
00196 } else {
00197 printf( "FAILED: row-major middle-level interface to zsytrs\n" );
00198 }
00199
00200
00201
00202 for( i = 0; i < lda*n; i++ ) {
00203 a_i[i] = a[i];
00204 }
00205 for( i = 0; i < n; i++ ) {
00206 ipiv_i[i] = ipiv[i];
00207 }
00208 for( i = 0; i < ldb*nrhs; i++ ) {
00209 b_i[i] = b_save[i];
00210 }
00211
00212
00213 LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, n, a_i, lda, a_r, n+2 );
00214 LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, nrhs, b_i, ldb, b_r, nrhs+2 );
00215 info_i = LAPACKE_zsytrs( LAPACK_ROW_MAJOR, uplo_i, n_i, nrhs_i, a_r, lda_r,
00216 ipiv_i, b_r, ldb_r );
00217
00218 LAPACKE_zge_trans( LAPACK_ROW_MAJOR, n, nrhs, b_r, nrhs+2, b_i, ldb );
00219
00220 failed = compare_zsytrs( b, b_i, info, info_i, ldb, nrhs );
00221 if( failed == 0 ) {
00222 printf( "PASSED: row-major high-level interface to zsytrs\n" );
00223 } else {
00224 printf( "FAILED: row-major high-level interface to zsytrs\n" );
00225 }
00226
00227
00228 if( a != NULL ) {
00229 LAPACKE_free( a );
00230 }
00231 if( a_i != NULL ) {
00232 LAPACKE_free( a_i );
00233 }
00234 if( a_r != NULL ) {
00235 LAPACKE_free( a_r );
00236 }
00237 if( ipiv != NULL ) {
00238 LAPACKE_free( ipiv );
00239 }
00240 if( ipiv_i != NULL ) {
00241 LAPACKE_free( ipiv_i );
00242 }
00243 if( b != NULL ) {
00244 LAPACKE_free( b );
00245 }
00246 if( b_i != NULL ) {
00247 LAPACKE_free( b_i );
00248 }
00249 if( b_r != NULL ) {
00250 LAPACKE_free( b_r );
00251 }
00252 if( b_save != NULL ) {
00253 LAPACKE_free( b_save );
00254 }
00255
00256 return 0;
00257 }
00258
00259
00260 static void init_scalars_zsytrs( char *uplo, lapack_int *n, lapack_int *nrhs,
00261 lapack_int *lda, lapack_int *ldb )
00262 {
00263 *uplo = 'L';
00264 *n = 4;
00265 *nrhs = 2;
00266 *lda = 8;
00267 *ldb = 8;
00268
00269 return;
00270 }
00271
00272
00273 static void init_a( lapack_int size, lapack_complex_double *a ) {
00274 lapack_int i;
00275 for( i = 0; i < size; i++ ) {
00276 a[i] = lapack_make_complex_double( 0.0, 0.0 );
00277 }
00278 a[0] = lapack_make_complex_double( -3.90000000000000010e-001,
00279 -7.09999999999999960e-001 );
00280 a[8] = lapack_make_complex_double( 0.00000000000000000e+000,
00281 0.00000000000000000e+000 );
00282 a[16] = lapack_make_complex_double( 0.00000000000000000e+000,
00283 0.00000000000000000e+000 );
00284 a[24] = lapack_make_complex_double( 0.00000000000000000e+000,
00285 0.00000000000000000e+000 );
00286 a[1] = lapack_make_complex_double( -7.86000000000000030e+000,
00287 -2.96000000000000000e+000 );
00288 a[9] = lapack_make_complex_double( -2.83000000000000010e+000,
00289 -2.99999999999999990e-002 );
00290 a[17] = lapack_make_complex_double( 0.00000000000000000e+000,
00291 0.00000000000000000e+000 );
00292 a[25] = lapack_make_complex_double( 0.00000000000000000e+000,
00293 0.00000000000000000e+000 );
00294 a[2] = lapack_make_complex_double( 5.27872480164079950e-001,
00295 -3.71466001482590570e-001 );
00296 a[10] = lapack_make_complex_double( -6.07839105668319330e-001,
00297 2.81079647893121950e-001 );
00298 a[18] = lapack_make_complex_double( 4.40790623673101220e+000,
00299 5.39912067679694110e+000 );
00300 a[26] = lapack_make_complex_double( 0.00000000000000000e+000,
00301 0.00000000000000000e+000 );
00302 a[3] = lapack_make_complex_double( 4.42558238872675090e-001,
00303 1.93648369829740290e-001 );
00304 a[11] = lapack_make_complex_double( -4.82282297518538240e-001,
00305 1.49893621910528460e-002 );
00306 a[19] = lapack_make_complex_double( -1.07082188009268430e-001,
00307 -3.15678086248845520e-001 );
00308 a[27] = lapack_make_complex_double( -2.09541488784005690e+000,
00309 -2.20113928144078570e+000 );
00310 }
00311 static void init_ipiv( lapack_int size, lapack_int *ipiv ) {
00312 lapack_int i;
00313 for( i = 0; i < size; i++ ) {
00314 ipiv[i] = 0;
00315 }
00316 ipiv[0] = -3;
00317 ipiv[1] = -3;
00318 ipiv[2] = 3;
00319 ipiv[3] = 4;
00320 }
00321 static void init_b( lapack_int size, lapack_complex_double *b ) {
00322 lapack_int i;
00323 for( i = 0; i < size; i++ ) {
00324 b[i] = lapack_make_complex_double( 0.0, 0.0 );
00325 }
00326 b[0] = lapack_make_complex_double( -5.56400000000000010e+001,
00327 4.12199999999999990e+001 );
00328 b[8] = lapack_make_complex_double( -1.90900000000000000e+001,
00329 -3.59699999999999990e+001 );
00330 b[1] = lapack_make_complex_double( -4.81800000000000000e+001,
00331 6.60000000000000000e+001 );
00332 b[9] = lapack_make_complex_double( -1.20800000000000000e+001,
00333 -2.70200000000000000e+001 );
00334 b[2] = lapack_make_complex_double( -4.89999999999999990e-001,
00335 -1.47000000000000000e+000 );
00336 b[10] = lapack_make_complex_double( 6.95000000000000020e+000,
00337 2.04899999999999980e+001 );
00338 b[3] = lapack_make_complex_double( -6.42999999999999970e+000,
00339 1.92399999999999980e+001 );
00340 b[11] = lapack_make_complex_double( -4.58999999999999990e+000,
00341 -3.55300000000000010e+001 );
00342 }
00343
00344
00345
00346 static int compare_zsytrs( lapack_complex_double *b, lapack_complex_double *b_i,
00347 lapack_int info, lapack_int info_i, lapack_int ldb,
00348 lapack_int nrhs )
00349 {
00350 lapack_int i;
00351 int failed = 0;
00352 for( i = 0; i < ldb*nrhs; i++ ) {
00353 failed += compare_complex_doubles(b[i],b_i[i]);
00354 }
00355 failed += (info == info_i) ? 0 : 1;
00356 if( info != 0 || info_i != 0 ) {
00357 printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00358 }
00359
00360 return failed;
00361 }