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_zgbcon( char *norm, lapack_int *n, lapack_int *kl,
00055 lapack_int *ku, lapack_int *ldab,
00056 double *anorm );
00057 static void init_ab( lapack_int size, lapack_complex_double *ab );
00058 static void init_ipiv( lapack_int size, lapack_int *ipiv );
00059 static void init_work( lapack_int size, lapack_complex_double *work );
00060 static void init_rwork( lapack_int size, double *rwork );
00061 static int compare_zgbcon( double rcond, double 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 double anorm, anorm_i;
00074 double rcond, rcond_i;
00075 lapack_int info, info_i;
00076 lapack_int i;
00077 int failed;
00078
00079
00080 lapack_complex_double *ab = NULL, *ab_i = NULL;
00081 lapack_int *ipiv = NULL, *ipiv_i = NULL;
00082 lapack_complex_double *work = NULL, *work_i = NULL;
00083 double *rwork = NULL, *rwork_i = NULL;
00084 lapack_complex_double *ab_r = NULL;
00085
00086
00087 init_scalars_zgbcon( &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_double *)
00098 LAPACKE_malloc( ldab*n * sizeof(lapack_complex_double) );
00099 ipiv = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
00100 work = (lapack_complex_double *)
00101 LAPACKE_malloc( 2*n * sizeof(lapack_complex_double) );
00102 rwork = (double *)LAPACKE_malloc( n * sizeof(double) );
00103
00104
00105 ab_i = (lapack_complex_double *)
00106 LAPACKE_malloc( ldab*n * sizeof(lapack_complex_double) );
00107 ipiv_i = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
00108 work_i = (lapack_complex_double *)
00109 LAPACKE_malloc( 2*n * sizeof(lapack_complex_double) );
00110 rwork_i = (double *)LAPACKE_malloc( n * sizeof(double) );
00111
00112
00113 ab_r = (lapack_complex_double *)
00114 LAPACKE_malloc( ((2*kl+ku+1)*(n+2)) * sizeof(lapack_complex_double) );
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 zgbcon_( &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_zgbcon_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_zgbcon( rcond, rcond_i, info, info_i );
00145 if( failed == 0 ) {
00146 printf( "PASSED: column-major middle-level interface to zgbcon\n" );
00147 } else {
00148 printf( "FAILED: column-major middle-level interface to zgbcon\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_zgbcon( 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_zgbcon( rcond, rcond_i, info, info_i );
00169 if( failed == 0 ) {
00170 printf( "PASSED: column-major high-level interface to zgbcon\n" );
00171 } else {
00172 printf( "FAILED: column-major high-level interface to zgbcon\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_zge_trans( LAPACK_COL_MAJOR, 2*kl+ku+1, n, ab_i, ldab, ab_r, n+2 );
00191 info_i = LAPACKE_zgbcon_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_zgbcon( rcond, rcond_i, info, info_i );
00196 if( failed == 0 ) {
00197 printf( "PASSED: row-major middle-level interface to zgbcon\n" );
00198 } else {
00199 printf( "FAILED: row-major middle-level interface to zgbcon\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_zge_trans( LAPACK_COL_MAJOR, 2*kl+ku+1, n, ab_i, ldab, ab_r, n+2 );
00219 info_i = LAPACKE_zgbcon( 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_zgbcon( rcond, rcond_i, info, info_i );
00223 if( failed == 0 ) {
00224 printf( "PASSED: row-major high-level interface to zgbcon\n" );
00225 } else {
00226 printf( "FAILED: row-major high-level interface to zgbcon\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_zgbcon( char *norm, lapack_int *n, lapack_int *kl,
00263 lapack_int *ku, lapack_int *ldab,
00264 double *anorm )
00265 {
00266 *norm = '1';
00267 *n = 4;
00268 *kl = 1;
00269 *ku = 2;
00270 *ldab = 25;
00271 *anorm = 1.54793504020627920e+001;
00272
00273 return;
00274 }
00275
00276
00277 static void init_ab( lapack_int size, lapack_complex_double *ab ) {
00278 lapack_int i;
00279 for( i = 0; i < size; i++ ) {
00280 ab[i] = lapack_make_complex_double( 0.0, 0.0 );
00281 }
00282 ab[0] = lapack_make_complex_double( 0.00000000000000000e+000,
00283 0.00000000000000000e+000 );
00284 ab[25] = lapack_make_complex_double( 0.00000000000000000e+000,
00285 0.00000000000000000e+000 );
00286 ab[50] = lapack_make_complex_double( 0.00000000000000000e+000,
00287 0.00000000000000000e+000 );
00288 ab[75] = lapack_make_complex_double( 5.89999999999999970e-001,
00289 -4.79999999999999980e-001 );
00290 ab[1] = lapack_make_complex_double( 0.00000000000000000e+000,
00291 0.00000000000000000e+000 );
00292 ab[26] = lapack_make_complex_double( 0.00000000000000000e+000,
00293 0.00000000000000000e+000 );
00294 ab[51] = lapack_make_complex_double( -3.99000000000000020e+000,
00295 4.00999999999999980e+000 );
00296 ab[76] = lapack_make_complex_double( 3.33000000000000010e+000,
00297 -1.04000000000000000e+000 );
00298 ab[2] = lapack_make_complex_double( 0.00000000000000000e+000,
00299 0.00000000000000000e+000 );
00300 ab[27] = lapack_make_complex_double( -1.48000000000000000e+000,
00301 -1.75000000000000000e+000 );
00302 ab[52] = lapack_make_complex_double( -1.06000000000000010e+000,
00303 1.93999999999999990e+000 );
00304 ab[77] = lapack_make_complex_double( -1.76920938160968100e+000,
00305 -1.85874728194578730e+000 );
00306 ab[3] = lapack_make_complex_double( 0.00000000000000000e+000,
00307 6.29999999999999980e+000 );
00308 ab[28] = lapack_make_complex_double( -7.70000000000000020e-001,
00309 2.83000000000000010e+000 );
00310 ab[53] = lapack_make_complex_double( 4.93026694117547140e+000,
00311 -3.00856374062719210e+000 );
00312 ab[78] = lapack_make_complex_double( 4.33774926590159760e-001,
00313 1.23252818156083470e-001 );
00314 ab[4] = lapack_make_complex_double( 3.58730158730158680e-001,
00315 2.61904761904761860e-001 );
00316 ab[29] = lapack_make_complex_double( 2.31426072874374280e-001,
00317 6.35764884204745640e-001 );
00318 ab[54] = lapack_make_complex_double( 7.60422661963551130e-001,
00319 2.42944258926713260e-001 );
00320 ab[79] = lapack_make_complex_double( 0.00000000000000000e+000,
00321 0.00000000000000000e+000 );
00322 }
00323 static void init_ipiv( lapack_int size, lapack_int *ipiv ) {
00324 lapack_int i;
00325 for( i = 0; i < size; i++ ) {
00326 ipiv[i] = 0;
00327 }
00328 ipiv[0] = 2;
00329 ipiv[1] = 3;
00330 ipiv[2] = 3;
00331 ipiv[3] = 4;
00332 }
00333 static void init_work( lapack_int size, lapack_complex_double *work ) {
00334 lapack_int i;
00335 for( i = 0; i < size; i++ ) {
00336 work[i] = lapack_make_complex_double( 0.0, 0.0 );
00337 }
00338 }
00339 static void init_rwork( lapack_int size, double *rwork ) {
00340 lapack_int i;
00341 for( i = 0; i < size; i++ ) {
00342 rwork[i] = 0;
00343 }
00344 }
00345
00346
00347
00348 static int compare_zgbcon( double rcond, double rcond_i, lapack_int info,
00349 lapack_int info_i )
00350 {
00351 int failed = 0;
00352 failed += compare_doubles(rcond,rcond_i);
00353 failed += (info == info_i) ? 0 : 1;
00354 if( info != 0 || info_i != 0 ) {
00355 printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00356 }
00357
00358 return failed;
00359 }