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_ctbtrs( char *uplo, char *trans, char *diag,
00055 lapack_int *n, lapack_int *kd,
00056 lapack_int *nrhs, lapack_int *ldab,
00057 lapack_int *ldb );
00058 static void init_ab( lapack_int size, lapack_complex_float *ab );
00059 static void init_b( lapack_int size, lapack_complex_float *b );
00060 static int compare_ctbtrs( 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 uplo, uplo_i;
00068 char trans, trans_i;
00069 char diag, diag_i;
00070 lapack_int n, n_i;
00071 lapack_int kd, kd_i;
00072 lapack_int nrhs, nrhs_i;
00073 lapack_int ldab, ldab_i;
00074 lapack_int ldab_r;
00075 lapack_int ldb, ldb_i;
00076 lapack_int ldb_r;
00077 lapack_int info, info_i;
00078 lapack_int i;
00079 int failed;
00080
00081
00082 lapack_complex_float *ab = NULL, *ab_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_ctbtrs( &uplo, &trans, &diag, &n, &kd, &nrhs, &ldab, &ldb );
00090 ldab_r = n+2;
00091 ldb_r = nrhs+2;
00092 uplo_i = uplo;
00093 trans_i = trans;
00094 diag_i = diag;
00095 n_i = n;
00096 kd_i = kd;
00097 nrhs_i = nrhs;
00098 ldab_i = ldab;
00099 ldb_i = ldb;
00100
00101
00102 ab = (lapack_complex_float *)
00103 LAPACKE_malloc( ldab*n * sizeof(lapack_complex_float) );
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 b_i = (lapack_complex_float *)
00111 LAPACKE_malloc( ldb*nrhs * sizeof(lapack_complex_float) );
00112
00113
00114 b_save = (lapack_complex_float *)
00115 LAPACKE_malloc( ldb*nrhs * sizeof(lapack_complex_float) );
00116
00117
00118 ab_r = (lapack_complex_float *)
00119 LAPACKE_malloc( (kd+1)*(n+2) * sizeof(lapack_complex_float) );
00120 b_r = (lapack_complex_float *)
00121 LAPACKE_malloc( n*(nrhs+2) * sizeof(lapack_complex_float) );
00122
00123
00124 init_ab( ldab*n, ab );
00125 init_b( ldb*nrhs, b );
00126
00127
00128 for( i = 0; i < ldb*nrhs; i++ ) {
00129 b_save[i] = b[i];
00130 }
00131
00132
00133 ctbtrs_( &uplo, &trans, &diag, &n, &kd, &nrhs, ab, &ldab, b, &ldb, &info );
00134
00135
00136
00137 for( i = 0; i < ldab*n; i++ ) {
00138 ab_i[i] = ab[i];
00139 }
00140 for( i = 0; i < ldb*nrhs; i++ ) {
00141 b_i[i] = b_save[i];
00142 }
00143 info_i = LAPACKE_ctbtrs_work( LAPACK_COL_MAJOR, uplo_i, trans_i, diag_i,
00144 n_i, kd_i, nrhs_i, ab_i, ldab_i, b_i, ldb_i );
00145
00146 failed = compare_ctbtrs( b, b_i, info, info_i, ldb, nrhs );
00147 if( failed == 0 ) {
00148 printf( "PASSED: column-major middle-level interface to ctbtrs\n" );
00149 } else {
00150 printf( "FAILED: column-major middle-level interface to ctbtrs\n" );
00151 }
00152
00153
00154
00155 for( i = 0; i < ldab*n; i++ ) {
00156 ab_i[i] = ab[i];
00157 }
00158 for( i = 0; i < ldb*nrhs; i++ ) {
00159 b_i[i] = b_save[i];
00160 }
00161 info_i = LAPACKE_ctbtrs( LAPACK_COL_MAJOR, uplo_i, trans_i, diag_i, n_i,
00162 kd_i, nrhs_i, ab_i, ldab_i, b_i, ldb_i );
00163
00164 failed = compare_ctbtrs( b, b_i, info, info_i, ldb, nrhs );
00165 if( failed == 0 ) {
00166 printf( "PASSED: column-major high-level interface to ctbtrs\n" );
00167 } else {
00168 printf( "FAILED: column-major high-level interface to ctbtrs\n" );
00169 }
00170
00171
00172
00173 for( i = 0; i < ldab*n; i++ ) {
00174 ab_i[i] = ab[i];
00175 }
00176 for( i = 0; i < ldb*nrhs; i++ ) {
00177 b_i[i] = b_save[i];
00178 }
00179
00180 LAPACKE_cge_trans( LAPACK_COL_MAJOR, kd+1, n, ab_i, ldab, ab_r, n+2 );
00181 LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, nrhs, b_i, ldb, b_r, nrhs+2 );
00182 info_i = LAPACKE_ctbtrs_work( LAPACK_ROW_MAJOR, uplo_i, trans_i, diag_i,
00183 n_i, kd_i, nrhs_i, ab_r, ldab_r, b_r, ldb_r );
00184
00185 LAPACKE_cge_trans( LAPACK_ROW_MAJOR, n, nrhs, b_r, nrhs+2, b_i, ldb );
00186
00187 failed = compare_ctbtrs( b, b_i, info, info_i, ldb, nrhs );
00188 if( failed == 0 ) {
00189 printf( "PASSED: row-major middle-level interface to ctbtrs\n" );
00190 } else {
00191 printf( "FAILED: row-major middle-level interface to ctbtrs\n" );
00192 }
00193
00194
00195
00196 for( i = 0; i < ldab*n; i++ ) {
00197 ab_i[i] = ab[i];
00198 }
00199 for( i = 0; i < ldb*nrhs; i++ ) {
00200 b_i[i] = b_save[i];
00201 }
00202
00203
00204 LAPACKE_cge_trans( LAPACK_COL_MAJOR, kd+1, n, ab_i, ldab, ab_r, n+2 );
00205 LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, nrhs, b_i, ldb, b_r, nrhs+2 );
00206 info_i = LAPACKE_ctbtrs( LAPACK_ROW_MAJOR, uplo_i, trans_i, diag_i, n_i,
00207 kd_i, nrhs_i, ab_r, ldab_r, b_r, ldb_r );
00208
00209 LAPACKE_cge_trans( LAPACK_ROW_MAJOR, n, nrhs, b_r, nrhs+2, b_i, ldb );
00210
00211 failed = compare_ctbtrs( b, b_i, info, info_i, ldb, nrhs );
00212 if( failed == 0 ) {
00213 printf( "PASSED: row-major high-level interface to ctbtrs\n" );
00214 } else {
00215 printf( "FAILED: row-major high-level interface to ctbtrs\n" );
00216 }
00217
00218
00219 if( ab != NULL ) {
00220 LAPACKE_free( ab );
00221 }
00222 if( ab_i != NULL ) {
00223 LAPACKE_free( ab_i );
00224 }
00225 if( ab_r != NULL ) {
00226 LAPACKE_free( ab_r );
00227 }
00228 if( b != NULL ) {
00229 LAPACKE_free( b );
00230 }
00231 if( b_i != NULL ) {
00232 LAPACKE_free( b_i );
00233 }
00234 if( b_r != NULL ) {
00235 LAPACKE_free( b_r );
00236 }
00237 if( b_save != NULL ) {
00238 LAPACKE_free( b_save );
00239 }
00240
00241 return 0;
00242 }
00243
00244
00245 static void init_scalars_ctbtrs( char *uplo, char *trans, char *diag,
00246 lapack_int *n, lapack_int *kd,
00247 lapack_int *nrhs, lapack_int *ldab,
00248 lapack_int *ldb )
00249 {
00250 *uplo = 'L';
00251 *trans = 'N';
00252 *diag = 'N';
00253 *n = 4;
00254 *kd = 2;
00255 *nrhs = 2;
00256 *ldab = 9;
00257 *ldb = 8;
00258
00259 return;
00260 }
00261
00262
00263 static void init_ab( lapack_int size, lapack_complex_float *ab ) {
00264 lapack_int i;
00265 for( i = 0; i < size; i++ ) {
00266 ab[i] = lapack_make_complex_float( 0.0f, 0.0f );
00267 }
00268 ab[0] = lapack_make_complex_float( -1.940000057e+000, 4.429999828e+000 );
00269 ab[9] = lapack_make_complex_float( 4.119999886e+000, -4.269999981e+000 );
00270 ab[18] = lapack_make_complex_float( 4.300000072e-001, -2.660000086e+000 );
00271 ab[27] = lapack_make_complex_float( 4.399999976e-001, 1.000000015e-001 );
00272 ab[1] = lapack_make_complex_float( -3.390000105e+000, 3.440000057e+000 );
00273 ab[10] = lapack_make_complex_float( -1.840000033e+000, 5.530000210e+000 );
00274 ab[19] = lapack_make_complex_float( 1.740000010e+000, -3.999999911e-002 );
00275 ab[28] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00276 ab[2] = lapack_make_complex_float( 1.620000005e+000, 3.680000067e+000 );
00277 ab[11] = lapack_make_complex_float( -2.769999981e+000, -1.929999948e+000 );
00278 ab[20] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00279 ab[29] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00280 }
00281 static void init_b( lapack_int size, lapack_complex_float *b ) {
00282 lapack_int i;
00283 for( i = 0; i < size; i++ ) {
00284 b[i] = lapack_make_complex_float( 0.0f, 0.0f );
00285 }
00286 b[0] = lapack_make_complex_float( -8.859999657e+000, -3.880000114e+000 );
00287 b[8] = lapack_make_complex_float( -2.409000015e+001, -5.269999981e+000 );
00288 b[1] = lapack_make_complex_float( -1.556999969e+001, -2.340999985e+001 );
00289 b[9] = lapack_make_complex_float( -5.797000122e+001, 8.140000343e+000 );
00290 b[2] = lapack_make_complex_float( -7.630000114e+000, 2.278000069e+001 );
00291 b[10] = lapack_make_complex_float( 1.909000015e+001, -2.951000023e+001 );
00292 b[3] = lapack_make_complex_float( -1.473999977e+001, -2.400000095e+000 );
00293 b[11] = lapack_make_complex_float( 1.917000008e+001, 2.132999992e+001 );
00294 }
00295
00296
00297
00298 static int compare_ctbtrs( lapack_complex_float *b, lapack_complex_float *b_i,
00299 lapack_int info, lapack_int info_i, lapack_int ldb,
00300 lapack_int nrhs )
00301 {
00302 lapack_int i;
00303 int failed = 0;
00304 for( i = 0; i < ldb*nrhs; i++ ) {
00305 failed += compare_complex_floats(b[i],b_i[i]);
00306 }
00307 failed += (info == info_i) ? 0 : 1;
00308 if( info != 0 || info_i != 0 ) {
00309 printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00310 }
00311
00312 return failed;
00313 }