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