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_sgbcon( char *norm, lapack_int *n, lapack_int *kl,
00055 lapack_int *ku, lapack_int *ldab,
00056 float *anorm );
00057 static void init_ab( lapack_int size, float *ab );
00058 static void init_ipiv( lapack_int size, lapack_int *ipiv );
00059 static void init_work( lapack_int size, float *work );
00060 static void init_iwork( lapack_int size, lapack_int *iwork );
00061 static int compare_sgbcon( float rcond, float rcond_i, lapack_int info,
00062 lapack_int info_i );
00063
00064 int main(void)
00065 {
00066
00067 char norm, norm_i;
00068 lapack_int n, n_i;
00069 lapack_int kl, kl_i;
00070 lapack_int ku, ku_i;
00071 lapack_int ldab, ldab_i;
00072 lapack_int ldab_r;
00073 float anorm, anorm_i;
00074 float rcond, rcond_i;
00075 lapack_int info, info_i;
00076 lapack_int i;
00077 int failed;
00078
00079
00080 float *ab = NULL, *ab_i = NULL;
00081 lapack_int *ipiv = NULL, *ipiv_i = NULL;
00082 float *work = NULL, *work_i = NULL;
00083 lapack_int *iwork = NULL, *iwork_i = NULL;
00084 float *ab_r = NULL;
00085
00086
00087 init_scalars_sgbcon( &norm, &n, &kl, &ku, &ldab, &anorm );
00088 ldab_r = n+2;
00089 norm_i = norm;
00090 n_i = n;
00091 kl_i = kl;
00092 ku_i = ku;
00093 ldab_i = ldab;
00094 anorm_i = anorm;
00095
00096
00097 ab = (float *)LAPACKE_malloc( ldab*n * sizeof(float) );
00098 ipiv = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
00099 work = (float *)LAPACKE_malloc( 3*n * sizeof(float) );
00100 iwork = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
00101
00102
00103 ab_i = (float *)LAPACKE_malloc( ldab*n * sizeof(float) );
00104 ipiv_i = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
00105 work_i = (float *)LAPACKE_malloc( 3*n * sizeof(float) );
00106 iwork_i = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
00107
00108
00109 ab_r = (float *)LAPACKE_malloc( ((2*kl+ku+1)*(n+2)) * sizeof(float) );
00110
00111
00112 init_ab( ldab*n, ab );
00113 init_ipiv( n, ipiv );
00114 init_work( 3*n, work );
00115 init_iwork( n, iwork );
00116
00117
00118 sgbcon_( &norm, &n, &kl, &ku, ab, &ldab, ipiv, &anorm, &rcond, work, iwork,
00119 &info );
00120
00121
00122
00123 for( i = 0; i < ldab*n; i++ ) {
00124 ab_i[i] = ab[i];
00125 }
00126 for( i = 0; i < n; i++ ) {
00127 ipiv_i[i] = ipiv[i];
00128 }
00129 for( i = 0; i < 3*n; i++ ) {
00130 work_i[i] = work[i];
00131 }
00132 for( i = 0; i < n; i++ ) {
00133 iwork_i[i] = iwork[i];
00134 }
00135 info_i = LAPACKE_sgbcon_work( LAPACK_COL_MAJOR, norm_i, n_i, kl_i, ku_i,
00136 ab_i, ldab_i, ipiv_i, anorm_i, &rcond_i,
00137 work_i, iwork_i );
00138
00139 failed = compare_sgbcon( rcond, rcond_i, info, info_i );
00140 if( failed == 0 ) {
00141 printf( "PASSED: column-major middle-level interface to sgbcon\n" );
00142 } else {
00143 printf( "FAILED: column-major middle-level interface to sgbcon\n" );
00144 }
00145
00146
00147
00148 for( i = 0; i < ldab*n; i++ ) {
00149 ab_i[i] = ab[i];
00150 }
00151 for( i = 0; i < n; i++ ) {
00152 ipiv_i[i] = ipiv[i];
00153 }
00154 for( i = 0; i < 3*n; i++ ) {
00155 work_i[i] = work[i];
00156 }
00157 for( i = 0; i < n; i++ ) {
00158 iwork_i[i] = iwork[i];
00159 }
00160 info_i = LAPACKE_sgbcon( LAPACK_COL_MAJOR, norm_i, n_i, kl_i, ku_i, ab_i,
00161 ldab_i, ipiv_i, anorm_i, &rcond_i );
00162
00163 failed = compare_sgbcon( rcond, rcond_i, info, info_i );
00164 if( failed == 0 ) {
00165 printf( "PASSED: column-major high-level interface to sgbcon\n" );
00166 } else {
00167 printf( "FAILED: column-major high-level interface to sgbcon\n" );
00168 }
00169
00170
00171
00172 for( i = 0; i < ldab*n; i++ ) {
00173 ab_i[i] = ab[i];
00174 }
00175 for( i = 0; i < n; i++ ) {
00176 ipiv_i[i] = ipiv[i];
00177 }
00178 for( i = 0; i < 3*n; i++ ) {
00179 work_i[i] = work[i];
00180 }
00181 for( i = 0; i < n; i++ ) {
00182 iwork_i[i] = iwork[i];
00183 }
00184
00185 LAPACKE_sge_trans( LAPACK_COL_MAJOR, 2*kl+ku+1, n, ab_i, ldab, ab_r, n+2 );
00186 info_i = LAPACKE_sgbcon_work( LAPACK_ROW_MAJOR, norm_i, n_i, kl_i, ku_i,
00187 ab_r, ldab_r, ipiv_i, anorm_i, &rcond_i,
00188 work_i, iwork_i );
00189
00190 failed = compare_sgbcon( rcond, rcond_i, info, info_i );
00191 if( failed == 0 ) {
00192 printf( "PASSED: row-major middle-level interface to sgbcon\n" );
00193 } else {
00194 printf( "FAILED: row-major middle-level interface to sgbcon\n" );
00195 }
00196
00197
00198
00199 for( i = 0; i < ldab*n; i++ ) {
00200 ab_i[i] = ab[i];
00201 }
00202 for( i = 0; i < n; i++ ) {
00203 ipiv_i[i] = ipiv[i];
00204 }
00205 for( i = 0; i < 3*n; i++ ) {
00206 work_i[i] = work[i];
00207 }
00208 for( i = 0; i < n; i++ ) {
00209 iwork_i[i] = iwork[i];
00210 }
00211
00212
00213 LAPACKE_sge_trans( LAPACK_COL_MAJOR, 2*kl+ku+1, n, ab_i, ldab, ab_r, n+2 );
00214 info_i = LAPACKE_sgbcon( LAPACK_ROW_MAJOR, norm_i, n_i, kl_i, ku_i, ab_r,
00215 ldab_r, ipiv_i, anorm_i, &rcond_i );
00216
00217 failed = compare_sgbcon( rcond, rcond_i, info, info_i );
00218 if( failed == 0 ) {
00219 printf( "PASSED: row-major high-level interface to sgbcon\n" );
00220 } else {
00221 printf( "FAILED: row-major high-level interface to sgbcon\n" );
00222 }
00223
00224
00225 if( ab != NULL ) {
00226 LAPACKE_free( ab );
00227 }
00228 if( ab_i != NULL ) {
00229 LAPACKE_free( ab_i );
00230 }
00231 if( ab_r != NULL ) {
00232 LAPACKE_free( ab_r );
00233 }
00234 if( ipiv != NULL ) {
00235 LAPACKE_free( ipiv );
00236 }
00237 if( ipiv_i != NULL ) {
00238 LAPACKE_free( ipiv_i );
00239 }
00240 if( work != NULL ) {
00241 LAPACKE_free( work );
00242 }
00243 if( work_i != NULL ) {
00244 LAPACKE_free( work_i );
00245 }
00246 if( iwork != NULL ) {
00247 LAPACKE_free( iwork );
00248 }
00249 if( iwork_i != NULL ) {
00250 LAPACKE_free( iwork_i );
00251 }
00252
00253 return 0;
00254 }
00255
00256
00257 static void init_scalars_sgbcon( char *norm, lapack_int *n, lapack_int *kl,
00258 lapack_int *ku, lapack_int *ldab,
00259 float *anorm )
00260 {
00261 *norm = '1';
00262 *n = 4;
00263 *kl = 1;
00264 *ku = 2;
00265 *ldab = 25;
00266 *anorm = 1.363000107e+001;
00267
00268 return;
00269 }
00270
00271
00272 static void init_ab( lapack_int size, float *ab ) {
00273 lapack_int i;
00274 for( i = 0; i < size; i++ ) {
00275 ab[i] = 0;
00276 }
00277 ab[0] = 0.000000000e+000;
00278 ab[25] = 0.000000000e+000;
00279 ab[50] = 0.000000000e+000;
00280 ab[75] = -2.130000114e+000;
00281 ab[1] = 0.000000000e+000;
00282 ab[26] = 0.000000000e+000;
00283 ab[51] = -2.730000019e+000;
00284 ab[76] = 4.070000172e+000;
00285 ab[2] = 0.000000000e+000;
00286 ab[27] = 2.460000038e+000;
00287 ab[52] = 2.460000038e+000;
00288 ab[77] = -3.839143991e+000;
00289 ab[3] = -6.980000019e+000;
00290 ab[28] = 2.559999943e+000;
00291 ab[53] = -5.932930470e+000;
00292 ab[78] = -7.269061804e-001;
00293 ab[4] = 3.295128793e-002;
00294 ab[29] = 9.605233669e-001;
00295 ab[54] = 8.056727648e-001;
00296 ab[79] = 0.000000000e+000;
00297 }
00298 static void init_ipiv( lapack_int size, lapack_int *ipiv ) {
00299 lapack_int i;
00300 for( i = 0; i < size; i++ ) {
00301 ipiv[i] = 0;
00302 }
00303 ipiv[0] = 2;
00304 ipiv[1] = 3;
00305 ipiv[2] = 3;
00306 ipiv[3] = 4;
00307 }
00308 static void init_work( lapack_int size, float *work ) {
00309 lapack_int i;
00310 for( i = 0; i < size; i++ ) {
00311 work[i] = 0;
00312 }
00313 }
00314 static void init_iwork( lapack_int size, lapack_int *iwork ) {
00315 lapack_int i;
00316 for( i = 0; i < size; i++ ) {
00317 iwork[i] = 0;
00318 }
00319 }
00320
00321
00322
00323 static int compare_sgbcon( float rcond, float rcond_i, lapack_int info,
00324 lapack_int info_i )
00325 {
00326 int failed = 0;
00327 failed += compare_floats(rcond,rcond_i);
00328 failed += (info == info_i) ? 0 : 1;
00329 if( info != 0 || info_i != 0 ) {
00330 printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00331 }
00332
00333 return failed;
00334 }