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_strcon( char *norm, char *uplo, char *diag,
00055 lapack_int *n, lapack_int *lda );
00056 static void init_a( lapack_int size, float *a );
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_strcon( 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 lapack_int lda, lda_i;
00070 lapack_int lda_r;
00071 float rcond, rcond_i;
00072 lapack_int info, info_i;
00073 lapack_int i;
00074 int failed;
00075
00076
00077 float *a = NULL, *a_i = NULL;
00078 float *work = NULL, *work_i = NULL;
00079 lapack_int *iwork = NULL, *iwork_i = NULL;
00080 float *a_r = NULL;
00081
00082
00083 init_scalars_strcon( &norm, &uplo, &diag, &n, &lda );
00084 lda_r = n+2;
00085 norm_i = norm;
00086 uplo_i = uplo;
00087 diag_i = diag;
00088 n_i = n;
00089 lda_i = lda;
00090
00091
00092 a = (float *)LAPACKE_malloc( lda*n * sizeof(float) );
00093 work = (float *)LAPACKE_malloc( 3*n * sizeof(float) );
00094 iwork = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
00095
00096
00097 a_i = (float *)LAPACKE_malloc( lda*n * sizeof(float) );
00098 work_i = (float *)LAPACKE_malloc( 3*n * sizeof(float) );
00099 iwork_i = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
00100
00101
00102 a_r = (float *)LAPACKE_malloc( n*(n+2) * sizeof(float) );
00103
00104
00105 init_a( lda*n, a );
00106 init_work( 3*n, work );
00107 init_iwork( n, iwork );
00108
00109
00110 strcon_( &norm, &uplo, &diag, &n, a, &lda, &rcond, work, iwork, &info );
00111
00112
00113
00114 for( i = 0; i < lda*n; i++ ) {
00115 a_i[i] = a[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_strcon_work( LAPACK_COL_MAJOR, norm_i, uplo_i, diag_i, n_i,
00124 a_i, lda_i, &rcond_i, work_i, iwork_i );
00125
00126 failed = compare_strcon( rcond, rcond_i, info, info_i );
00127 if( failed == 0 ) {
00128 printf( "PASSED: column-major middle-level interface to strcon\n" );
00129 } else {
00130 printf( "FAILED: column-major middle-level interface to strcon\n" );
00131 }
00132
00133
00134
00135 for( i = 0; i < lda*n; i++ ) {
00136 a_i[i] = a[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_strcon( LAPACK_COL_MAJOR, norm_i, uplo_i, diag_i, n_i, a_i,
00145 lda_i, &rcond_i );
00146
00147 failed = compare_strcon( rcond, rcond_i, info, info_i );
00148 if( failed == 0 ) {
00149 printf( "PASSED: column-major high-level interface to strcon\n" );
00150 } else {
00151 printf( "FAILED: column-major high-level interface to strcon\n" );
00152 }
00153
00154
00155
00156 for( i = 0; i < lda*n; i++ ) {
00157 a_i[i] = a[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_sge_trans( LAPACK_COL_MAJOR, n, n, a_i, lda, a_r, n+2 );
00167 info_i = LAPACKE_strcon_work( LAPACK_ROW_MAJOR, norm_i, uplo_i, diag_i, n_i,
00168 a_r, lda_r, &rcond_i, work_i, iwork_i );
00169
00170 failed = compare_strcon( rcond, rcond_i, info, info_i );
00171 if( failed == 0 ) {
00172 printf( "PASSED: row-major middle-level interface to strcon\n" );
00173 } else {
00174 printf( "FAILED: row-major middle-level interface to strcon\n" );
00175 }
00176
00177
00178
00179 for( i = 0; i < lda*n; i++ ) {
00180 a_i[i] = a[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_sge_trans( LAPACK_COL_MAJOR, n, n, a_i, lda, a_r, n+2 );
00191 info_i = LAPACKE_strcon( LAPACK_ROW_MAJOR, norm_i, uplo_i, diag_i, n_i, a_r,
00192 lda_r, &rcond_i );
00193
00194 failed = compare_strcon( rcond, rcond_i, info, info_i );
00195 if( failed == 0 ) {
00196 printf( "PASSED: row-major high-level interface to strcon\n" );
00197 } else {
00198 printf( "FAILED: row-major high-level interface to strcon\n" );
00199 }
00200
00201
00202 if( a != NULL ) {
00203 LAPACKE_free( a );
00204 }
00205 if( a_i != NULL ) {
00206 LAPACKE_free( a_i );
00207 }
00208 if( a_r != NULL ) {
00209 LAPACKE_free( a_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_strcon( char *norm, char *uplo, char *diag,
00229 lapack_int *n, lapack_int *lda )
00230 {
00231 *norm = '1';
00232 *uplo = 'L';
00233 *diag = 'N';
00234 *n = 4;
00235 *lda = 8;
00236
00237 return;
00238 }
00239
00240
00241 static void init_a( lapack_int size, float *a ) {
00242 lapack_int i;
00243 for( i = 0; i < size; i++ ) {
00244 a[i] = 0;
00245 }
00246 a[0] = 4.300000191e+000;
00247 a[8] = 0.000000000e+000;
00248 a[16] = 0.000000000e+000;
00249 a[24] = 0.000000000e+000;
00250 a[1] = -3.960000038e+000;
00251 a[9] = -4.869999886e+000;
00252 a[17] = 0.000000000e+000;
00253 a[25] = 0.000000000e+000;
00254 a[2] = 4.000000060e-001;
00255 a[10] = 3.100000024e-001;
00256 a[18] = -8.020000458e+000;
00257 a[26] = 0.000000000e+000;
00258 a[3] = -2.700000107e-001;
00259 a[11] = 7.000000030e-002;
00260 a[19] = -5.949999809e+000;
00261 a[27] = 1.199999973e-001;
00262 }
00263 static void init_work( lapack_int size, float *work ) {
00264 lapack_int i;
00265 for( i = 0; i < size; i++ ) {
00266 work[i] = 0;
00267 }
00268 }
00269 static void init_iwork( lapack_int size, lapack_int *iwork ) {
00270 lapack_int i;
00271 for( i = 0; i < size; i++ ) {
00272 iwork[i] = 0;
00273 }
00274 }
00275
00276
00277
00278 static int compare_strcon( float rcond, float rcond_i, lapack_int info,
00279 lapack_int info_i )
00280 {
00281 int failed = 0;
00282 failed += compare_floats(rcond,rcond_i);
00283 failed += (info == info_i) ? 0 : 1;
00284 if( info != 0 || info_i != 0 ) {
00285 printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00286 }
00287
00288 return failed;
00289 }