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_sppcon( char *uplo, lapack_int *n, float *anorm );
00055 static void init_ap( lapack_int size, float *ap );
00056 static void init_work( lapack_int size, float *work );
00057 static void init_iwork( lapack_int size, lapack_int *iwork );
00058 static int compare_sppcon( float rcond, float 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 float anorm, anorm_i;
00067 float rcond, rcond_i;
00068 lapack_int info, info_i;
00069 lapack_int i;
00070 int failed;
00071
00072
00073 float *ap = NULL, *ap_i = NULL;
00074 float *work = NULL, *work_i = NULL;
00075 lapack_int *iwork = NULL, *iwork_i = NULL;
00076 float *ap_r = NULL;
00077
00078
00079 init_scalars_sppcon( &uplo, &n, &anorm );
00080 uplo_i = uplo;
00081 n_i = n;
00082 anorm_i = anorm;
00083
00084
00085 ap = (float *)LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(float) );
00086 work = (float *)LAPACKE_malloc( 3*n * sizeof(float) );
00087 iwork = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
00088
00089
00090 ap_i = (float *)LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(float) );
00091 work_i = (float *)LAPACKE_malloc( 3*n * sizeof(float) );
00092 iwork_i = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
00093
00094
00095 ap_r = (float *)LAPACKE_malloc( n*(n+1)/2 * sizeof(float) );
00096
00097
00098 init_ap( (n*(n+1)/2), ap );
00099 init_work( 3*n, work );
00100 init_iwork( n, iwork );
00101
00102
00103 sppcon_( &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_sppcon_work( LAPACK_COL_MAJOR, uplo_i, n_i, ap_i, anorm_i,
00117 &rcond_i, work_i, iwork_i );
00118
00119 failed = compare_sppcon( rcond, rcond_i, info, info_i );
00120 if( failed == 0 ) {
00121 printf( "PASSED: column-major middle-level interface to sppcon\n" );
00122 } else {
00123 printf( "FAILED: column-major middle-level interface to sppcon\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_sppcon( LAPACK_COL_MAJOR, uplo_i, n_i, ap_i, anorm_i,
00138 &rcond_i );
00139
00140 failed = compare_sppcon( rcond, rcond_i, info, info_i );
00141 if( failed == 0 ) {
00142 printf( "PASSED: column-major high-level interface to sppcon\n" );
00143 } else {
00144 printf( "FAILED: column-major high-level interface to sppcon\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_spp_trans( LAPACK_COL_MAJOR, uplo, n, ap_i, ap_r );
00160 info_i = LAPACKE_sppcon_work( LAPACK_ROW_MAJOR, uplo_i, n_i, ap_r, anorm_i,
00161 &rcond_i, work_i, iwork_i );
00162
00163 failed = compare_sppcon( rcond, rcond_i, info, info_i );
00164 if( failed == 0 ) {
00165 printf( "PASSED: row-major middle-level interface to sppcon\n" );
00166 } else {
00167 printf( "FAILED: row-major middle-level interface to sppcon\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_spp_trans( LAPACK_COL_MAJOR, uplo, n, ap_i, ap_r );
00184 info_i = LAPACKE_sppcon( LAPACK_ROW_MAJOR, uplo_i, n_i, ap_r, anorm_i,
00185 &rcond_i );
00186
00187 failed = compare_sppcon( rcond, rcond_i, info, info_i );
00188 if( failed == 0 ) {
00189 printf( "PASSED: row-major high-level interface to sppcon\n" );
00190 } else {
00191 printf( "FAILED: row-major high-level interface to sppcon\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_sppcon( char *uplo, lapack_int *n, float *anorm )
00222 {
00223 *uplo = 'L';
00224 *n = 4;
00225 *anorm = 1.015999985e+001;
00226
00227 return;
00228 }
00229
00230
00231 static void init_ap( lapack_int size, float *ap ) {
00232 lapack_int i;
00233 for( i = 0; i < size; i++ ) {
00234 ap[i] = 0;
00235 }
00236 ap[0] = 2.039607763e+000;
00237 ap[1] = -1.529705763e+000;
00238 ap[2] = 2.745625973e-001;
00239 ap[3] = -4.902903363e-002;
00240 ap[4] = 1.640122056e+000;
00241 ap[5] = -2.499813884e-001;
00242 ap[6] = 6.737302542e-001;
00243 ap[7] = 7.887488008e-001;
00244 ap[8] = 6.616575122e-001;
00245 ap[9] = 5.346895456e-001;
00246 }
00247 static void init_work( lapack_int size, float *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_sppcon( float rcond, float rcond_i, lapack_int info,
00263 lapack_int info_i )
00264 {
00265 int failed = 0;
00266 failed += compare_floats(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 }