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_ztbtrs( 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_double *ab );
00059 static void init_b( lapack_int size, lapack_complex_double *b );
00060 static int compare_ztbtrs( lapack_complex_double *b, lapack_complex_double *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_double *ab = NULL, *ab_i = NULL;
00083 lapack_complex_double *b = NULL, *b_i = NULL;
00084 lapack_complex_double *b_save = NULL;
00085 lapack_complex_double *ab_r = NULL;
00086 lapack_complex_double *b_r = NULL;
00087
00088
00089 init_scalars_ztbtrs( &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_double *)
00103 LAPACKE_malloc( ldab*n * sizeof(lapack_complex_double) );
00104 b = (lapack_complex_double *)
00105 LAPACKE_malloc( ldb*nrhs * sizeof(lapack_complex_double) );
00106
00107
00108 ab_i = (lapack_complex_double *)
00109 LAPACKE_malloc( ldab*n * sizeof(lapack_complex_double) );
00110 b_i = (lapack_complex_double *)
00111 LAPACKE_malloc( ldb*nrhs * sizeof(lapack_complex_double) );
00112
00113
00114 b_save = (lapack_complex_double *)
00115 LAPACKE_malloc( ldb*nrhs * sizeof(lapack_complex_double) );
00116
00117
00118 ab_r = (lapack_complex_double *)
00119 LAPACKE_malloc( (kd+1)*(n+2) * sizeof(lapack_complex_double) );
00120 b_r = (lapack_complex_double *)
00121 LAPACKE_malloc( n*(nrhs+2) * sizeof(lapack_complex_double) );
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 ztbtrs_( &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_ztbtrs_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_ztbtrs( b, b_i, info, info_i, ldb, nrhs );
00147 if( failed == 0 ) {
00148 printf( "PASSED: column-major middle-level interface to ztbtrs\n" );
00149 } else {
00150 printf( "FAILED: column-major middle-level interface to ztbtrs\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_ztbtrs( 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_ztbtrs( b, b_i, info, info_i, ldb, nrhs );
00165 if( failed == 0 ) {
00166 printf( "PASSED: column-major high-level interface to ztbtrs\n" );
00167 } else {
00168 printf( "FAILED: column-major high-level interface to ztbtrs\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_zge_trans( LAPACK_COL_MAJOR, kd+1, n, ab_i, ldab, ab_r, n+2 );
00181 LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, nrhs, b_i, ldb, b_r, nrhs+2 );
00182 info_i = LAPACKE_ztbtrs_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_zge_trans( LAPACK_ROW_MAJOR, n, nrhs, b_r, nrhs+2, b_i, ldb );
00186
00187 failed = compare_ztbtrs( b, b_i, info, info_i, ldb, nrhs );
00188 if( failed == 0 ) {
00189 printf( "PASSED: row-major middle-level interface to ztbtrs\n" );
00190 } else {
00191 printf( "FAILED: row-major middle-level interface to ztbtrs\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_zge_trans( LAPACK_COL_MAJOR, kd+1, n, ab_i, ldab, ab_r, n+2 );
00205 LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, nrhs, b_i, ldb, b_r, nrhs+2 );
00206 info_i = LAPACKE_ztbtrs( 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_zge_trans( LAPACK_ROW_MAJOR, n, nrhs, b_r, nrhs+2, b_i, ldb );
00210
00211 failed = compare_ztbtrs( b, b_i, info, info_i, ldb, nrhs );
00212 if( failed == 0 ) {
00213 printf( "PASSED: row-major high-level interface to ztbtrs\n" );
00214 } else {
00215 printf( "FAILED: row-major high-level interface to ztbtrs\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_ztbtrs( 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_double *ab ) {
00264 lapack_int i;
00265 for( i = 0; i < size; i++ ) {
00266 ab[i] = lapack_make_complex_double( 0.0, 0.0 );
00267 }
00268 ab[0] = lapack_make_complex_double( -1.93999999999999990e+000,
00269 4.42999999999999970e+000 );
00270 ab[9] = lapack_make_complex_double( 4.12000000000000010e+000,
00271 -4.26999999999999960e+000 );
00272 ab[18] = lapack_make_complex_double( 4.29999999999999990e-001,
00273 -2.66000000000000010e+000 );
00274 ab[27] = lapack_make_complex_double( 4.40000000000000000e-001,
00275 1.00000000000000010e-001 );
00276 ab[1] = lapack_make_complex_double( -3.39000000000000010e+000,
00277 3.43999999999999990e+000 );
00278 ab[10] = lapack_make_complex_double( -1.84000000000000010e+000,
00279 5.53000000000000020e+000 );
00280 ab[19] = lapack_make_complex_double( 1.74000000000000000e+000,
00281 -4.00000000000000010e-002 );
00282 ab[28] = lapack_make_complex_double( 0.00000000000000000e+000,
00283 0.00000000000000000e+000 );
00284 ab[2] = lapack_make_complex_double( 1.62000000000000010e+000,
00285 3.68000000000000020e+000 );
00286 ab[11] = lapack_make_complex_double( -2.77000000000000000e+000,
00287 -1.92999999999999990e+000 );
00288 ab[20] = lapack_make_complex_double( 0.00000000000000000e+000,
00289 0.00000000000000000e+000 );
00290 ab[29] = lapack_make_complex_double( 0.00000000000000000e+000,
00291 0.00000000000000000e+000 );
00292 }
00293 static void init_b( lapack_int size, lapack_complex_double *b ) {
00294 lapack_int i;
00295 for( i = 0; i < size; i++ ) {
00296 b[i] = lapack_make_complex_double( 0.0, 0.0 );
00297 }
00298 b[0] = lapack_make_complex_double( -8.85999999999999940e+000,
00299 -3.87999999999999990e+000 );
00300 b[8] = lapack_make_complex_double( -2.40900000000000000e+001,
00301 -5.26999999999999960e+000 );
00302 b[1] = lapack_make_complex_double( -1.55700000000000000e+001,
00303 -2.34100000000000000e+001 );
00304 b[9] = lapack_make_complex_double( -5.79699999999999990e+001,
00305 8.14000000000000060e+000 );
00306 b[2] = lapack_make_complex_double( -7.62999999999999990e+000,
00307 2.27800000000000010e+001 );
00308 b[10] = lapack_make_complex_double( 1.90900000000000000e+001,
00309 -2.95100000000000020e+001 );
00310 b[3] = lapack_make_complex_double( -1.47400000000000000e+001,
00311 -2.39999999999999990e+000 );
00312 b[11] = lapack_make_complex_double( 1.91700000000000020e+001,
00313 2.13299999999999980e+001 );
00314 }
00315
00316
00317
00318 static int compare_ztbtrs( lapack_complex_double *b, lapack_complex_double *b_i,
00319 lapack_int info, lapack_int info_i, lapack_int ldb,
00320 lapack_int nrhs )
00321 {
00322 lapack_int i;
00323 int failed = 0;
00324 for( i = 0; i < ldb*nrhs; i++ ) {
00325 failed += compare_complex_doubles(b[i],b_i[i]);
00326 }
00327 failed += (info == info_i) ? 0 : 1;
00328 if( info != 0 || info_i != 0 ) {
00329 printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00330 }
00331
00332 return failed;
00333 }