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_stbtrs( 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, float *ab );
00059 static void init_b( lapack_int size, float *b );
00060 static int compare_stbtrs( float *b, float *b_i, lapack_int info,
00061 lapack_int info_i, lapack_int ldb, lapack_int nrhs );
00062
00063 int main(void)
00064 {
00065
00066 char uplo, uplo_i;
00067 char trans, trans_i;
00068 char diag, diag_i;
00069 lapack_int n, n_i;
00070 lapack_int kd, kd_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 float *ab = NULL, *ab_i = NULL;
00082 float *b = NULL, *b_i = NULL;
00083 float *b_save = NULL;
00084 float *ab_r = NULL;
00085 float *b_r = NULL;
00086
00087
00088 init_scalars_stbtrs( &uplo, &trans, &diag, &n, &kd, &nrhs, &ldab, &ldb );
00089 ldab_r = n+2;
00090 ldb_r = nrhs+2;
00091 uplo_i = uplo;
00092 trans_i = trans;
00093 diag_i = diag;
00094 n_i = n;
00095 kd_i = kd;
00096 nrhs_i = nrhs;
00097 ldab_i = ldab;
00098 ldb_i = ldb;
00099
00100
00101 ab = (float *)LAPACKE_malloc( ldab*n * sizeof(float) );
00102 b = (float *)LAPACKE_malloc( ldb*nrhs * sizeof(float) );
00103
00104
00105 ab_i = (float *)LAPACKE_malloc( ldab*n * sizeof(float) );
00106 b_i = (float *)LAPACKE_malloc( ldb*nrhs * sizeof(float) );
00107
00108
00109 b_save = (float *)LAPACKE_malloc( ldb*nrhs * sizeof(float) );
00110
00111
00112 ab_r = (float *)LAPACKE_malloc( (kd+1)*(n+2) * sizeof(float) );
00113 b_r = (float *)LAPACKE_malloc( n*(nrhs+2) * sizeof(float) );
00114
00115
00116 init_ab( ldab*n, ab );
00117 init_b( ldb*nrhs, b );
00118
00119
00120 for( i = 0; i < ldb*nrhs; i++ ) {
00121 b_save[i] = b[i];
00122 }
00123
00124
00125 stbtrs_( &uplo, &trans, &diag, &n, &kd, &nrhs, ab, &ldab, b, &ldb, &info );
00126
00127
00128
00129 for( i = 0; i < ldab*n; i++ ) {
00130 ab_i[i] = ab[i];
00131 }
00132 for( i = 0; i < ldb*nrhs; i++ ) {
00133 b_i[i] = b_save[i];
00134 }
00135 info_i = LAPACKE_stbtrs_work( LAPACK_COL_MAJOR, uplo_i, trans_i, diag_i,
00136 n_i, kd_i, nrhs_i, ab_i, ldab_i, b_i, ldb_i );
00137
00138 failed = compare_stbtrs( b, b_i, info, info_i, ldb, nrhs );
00139 if( failed == 0 ) {
00140 printf( "PASSED: column-major middle-level interface to stbtrs\n" );
00141 } else {
00142 printf( "FAILED: column-major middle-level interface to stbtrs\n" );
00143 }
00144
00145
00146
00147 for( i = 0; i < ldab*n; i++ ) {
00148 ab_i[i] = ab[i];
00149 }
00150 for( i = 0; i < ldb*nrhs; i++ ) {
00151 b_i[i] = b_save[i];
00152 }
00153 info_i = LAPACKE_stbtrs( LAPACK_COL_MAJOR, uplo_i, trans_i, diag_i, n_i,
00154 kd_i, nrhs_i, ab_i, ldab_i, b_i, ldb_i );
00155
00156 failed = compare_stbtrs( b, b_i, info, info_i, ldb, nrhs );
00157 if( failed == 0 ) {
00158 printf( "PASSED: column-major high-level interface to stbtrs\n" );
00159 } else {
00160 printf( "FAILED: column-major high-level interface to stbtrs\n" );
00161 }
00162
00163
00164
00165 for( i = 0; i < ldab*n; i++ ) {
00166 ab_i[i] = ab[i];
00167 }
00168 for( i = 0; i < ldb*nrhs; i++ ) {
00169 b_i[i] = b_save[i];
00170 }
00171
00172 LAPACKE_sge_trans( LAPACK_COL_MAJOR, kd+1, n, ab_i, ldab, ab_r, n+2 );
00173 LAPACKE_sge_trans( LAPACK_COL_MAJOR, n, nrhs, b_i, ldb, b_r, nrhs+2 );
00174 info_i = LAPACKE_stbtrs_work( LAPACK_ROW_MAJOR, uplo_i, trans_i, diag_i,
00175 n_i, kd_i, nrhs_i, ab_r, ldab_r, b_r, ldb_r );
00176
00177 LAPACKE_sge_trans( LAPACK_ROW_MAJOR, n, nrhs, b_r, nrhs+2, b_i, ldb );
00178
00179 failed = compare_stbtrs( b, b_i, info, info_i, ldb, nrhs );
00180 if( failed == 0 ) {
00181 printf( "PASSED: row-major middle-level interface to stbtrs\n" );
00182 } else {
00183 printf( "FAILED: row-major middle-level interface to stbtrs\n" );
00184 }
00185
00186
00187
00188 for( i = 0; i < ldab*n; i++ ) {
00189 ab_i[i] = ab[i];
00190 }
00191 for( i = 0; i < ldb*nrhs; i++ ) {
00192 b_i[i] = b_save[i];
00193 }
00194
00195
00196 LAPACKE_sge_trans( LAPACK_COL_MAJOR, kd+1, n, ab_i, ldab, ab_r, n+2 );
00197 LAPACKE_sge_trans( LAPACK_COL_MAJOR, n, nrhs, b_i, ldb, b_r, nrhs+2 );
00198 info_i = LAPACKE_stbtrs( LAPACK_ROW_MAJOR, uplo_i, trans_i, diag_i, n_i,
00199 kd_i, nrhs_i, ab_r, ldab_r, b_r, ldb_r );
00200
00201 LAPACKE_sge_trans( LAPACK_ROW_MAJOR, n, nrhs, b_r, nrhs+2, b_i, ldb );
00202
00203 failed = compare_stbtrs( b, b_i, info, info_i, ldb, nrhs );
00204 if( failed == 0 ) {
00205 printf( "PASSED: row-major high-level interface to stbtrs\n" );
00206 } else {
00207 printf( "FAILED: row-major high-level interface to stbtrs\n" );
00208 }
00209
00210
00211 if( ab != NULL ) {
00212 LAPACKE_free( ab );
00213 }
00214 if( ab_i != NULL ) {
00215 LAPACKE_free( ab_i );
00216 }
00217 if( ab_r != NULL ) {
00218 LAPACKE_free( ab_r );
00219 }
00220 if( b != NULL ) {
00221 LAPACKE_free( b );
00222 }
00223 if( b_i != NULL ) {
00224 LAPACKE_free( b_i );
00225 }
00226 if( b_r != NULL ) {
00227 LAPACKE_free( b_r );
00228 }
00229 if( b_save != NULL ) {
00230 LAPACKE_free( b_save );
00231 }
00232
00233 return 0;
00234 }
00235
00236
00237 static void init_scalars_stbtrs( char *uplo, char *trans, char *diag,
00238 lapack_int *n, lapack_int *kd,
00239 lapack_int *nrhs, lapack_int *ldab,
00240 lapack_int *ldb )
00241 {
00242 *uplo = 'L';
00243 *trans = 'N';
00244 *diag = 'N';
00245 *n = 4;
00246 *kd = 1;
00247 *nrhs = 2;
00248 *ldab = 9;
00249 *ldb = 8;
00250
00251 return;
00252 }
00253
00254
00255 static void init_ab( lapack_int size, float *ab ) {
00256 lapack_int i;
00257 for( i = 0; i < size; i++ ) {
00258 ab[i] = 0;
00259 }
00260 ab[0] = -4.159999847e+000;
00261 ab[9] = 4.780000210e+000;
00262 ab[18] = 6.320000172e+000;
00263 ab[27] = 1.599999964e-001;
00264 ab[1] = -2.250000000e+000;
00265 ab[10] = 5.860000134e+000;
00266 ab[19] = -4.820000172e+000;
00267 ab[28] = 0.000000000e+000;
00268 }
00269 static void init_b( lapack_int size, float *b ) {
00270 lapack_int i;
00271 for( i = 0; i < size; i++ ) {
00272 b[i] = 0;
00273 }
00274 b[0] = -1.663999939e+001;
00275 b[8] = -4.159999847e+000;
00276 b[1] = -1.377999973e+001;
00277 b[9] = -1.659000015e+001;
00278 b[2] = 1.310000038e+001;
00279 b[10] = -4.940000057e+000;
00280 b[3] = -1.414000034e+001;
00281 b[11] = -9.960000038e+000;
00282 }
00283
00284
00285
00286 static int compare_stbtrs( float *b, float *b_i, lapack_int info,
00287 lapack_int info_i, lapack_int ldb, lapack_int nrhs )
00288 {
00289 lapack_int i;
00290 int failed = 0;
00291 for( i = 0; i < ldb*nrhs; i++ ) {
00292 failed += compare_floats(b[i],b_i[i]);
00293 }
00294 failed += (info == info_i) ? 0 : 1;
00295 if( info != 0 || info_i != 0 ) {
00296 printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00297 }
00298
00299 return failed;
00300 }