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_cgbcon( 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, lapack_complex_float *ab );
00058 static void init_ipiv( lapack_int size, lapack_int *ipiv );
00059 static void init_work( lapack_int size, lapack_complex_float *work );
00060 static void init_rwork( lapack_int size, float *rwork );
00061 static int compare_cgbcon( 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 lapack_complex_float *ab = NULL, *ab_i = NULL;
00081 lapack_int *ipiv = NULL, *ipiv_i = NULL;
00082 lapack_complex_float *work = NULL, *work_i = NULL;
00083 float *rwork = NULL, *rwork_i = NULL;
00084 lapack_complex_float *ab_r = NULL;
00085
00086
00087 init_scalars_cgbcon( &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 = (lapack_complex_float *)
00098 LAPACKE_malloc( ldab*n * sizeof(lapack_complex_float) );
00099 ipiv = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
00100 work = (lapack_complex_float *)
00101 LAPACKE_malloc( 2*n * sizeof(lapack_complex_float) );
00102 rwork = (float *)LAPACKE_malloc( n * sizeof(float) );
00103
00104
00105 ab_i = (lapack_complex_float *)
00106 LAPACKE_malloc( ldab*n * sizeof(lapack_complex_float) );
00107 ipiv_i = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
00108 work_i = (lapack_complex_float *)
00109 LAPACKE_malloc( 2*n * sizeof(lapack_complex_float) );
00110 rwork_i = (float *)LAPACKE_malloc( n * sizeof(float) );
00111
00112
00113 ab_r = (lapack_complex_float *)
00114 LAPACKE_malloc( ((2*kl+ku+1)*(n+2)) * sizeof(lapack_complex_float) );
00115
00116
00117 init_ab( ldab*n, ab );
00118 init_ipiv( n, ipiv );
00119 init_work( 2*n, work );
00120 init_rwork( n, rwork );
00121
00122
00123 cgbcon_( &norm, &n, &kl, &ku, ab, &ldab, ipiv, &anorm, &rcond, work, rwork,
00124 &info );
00125
00126
00127
00128 for( i = 0; i < ldab*n; i++ ) {
00129 ab_i[i] = ab[i];
00130 }
00131 for( i = 0; i < n; i++ ) {
00132 ipiv_i[i] = ipiv[i];
00133 }
00134 for( i = 0; i < 2*n; i++ ) {
00135 work_i[i] = work[i];
00136 }
00137 for( i = 0; i < n; i++ ) {
00138 rwork_i[i] = rwork[i];
00139 }
00140 info_i = LAPACKE_cgbcon_work( LAPACK_COL_MAJOR, norm_i, n_i, kl_i, ku_i,
00141 ab_i, ldab_i, ipiv_i, anorm_i, &rcond_i,
00142 work_i, rwork_i );
00143
00144 failed = compare_cgbcon( rcond, rcond_i, info, info_i );
00145 if( failed == 0 ) {
00146 printf( "PASSED: column-major middle-level interface to cgbcon\n" );
00147 } else {
00148 printf( "FAILED: column-major middle-level interface to cgbcon\n" );
00149 }
00150
00151
00152
00153 for( i = 0; i < ldab*n; i++ ) {
00154 ab_i[i] = ab[i];
00155 }
00156 for( i = 0; i < n; i++ ) {
00157 ipiv_i[i] = ipiv[i];
00158 }
00159 for( i = 0; i < 2*n; i++ ) {
00160 work_i[i] = work[i];
00161 }
00162 for( i = 0; i < n; i++ ) {
00163 rwork_i[i] = rwork[i];
00164 }
00165 info_i = LAPACKE_cgbcon( LAPACK_COL_MAJOR, norm_i, n_i, kl_i, ku_i, ab_i,
00166 ldab_i, ipiv_i, anorm_i, &rcond_i );
00167
00168 failed = compare_cgbcon( rcond, rcond_i, info, info_i );
00169 if( failed == 0 ) {
00170 printf( "PASSED: column-major high-level interface to cgbcon\n" );
00171 } else {
00172 printf( "FAILED: column-major high-level interface to cgbcon\n" );
00173 }
00174
00175
00176
00177 for( i = 0; i < ldab*n; i++ ) {
00178 ab_i[i] = ab[i];
00179 }
00180 for( i = 0; i < n; i++ ) {
00181 ipiv_i[i] = ipiv[i];
00182 }
00183 for( i = 0; i < 2*n; i++ ) {
00184 work_i[i] = work[i];
00185 }
00186 for( i = 0; i < n; i++ ) {
00187 rwork_i[i] = rwork[i];
00188 }
00189
00190 LAPACKE_cge_trans( LAPACK_COL_MAJOR, 2*kl+ku+1, n, ab_i, ldab, ab_r, n+2 );
00191 info_i = LAPACKE_cgbcon_work( LAPACK_ROW_MAJOR, norm_i, n_i, kl_i, ku_i,
00192 ab_r, ldab_r, ipiv_i, anorm_i, &rcond_i,
00193 work_i, rwork_i );
00194
00195 failed = compare_cgbcon( rcond, rcond_i, info, info_i );
00196 if( failed == 0 ) {
00197 printf( "PASSED: row-major middle-level interface to cgbcon\n" );
00198 } else {
00199 printf( "FAILED: row-major middle-level interface to cgbcon\n" );
00200 }
00201
00202
00203
00204 for( i = 0; i < ldab*n; i++ ) {
00205 ab_i[i] = ab[i];
00206 }
00207 for( i = 0; i < n; i++ ) {
00208 ipiv_i[i] = ipiv[i];
00209 }
00210 for( i = 0; i < 2*n; i++ ) {
00211 work_i[i] = work[i];
00212 }
00213 for( i = 0; i < n; i++ ) {
00214 rwork_i[i] = rwork[i];
00215 }
00216
00217
00218 LAPACKE_cge_trans( LAPACK_COL_MAJOR, 2*kl+ku+1, n, ab_i, ldab, ab_r, n+2 );
00219 info_i = LAPACKE_cgbcon( LAPACK_ROW_MAJOR, norm_i, n_i, kl_i, ku_i, ab_r,
00220 ldab_r, ipiv_i, anorm_i, &rcond_i );
00221
00222 failed = compare_cgbcon( rcond, rcond_i, info, info_i );
00223 if( failed == 0 ) {
00224 printf( "PASSED: row-major high-level interface to cgbcon\n" );
00225 } else {
00226 printf( "FAILED: row-major high-level interface to cgbcon\n" );
00227 }
00228
00229
00230 if( ab != NULL ) {
00231 LAPACKE_free( ab );
00232 }
00233 if( ab_i != NULL ) {
00234 LAPACKE_free( ab_i );
00235 }
00236 if( ab_r != NULL ) {
00237 LAPACKE_free( ab_r );
00238 }
00239 if( ipiv != NULL ) {
00240 LAPACKE_free( ipiv );
00241 }
00242 if( ipiv_i != NULL ) {
00243 LAPACKE_free( ipiv_i );
00244 }
00245 if( work != NULL ) {
00246 LAPACKE_free( work );
00247 }
00248 if( work_i != NULL ) {
00249 LAPACKE_free( work_i );
00250 }
00251 if( rwork != NULL ) {
00252 LAPACKE_free( rwork );
00253 }
00254 if( rwork_i != NULL ) {
00255 LAPACKE_free( rwork_i );
00256 }
00257
00258 return 0;
00259 }
00260
00261
00262 static void init_scalars_cgbcon( char *norm, lapack_int *n, lapack_int *kl,
00263 lapack_int *ku, lapack_int *ldab,
00264 float *anorm )
00265 {
00266 *norm = '1';
00267 *n = 4;
00268 *kl = 1;
00269 *ku = 2;
00270 *ldab = 25;
00271 *anorm = 1.547935009e+001;
00272
00273 return;
00274 }
00275
00276
00277 static void init_ab( lapack_int size, lapack_complex_float *ab ) {
00278 lapack_int i;
00279 for( i = 0; i < size; i++ ) {
00280 ab[i] = lapack_make_complex_float( 0.0f, 0.0f );
00281 }
00282 ab[0] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00283 ab[25] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00284 ab[50] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00285 ab[75] = lapack_make_complex_float( 5.899999738e-001, -4.799999893e-001 );
00286 ab[1] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00287 ab[26] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00288 ab[51] = lapack_make_complex_float( -3.990000010e+000, 4.010000229e+000 );
00289 ab[76] = lapack_make_complex_float( 3.329999924e+000, -1.039999962e+000 );
00290 ab[2] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00291 ab[27] = lapack_make_complex_float( -1.480000019e+000, -1.750000000e+000 );
00292 ab[52] = lapack_make_complex_float( -1.059999943e+000, 1.940000057e+000 );
00293 ab[77] = lapack_make_complex_float( -1.769209266e+000, -1.858747363e+000 );
00294 ab[3] = lapack_make_complex_float( 0.000000000e+000, 6.300000191e+000 );
00295 ab[28] = lapack_make_complex_float( -7.699999809e-001, 2.829999924e+000 );
00296 ab[53] = lapack_make_complex_float( 4.930266857e+000, -3.008563757e+000 );
00297 ab[78] = lapack_make_complex_float( 4.337749183e-001, 1.232528687e-001 );
00298 ab[4] = lapack_make_complex_float( 3.587301373e-001, 2.619047463e-001 );
00299 ab[29] = lapack_make_complex_float( 2.314260751e-001, 6.357648969e-001 );
00300 ab[54] = lapack_make_complex_float( 7.604227066e-001, 2.429442555e-001 );
00301 ab[79] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00302 }
00303 static void init_ipiv( lapack_int size, lapack_int *ipiv ) {
00304 lapack_int i;
00305 for( i = 0; i < size; i++ ) {
00306 ipiv[i] = 0;
00307 }
00308 ipiv[0] = 2;
00309 ipiv[1] = 3;
00310 ipiv[2] = 3;
00311 ipiv[3] = 4;
00312 }
00313 static void init_work( lapack_int size, lapack_complex_float *work ) {
00314 lapack_int i;
00315 for( i = 0; i < size; i++ ) {
00316 work[i] = lapack_make_complex_float( 0.0f, 0.0f );
00317 }
00318 }
00319 static void init_rwork( lapack_int size, float *rwork ) {
00320 lapack_int i;
00321 for( i = 0; i < size; i++ ) {
00322 rwork[i] = 0;
00323 }
00324 }
00325
00326
00327
00328 static int compare_cgbcon( float rcond, float rcond_i, lapack_int info,
00329 lapack_int info_i )
00330 {
00331 int failed = 0;
00332 failed += compare_floats(rcond,rcond_i);
00333 failed += (info == info_i) ? 0 : 1;
00334 if( info != 0 || info_i != 0 ) {
00335 printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00336 }
00337
00338 return failed;
00339 }