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_cgbtrs( char *trans, lapack_int *n, lapack_int *kl,
00055 lapack_int *ku, lapack_int *nrhs,
00056 lapack_int *ldab, lapack_int *ldb );
00057 static void init_ab( lapack_int size, lapack_complex_float *ab );
00058 static void init_ipiv( lapack_int size, lapack_int *ipiv );
00059 static void init_b( lapack_int size, lapack_complex_float *b );
00060 static int compare_cgbtrs( lapack_complex_float *b, lapack_complex_float *b_i,
00061 lapack_int info, lapack_int info_i, lapack_int ldb,
00062 lapack_int nrhs );
00063
00064 int main(void)
00065 {
00066
00067 char trans, trans_i;
00068 lapack_int n, n_i;
00069 lapack_int kl, kl_i;
00070 lapack_int ku, ku_i;
00071 lapack_int nrhs, nrhs_i;
00072 lapack_int ldab, ldab_i;
00073 lapack_int ldab_r;
00074 lapack_int ldb, ldb_i;
00075 lapack_int ldb_r;
00076 lapack_int info, info_i;
00077 lapack_int i;
00078 int failed;
00079
00080
00081 lapack_complex_float *ab = NULL, *ab_i = NULL;
00082 lapack_int *ipiv = NULL, *ipiv_i = NULL;
00083 lapack_complex_float *b = NULL, *b_i = NULL;
00084 lapack_complex_float *b_save = NULL;
00085 lapack_complex_float *ab_r = NULL;
00086 lapack_complex_float *b_r = NULL;
00087
00088
00089 init_scalars_cgbtrs( &trans, &n, &kl, &ku, &nrhs, &ldab, &ldb );
00090 ldab_r = n+2;
00091 ldb_r = nrhs+2;
00092 trans_i = trans;
00093 n_i = n;
00094 kl_i = kl;
00095 ku_i = ku;
00096 nrhs_i = nrhs;
00097 ldab_i = ldab;
00098 ldb_i = ldb;
00099
00100
00101 ab = (lapack_complex_float *)
00102 LAPACKE_malloc( ldab*n * sizeof(lapack_complex_float) );
00103 ipiv = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
00104 b = (lapack_complex_float *)
00105 LAPACKE_malloc( ldb*nrhs * sizeof(lapack_complex_float) );
00106
00107
00108 ab_i = (lapack_complex_float *)
00109 LAPACKE_malloc( ldab*n * sizeof(lapack_complex_float) );
00110 ipiv_i = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
00111 b_i = (lapack_complex_float *)
00112 LAPACKE_malloc( ldb*nrhs * sizeof(lapack_complex_float) );
00113
00114
00115 b_save = (lapack_complex_float *)
00116 LAPACKE_malloc( ldb*nrhs * sizeof(lapack_complex_float) );
00117
00118
00119 ab_r = (lapack_complex_float *)
00120 LAPACKE_malloc( ((2*kl+ku+1)*(n+2)) * sizeof(lapack_complex_float) );
00121 b_r = (lapack_complex_float *)
00122 LAPACKE_malloc( n*(nrhs+2) * sizeof(lapack_complex_float) );
00123
00124
00125 init_ab( ldab*n, ab );
00126 init_ipiv( n, ipiv );
00127 init_b( ldb*nrhs, b );
00128
00129
00130 for( i = 0; i < ldb*nrhs; i++ ) {
00131 b_save[i] = b[i];
00132 }
00133
00134
00135 cgbtrs_( &trans, &n, &kl, &ku, &nrhs, ab, &ldab, ipiv, b, &ldb, &info );
00136
00137
00138
00139 for( i = 0; i < ldab*n; i++ ) {
00140 ab_i[i] = ab[i];
00141 }
00142 for( i = 0; i < n; i++ ) {
00143 ipiv_i[i] = ipiv[i];
00144 }
00145 for( i = 0; i < ldb*nrhs; i++ ) {
00146 b_i[i] = b_save[i];
00147 }
00148 info_i = LAPACKE_cgbtrs_work( LAPACK_COL_MAJOR, trans_i, n_i, kl_i, ku_i,
00149 nrhs_i, ab_i, ldab_i, ipiv_i, b_i, ldb_i );
00150
00151 failed = compare_cgbtrs( b, b_i, info, info_i, ldb, nrhs );
00152 if( failed == 0 ) {
00153 printf( "PASSED: column-major middle-level interface to cgbtrs\n" );
00154 } else {
00155 printf( "FAILED: column-major middle-level interface to cgbtrs\n" );
00156 }
00157
00158
00159
00160 for( i = 0; i < ldab*n; i++ ) {
00161 ab_i[i] = ab[i];
00162 }
00163 for( i = 0; i < n; i++ ) {
00164 ipiv_i[i] = ipiv[i];
00165 }
00166 for( i = 0; i < ldb*nrhs; i++ ) {
00167 b_i[i] = b_save[i];
00168 }
00169 info_i = LAPACKE_cgbtrs( LAPACK_COL_MAJOR, trans_i, n_i, kl_i, ku_i, nrhs_i,
00170 ab_i, ldab_i, ipiv_i, b_i, ldb_i );
00171
00172 failed = compare_cgbtrs( b, b_i, info, info_i, ldb, nrhs );
00173 if( failed == 0 ) {
00174 printf( "PASSED: column-major high-level interface to cgbtrs\n" );
00175 } else {
00176 printf( "FAILED: column-major high-level interface to cgbtrs\n" );
00177 }
00178
00179
00180
00181 for( i = 0; i < ldab*n; i++ ) {
00182 ab_i[i] = ab[i];
00183 }
00184 for( i = 0; i < n; i++ ) {
00185 ipiv_i[i] = ipiv[i];
00186 }
00187 for( i = 0; i < ldb*nrhs; i++ ) {
00188 b_i[i] = b_save[i];
00189 }
00190
00191 LAPACKE_cge_trans( LAPACK_COL_MAJOR, 2*kl+ku+1, n, ab_i, ldab, ab_r, n+2 );
00192 LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, nrhs, b_i, ldb, b_r, nrhs+2 );
00193 info_i = LAPACKE_cgbtrs_work( LAPACK_ROW_MAJOR, trans_i, n_i, kl_i, ku_i,
00194 nrhs_i, ab_r, ldab_r, ipiv_i, b_r, ldb_r );
00195
00196 LAPACKE_cge_trans( LAPACK_ROW_MAJOR, n, nrhs, b_r, nrhs+2, b_i, ldb );
00197
00198 failed = compare_cgbtrs( b, b_i, info, info_i, ldb, nrhs );
00199 if( failed == 0 ) {
00200 printf( "PASSED: row-major middle-level interface to cgbtrs\n" );
00201 } else {
00202 printf( "FAILED: row-major middle-level interface to cgbtrs\n" );
00203 }
00204
00205
00206
00207 for( i = 0; i < ldab*n; i++ ) {
00208 ab_i[i] = ab[i];
00209 }
00210 for( i = 0; i < n; i++ ) {
00211 ipiv_i[i] = ipiv[i];
00212 }
00213 for( i = 0; i < ldb*nrhs; i++ ) {
00214 b_i[i] = b_save[i];
00215 }
00216
00217
00218 LAPACKE_cge_trans( LAPACK_COL_MAJOR, 2*kl+ku+1, n, ab_i, ldab, ab_r, n+2 );
00219 LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, nrhs, b_i, ldb, b_r, nrhs+2 );
00220 info_i = LAPACKE_cgbtrs( LAPACK_ROW_MAJOR, trans_i, n_i, kl_i, ku_i, nrhs_i,
00221 ab_r, ldab_r, ipiv_i, b_r, ldb_r );
00222
00223 LAPACKE_cge_trans( LAPACK_ROW_MAJOR, n, nrhs, b_r, nrhs+2, b_i, ldb );
00224
00225 failed = compare_cgbtrs( b, b_i, info, info_i, ldb, nrhs );
00226 if( failed == 0 ) {
00227 printf( "PASSED: row-major high-level interface to cgbtrs\n" );
00228 } else {
00229 printf( "FAILED: row-major high-level interface to cgbtrs\n" );
00230 }
00231
00232
00233 if( ab != NULL ) {
00234 LAPACKE_free( ab );
00235 }
00236 if( ab_i != NULL ) {
00237 LAPACKE_free( ab_i );
00238 }
00239 if( ab_r != NULL ) {
00240 LAPACKE_free( ab_r );
00241 }
00242 if( ipiv != NULL ) {
00243 LAPACKE_free( ipiv );
00244 }
00245 if( ipiv_i != NULL ) {
00246 LAPACKE_free( ipiv_i );
00247 }
00248 if( b != NULL ) {
00249 LAPACKE_free( b );
00250 }
00251 if( b_i != NULL ) {
00252 LAPACKE_free( b_i );
00253 }
00254 if( b_r != NULL ) {
00255 LAPACKE_free( b_r );
00256 }
00257 if( b_save != NULL ) {
00258 LAPACKE_free( b_save );
00259 }
00260
00261 return 0;
00262 }
00263
00264
00265 static void init_scalars_cgbtrs( char *trans, lapack_int *n, lapack_int *kl,
00266 lapack_int *ku, lapack_int *nrhs,
00267 lapack_int *ldab, lapack_int *ldb )
00268 {
00269 *trans = 'N';
00270 *n = 4;
00271 *kl = 1;
00272 *ku = 2;
00273 *nrhs = 2;
00274 *ldab = 25;
00275 *ldb = 8;
00276
00277 return;
00278 }
00279
00280
00281 static void init_ab( lapack_int size, lapack_complex_float *ab ) {
00282 lapack_int i;
00283 for( i = 0; i < size; i++ ) {
00284 ab[i] = lapack_make_complex_float( 0.0f, 0.0f );
00285 }
00286 ab[0] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00287 ab[25] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00288 ab[50] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00289 ab[75] = lapack_make_complex_float( 5.899999738e-001, -4.799999893e-001 );
00290 ab[1] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00291 ab[26] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00292 ab[51] = lapack_make_complex_float( -3.990000010e+000, 4.010000229e+000 );
00293 ab[76] = lapack_make_complex_float( 3.329999924e+000, -1.039999962e+000 );
00294 ab[2] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00295 ab[27] = lapack_make_complex_float( -1.480000019e+000, -1.750000000e+000 );
00296 ab[52] = lapack_make_complex_float( -1.059999943e+000, 1.940000057e+000 );
00297 ab[77] = lapack_make_complex_float( -1.769209266e+000, -1.858747363e+000 );
00298 ab[3] = lapack_make_complex_float( 0.000000000e+000, 6.300000191e+000 );
00299 ab[28] = lapack_make_complex_float( -7.699999809e-001, 2.829999924e+000 );
00300 ab[53] = lapack_make_complex_float( 4.930266857e+000, -3.008563757e+000 );
00301 ab[78] = lapack_make_complex_float( 4.337749183e-001, 1.232528687e-001 );
00302 ab[4] = lapack_make_complex_float( 3.587301373e-001, 2.619047463e-001 );
00303 ab[29] = lapack_make_complex_float( 2.314260751e-001, 6.357648969e-001 );
00304 ab[54] = lapack_make_complex_float( 7.604227066e-001, 2.429442555e-001 );
00305 ab[79] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00306 }
00307 static void init_ipiv( lapack_int size, lapack_int *ipiv ) {
00308 lapack_int i;
00309 for( i = 0; i < size; i++ ) {
00310 ipiv[i] = 0;
00311 }
00312 ipiv[0] = 2;
00313 ipiv[1] = 3;
00314 ipiv[2] = 3;
00315 ipiv[3] = 4;
00316 }
00317 static void init_b( lapack_int size, lapack_complex_float *b ) {
00318 lapack_int i;
00319 for( i = 0; i < size; i++ ) {
00320 b[i] = lapack_make_complex_float( 0.0f, 0.0f );
00321 }
00322 b[0] = lapack_make_complex_float( -1.059999943e+000, 2.150000000e+001 );
00323 b[8] = lapack_make_complex_float( 1.285000038e+001, 2.839999914e+000 );
00324 b[1] = lapack_make_complex_float( -2.271999931e+001, -5.390000153e+001 );
00325 b[9] = lapack_make_complex_float( -7.022000122e+001, 2.156999969e+001 );
00326 b[2] = lapack_make_complex_float( 2.823999977e+001, -3.859999847e+001 );
00327 b[10] = lapack_make_complex_float( -2.072999954e+001, -1.230000019e+000 );
00328 b[3] = lapack_make_complex_float( -3.456000137e+001, 1.672999954e+001 );
00329 b[11] = lapack_make_complex_float( 2.601000023e+001, 3.196999931e+001 );
00330 }
00331
00332
00333
00334 static int compare_cgbtrs( lapack_complex_float *b, lapack_complex_float *b_i,
00335 lapack_int info, lapack_int info_i, lapack_int ldb,
00336 lapack_int nrhs )
00337 {
00338 lapack_int i;
00339 int failed = 0;
00340 for( i = 0; i < ldb*nrhs; i++ ) {
00341 failed += compare_complex_floats(b[i],b_i[i]);
00342 }
00343 failed += (info == info_i) ? 0 : 1;
00344 if( info != 0 || info_i != 0 ) {
00345 printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00346 }
00347
00348 return failed;
00349 }