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