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_dpbcon( char *uplo, lapack_int *n, lapack_int *kd,
00055 lapack_int *ldab, double *anorm );
00056 static void init_ab( lapack_int size, double *ab );
00057 static void init_work( lapack_int size, double *work );
00058 static void init_iwork( lapack_int size, lapack_int *iwork );
00059 static int compare_dpbcon( double rcond, double rcond_i, lapack_int info,
00060 lapack_int info_i );
00061
00062 int main(void)
00063 {
00064
00065 char uplo, uplo_i;
00066 lapack_int n, n_i;
00067 lapack_int kd, kd_i;
00068 lapack_int ldab, ldab_i;
00069 lapack_int ldab_r;
00070 double anorm, anorm_i;
00071 double rcond, rcond_i;
00072 lapack_int info, info_i;
00073 lapack_int i;
00074 int failed;
00075
00076
00077 double *ab = NULL, *ab_i = NULL;
00078 double *work = NULL, *work_i = NULL;
00079 lapack_int *iwork = NULL, *iwork_i = NULL;
00080 double *ab_r = NULL;
00081
00082
00083 init_scalars_dpbcon( &uplo, &n, &kd, &ldab, &anorm );
00084 ldab_r = n+2;
00085 uplo_i = uplo;
00086 n_i = n;
00087 kd_i = kd;
00088 ldab_i = ldab;
00089 anorm_i = anorm;
00090
00091
00092 ab = (double *)LAPACKE_malloc( ldab*n * sizeof(double) );
00093 work = (double *)LAPACKE_malloc( 3*n * sizeof(double) );
00094 iwork = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
00095
00096
00097 ab_i = (double *)LAPACKE_malloc( ldab*n * sizeof(double) );
00098 work_i = (double *)LAPACKE_malloc( 3*n * sizeof(double) );
00099 iwork_i = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
00100
00101
00102 ab_r = (double *)LAPACKE_malloc( (kd+1)*(n+2) * sizeof(double) );
00103
00104
00105 init_ab( ldab*n, ab );
00106 init_work( 3*n, work );
00107 init_iwork( n, iwork );
00108
00109
00110 dpbcon_( &uplo, &n, &kd, ab, &ldab, &anorm, &rcond, work, iwork, &info );
00111
00112
00113
00114 for( i = 0; i < ldab*n; i++ ) {
00115 ab_i[i] = ab[i];
00116 }
00117 for( i = 0; i < 3*n; i++ ) {
00118 work_i[i] = work[i];
00119 }
00120 for( i = 0; i < n; i++ ) {
00121 iwork_i[i] = iwork[i];
00122 }
00123 info_i = LAPACKE_dpbcon_work( LAPACK_COL_MAJOR, uplo_i, n_i, kd_i, ab_i,
00124 ldab_i, anorm_i, &rcond_i, work_i, iwork_i );
00125
00126 failed = compare_dpbcon( rcond, rcond_i, info, info_i );
00127 if( failed == 0 ) {
00128 printf( "PASSED: column-major middle-level interface to dpbcon\n" );
00129 } else {
00130 printf( "FAILED: column-major middle-level interface to dpbcon\n" );
00131 }
00132
00133
00134
00135 for( i = 0; i < ldab*n; i++ ) {
00136 ab_i[i] = ab[i];
00137 }
00138 for( i = 0; i < 3*n; i++ ) {
00139 work_i[i] = work[i];
00140 }
00141 for( i = 0; i < n; i++ ) {
00142 iwork_i[i] = iwork[i];
00143 }
00144 info_i = LAPACKE_dpbcon( LAPACK_COL_MAJOR, uplo_i, n_i, kd_i, ab_i, ldab_i,
00145 anorm_i, &rcond_i );
00146
00147 failed = compare_dpbcon( rcond, rcond_i, info, info_i );
00148 if( failed == 0 ) {
00149 printf( "PASSED: column-major high-level interface to dpbcon\n" );
00150 } else {
00151 printf( "FAILED: column-major high-level interface to dpbcon\n" );
00152 }
00153
00154
00155
00156 for( i = 0; i < ldab*n; i++ ) {
00157 ab_i[i] = ab[i];
00158 }
00159 for( i = 0; i < 3*n; i++ ) {
00160 work_i[i] = work[i];
00161 }
00162 for( i = 0; i < n; i++ ) {
00163 iwork_i[i] = iwork[i];
00164 }
00165
00166 LAPACKE_dge_trans( LAPACK_COL_MAJOR, kd+1, n, ab_i, ldab, ab_r, n+2 );
00167 info_i = LAPACKE_dpbcon_work( LAPACK_ROW_MAJOR, uplo_i, n_i, kd_i, ab_r,
00168 ldab_r, anorm_i, &rcond_i, work_i, iwork_i );
00169
00170 failed = compare_dpbcon( rcond, rcond_i, info, info_i );
00171 if( failed == 0 ) {
00172 printf( "PASSED: row-major middle-level interface to dpbcon\n" );
00173 } else {
00174 printf( "FAILED: row-major middle-level interface to dpbcon\n" );
00175 }
00176
00177
00178
00179 for( i = 0; i < ldab*n; i++ ) {
00180 ab_i[i] = ab[i];
00181 }
00182 for( i = 0; i < 3*n; i++ ) {
00183 work_i[i] = work[i];
00184 }
00185 for( i = 0; i < n; i++ ) {
00186 iwork_i[i] = iwork[i];
00187 }
00188
00189
00190 LAPACKE_dge_trans( LAPACK_COL_MAJOR, kd+1, n, ab_i, ldab, ab_r, n+2 );
00191 info_i = LAPACKE_dpbcon( LAPACK_ROW_MAJOR, uplo_i, n_i, kd_i, ab_r, ldab_r,
00192 anorm_i, &rcond_i );
00193
00194 failed = compare_dpbcon( rcond, rcond_i, info, info_i );
00195 if( failed == 0 ) {
00196 printf( "PASSED: row-major high-level interface to dpbcon\n" );
00197 } else {
00198 printf( "FAILED: row-major high-level interface to dpbcon\n" );
00199 }
00200
00201
00202 if( ab != NULL ) {
00203 LAPACKE_free( ab );
00204 }
00205 if( ab_i != NULL ) {
00206 LAPACKE_free( ab_i );
00207 }
00208 if( ab_r != NULL ) {
00209 LAPACKE_free( ab_r );
00210 }
00211 if( work != NULL ) {
00212 LAPACKE_free( work );
00213 }
00214 if( work_i != NULL ) {
00215 LAPACKE_free( work_i );
00216 }
00217 if( iwork != NULL ) {
00218 LAPACKE_free( iwork );
00219 }
00220 if( iwork_i != NULL ) {
00221 LAPACKE_free( iwork_i );
00222 }
00223
00224 return 0;
00225 }
00226
00227
00228 static void init_scalars_dpbcon( char *uplo, lapack_int *n, lapack_int *kd,
00229 lapack_int *ldab, double *anorm )
00230 {
00231 *uplo = 'L';
00232 *n = 4;
00233 *kd = 1;
00234 *ldab = 9;
00235 *anorm = 1.07000000000000010e+001;
00236
00237 return;
00238 }
00239
00240
00241 static void init_ab( lapack_int size, double *ab ) {
00242 lapack_int i;
00243 for( i = 0; i < size; i++ ) {
00244 ab[i] = 0;
00245 }
00246 ab[0] = 2.34307490277199640e+000;
00247 ab[9] = 2.07887720150650870e+000;
00248 ab[18] = 1.13061224833700420e+000;
00249 ab[27] = 1.14652471173422900e+000;
00250 ab[1] = 1.14379612740053750e+000;
00251 ab[10] = -1.14965905550747700e+000;
00252 ab[19] = -1.96353790016458380e+000;
00253 ab[28] = 0.00000000000000000e+000;
00254 }
00255 static void init_work( lapack_int size, double *work ) {
00256 lapack_int i;
00257 for( i = 0; i < size; i++ ) {
00258 work[i] = 0;
00259 }
00260 }
00261 static void init_iwork( lapack_int size, lapack_int *iwork ) {
00262 lapack_int i;
00263 for( i = 0; i < size; i++ ) {
00264 iwork[i] = 0;
00265 }
00266 }
00267
00268
00269
00270 static int compare_dpbcon( double rcond, double rcond_i, lapack_int info,
00271 lapack_int info_i )
00272 {
00273 int failed = 0;
00274 failed += compare_doubles(rcond,rcond_i);
00275 failed += (info == info_i) ? 0 : 1;
00276 if( info != 0 || info_i != 0 ) {
00277 printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00278 }
00279
00280 return failed;
00281 }