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_dstebz( char *range, char *order, lapack_int *n,
00055 double *vl, double *vu, lapack_int *il,
00056 lapack_int *iu, double *abstol );
00057 static void init_d( lapack_int size, double *d );
00058 static void init_e( lapack_int size, double *e );
00059 static void init_w( lapack_int size, double *w );
00060 static void init_iblock( lapack_int size, lapack_int *iblock );
00061 static void init_isplit( lapack_int size, lapack_int *isplit );
00062 static void init_work( lapack_int size, double *work );
00063 static void init_iwork( lapack_int size, lapack_int *iwork );
00064 static int compare_dstebz( lapack_int m, lapack_int m_i, lapack_int nsplit,
00065 lapack_int nsplit_i, double *w, double *w_i,
00066 lapack_int *iblock, lapack_int *iblock_i,
00067 lapack_int *isplit, lapack_int *isplit_i,
00068 lapack_int info, lapack_int info_i, lapack_int n );
00069
00070 int main(void)
00071 {
00072
00073 char range, range_i;
00074 char order, order_i;
00075 lapack_int n, n_i;
00076 double vl, vl_i;
00077 double vu, vu_i;
00078 lapack_int il, il_i;
00079 lapack_int iu, iu_i;
00080 double abstol, abstol_i;
00081 lapack_int m, m_i;
00082 lapack_int nsplit, nsplit_i;
00083 lapack_int info, info_i;
00084 lapack_int i;
00085 int failed;
00086
00087
00088 double *d = NULL, *d_i = NULL;
00089 double *e = NULL, *e_i = NULL;
00090 double *w = NULL, *w_i = NULL;
00091 lapack_int *iblock = NULL, *iblock_i = NULL;
00092 lapack_int *isplit = NULL, *isplit_i = NULL;
00093 double *work = NULL, *work_i = NULL;
00094 lapack_int *iwork = NULL, *iwork_i = NULL;
00095 double *w_save = NULL;
00096 lapack_int *iblock_save = NULL;
00097 lapack_int *isplit_save = NULL;
00098
00099
00100 init_scalars_dstebz( &range, &order, &n, &vl, &vu, &il, &iu, &abstol );
00101 range_i = range;
00102 order_i = order;
00103 n_i = n;
00104 vl_i = vl;
00105 vu_i = vu;
00106 il_i = il;
00107 iu_i = iu;
00108 abstol_i = abstol;
00109
00110
00111 d = (double *)LAPACKE_malloc( n * sizeof(double) );
00112 e = (double *)LAPACKE_malloc( (n-1) * sizeof(double) );
00113 w = (double *)LAPACKE_malloc( n * sizeof(double) );
00114 iblock = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
00115 isplit = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
00116 work = (double *)LAPACKE_malloc( 4*n * sizeof(double) );
00117 iwork = (lapack_int *)LAPACKE_malloc( 3*n * sizeof(lapack_int) );
00118
00119
00120 d_i = (double *)LAPACKE_malloc( n * sizeof(double) );
00121 e_i = (double *)LAPACKE_malloc( (n-1) * sizeof(double) );
00122 w_i = (double *)LAPACKE_malloc( n * sizeof(double) );
00123 iblock_i = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
00124 isplit_i = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
00125 work_i = (double *)LAPACKE_malloc( 4*n * sizeof(double) );
00126 iwork_i = (lapack_int *)LAPACKE_malloc( 3*n * sizeof(lapack_int) );
00127
00128
00129 w_save = (double *)LAPACKE_malloc( n * sizeof(double) );
00130 iblock_save = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
00131 isplit_save = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
00132
00133
00134
00135
00136 init_d( n, d );
00137 init_e( (n-1), e );
00138 init_w( n, w );
00139 init_iblock( n, iblock );
00140 init_isplit( n, isplit );
00141 init_work( 4*n, work );
00142 init_iwork( 3*n, iwork );
00143
00144
00145 for( i = 0; i < n; i++ ) {
00146 w_save[i] = w[i];
00147 }
00148 for( i = 0; i < n; i++ ) {
00149 iblock_save[i] = iblock[i];
00150 }
00151 for( i = 0; i < n; i++ ) {
00152 isplit_save[i] = isplit[i];
00153 }
00154
00155
00156 dstebz_( &range, &order, &n, &vl, &vu, &il, &iu, &abstol, d, e, &m, &nsplit,
00157 w, iblock, isplit, work, iwork, &info );
00158
00159
00160
00161 for( i = 0; i < n; i++ ) {
00162 d_i[i] = d[i];
00163 }
00164 for( i = 0; i < (n-1); i++ ) {
00165 e_i[i] = e[i];
00166 }
00167 for( i = 0; i < n; i++ ) {
00168 w_i[i] = w_save[i];
00169 }
00170 for( i = 0; i < n; i++ ) {
00171 iblock_i[i] = iblock_save[i];
00172 }
00173 for( i = 0; i < n; i++ ) {
00174 isplit_i[i] = isplit_save[i];
00175 }
00176 for( i = 0; i < 4*n; i++ ) {
00177 work_i[i] = work[i];
00178 }
00179 for( i = 0; i < 3*n; i++ ) {
00180 iwork_i[i] = iwork[i];
00181 }
00182 info_i = LAPACKE_dstebz_work( range_i, order_i, n_i, vl_i, vu_i, il_i, iu_i,
00183 abstol_i, d_i, e_i, &m_i, &nsplit_i, w_i,
00184 iblock_i, isplit_i, work_i, iwork_i );
00185
00186 failed = compare_dstebz( m, m_i, nsplit, nsplit_i, w, w_i, iblock, iblock_i,
00187 isplit, isplit_i, info, info_i, n );
00188 if( failed == 0 ) {
00189 printf( "PASSED: column-major middle-level interface to dstebz\n" );
00190 } else {
00191 printf( "FAILED: column-major middle-level interface to dstebz\n" );
00192 }
00193
00194
00195
00196 for( i = 0; i < n; i++ ) {
00197 d_i[i] = d[i];
00198 }
00199 for( i = 0; i < (n-1); i++ ) {
00200 e_i[i] = e[i];
00201 }
00202 for( i = 0; i < n; i++ ) {
00203 w_i[i] = w_save[i];
00204 }
00205 for( i = 0; i < n; i++ ) {
00206 iblock_i[i] = iblock_save[i];
00207 }
00208 for( i = 0; i < n; i++ ) {
00209 isplit_i[i] = isplit_save[i];
00210 }
00211 for( i = 0; i < 4*n; i++ ) {
00212 work_i[i] = work[i];
00213 }
00214 for( i = 0; i < 3*n; i++ ) {
00215 iwork_i[i] = iwork[i];
00216 }
00217 info_i = LAPACKE_dstebz( range_i, order_i, n_i, vl_i, vu_i, il_i, iu_i,
00218 abstol_i, d_i, e_i, &m_i, &nsplit_i, w_i, iblock_i,
00219 isplit_i );
00220
00221 failed = compare_dstebz( m, m_i, nsplit, nsplit_i, w, w_i, iblock, iblock_i,
00222 isplit, isplit_i, info, info_i, n );
00223 if( failed == 0 ) {
00224 printf( "PASSED: column-major high-level interface to dstebz\n" );
00225 } else {
00226 printf( "FAILED: column-major high-level interface to dstebz\n" );
00227 }
00228
00229 failed = compare_dstebz( m, m_i, nsplit, nsplit_i, w, w_i, iblock, iblock_i,
00230 isplit, isplit_i, info, info_i, n );
00231 if( failed == 0 ) {
00232 printf( "PASSED: row-major middle-level interface to dstebz\n" );
00233 } else {
00234 printf( "FAILED: row-major middle-level interface to dstebz\n" );
00235 }
00236
00237 failed = compare_dstebz( m, m_i, nsplit, nsplit_i, w, w_i, iblock, iblock_i,
00238 isplit, isplit_i, info, info_i, n );
00239 if( failed == 0 ) {
00240 printf( "PASSED: row-major high-level interface to dstebz\n" );
00241 } else {
00242 printf( "FAILED: row-major high-level interface to dstebz\n" );
00243 }
00244
00245
00246 if( d != NULL ) {
00247 LAPACKE_free( d );
00248 }
00249 if( d_i != NULL ) {
00250 LAPACKE_free( d_i );
00251 }
00252 if( e != NULL ) {
00253 LAPACKE_free( e );
00254 }
00255 if( e_i != NULL ) {
00256 LAPACKE_free( e_i );
00257 }
00258 if( w != NULL ) {
00259 LAPACKE_free( w );
00260 }
00261 if( w_i != NULL ) {
00262 LAPACKE_free( w_i );
00263 }
00264 if( w_save != NULL ) {
00265 LAPACKE_free( w_save );
00266 }
00267 if( iblock != NULL ) {
00268 LAPACKE_free( iblock );
00269 }
00270 if( iblock_i != NULL ) {
00271 LAPACKE_free( iblock_i );
00272 }
00273 if( iblock_save != NULL ) {
00274 LAPACKE_free( iblock_save );
00275 }
00276 if( isplit != NULL ) {
00277 LAPACKE_free( isplit );
00278 }
00279 if( isplit_i != NULL ) {
00280 LAPACKE_free( isplit_i );
00281 }
00282 if( isplit_save != NULL ) {
00283 LAPACKE_free( isplit_save );
00284 }
00285 if( work != NULL ) {
00286 LAPACKE_free( work );
00287 }
00288 if( work_i != NULL ) {
00289 LAPACKE_free( work_i );
00290 }
00291 if( iwork != NULL ) {
00292 LAPACKE_free( iwork );
00293 }
00294 if( iwork_i != NULL ) {
00295 LAPACKE_free( iwork_i );
00296 }
00297
00298 return 0;
00299 }
00300
00301
00302 static void init_scalars_dstebz( char *range, char *order, lapack_int *n,
00303 double *vl, double *vu, lapack_int *il,
00304 lapack_int *iu, double *abstol )
00305 {
00306 *range = 'I';
00307 *order = 'B';
00308 *n = 4;
00309 *vl = 0.00000000000000000e+000;
00310 *vu = 0.00000000000000000e+000;
00311 *il = 1;
00312 *iu = 2;
00313 *abstol = 0.00000000000000000e+000;
00314
00315 return;
00316 }
00317
00318
00319 static void init_d( lapack_int size, double *d ) {
00320 lapack_int i;
00321 for( i = 0; i < size; i++ ) {
00322 d[i] = 0;
00323 }
00324 d[0] = 2.06999999999999980e+000;
00325 d[1] = 1.47409370819755310e+000;
00326 d[2] = -6.49159507545784330e-001;
00327 d[3] = -1.69493420065176800e+000;
00328 }
00329 static void init_e( lapack_int size, double *e ) {
00330 lapack_int i;
00331 for( i = 0; i < size; i++ ) {
00332 e[i] = 0;
00333 }
00334 e[0] = -5.82575317019181590e+000;
00335 e[1] = 2.62404517879558740e+000;
00336 e[2] = 9.16272756321918620e-001;
00337 }
00338 static void init_w( lapack_int size, double *w ) {
00339 lapack_int i;
00340 for( i = 0; i < size; i++ ) {
00341 w[i] = 0;
00342 }
00343 }
00344 static void init_iblock( lapack_int size, lapack_int *iblock ) {
00345 lapack_int i;
00346 for( i = 0; i < size; i++ ) {
00347 iblock[i] = 0;
00348 }
00349 }
00350 static void init_isplit( lapack_int size, lapack_int *isplit ) {
00351 lapack_int i;
00352 for( i = 0; i < size; i++ ) {
00353 isplit[i] = 0;
00354 }
00355 }
00356 static void init_work( lapack_int size, double *work ) {
00357 lapack_int i;
00358 for( i = 0; i < size; i++ ) {
00359 work[i] = 0;
00360 }
00361 }
00362 static void init_iwork( lapack_int size, lapack_int *iwork ) {
00363 lapack_int i;
00364 for( i = 0; i < size; i++ ) {
00365 iwork[i] = 0;
00366 }
00367 }
00368
00369
00370
00371 static int compare_dstebz( lapack_int m, lapack_int m_i, lapack_int nsplit,
00372 lapack_int nsplit_i, double *w, double *w_i,
00373 lapack_int *iblock, lapack_int *iblock_i,
00374 lapack_int *isplit, lapack_int *isplit_i,
00375 lapack_int info, lapack_int info_i, lapack_int n )
00376 {
00377 lapack_int i;
00378 int failed = 0;
00379 failed += (m == m_i) ? 0 : 1;
00380 failed += (nsplit == nsplit_i) ? 0 : 1;
00381 for( i = 0; i < n; i++ ) {
00382 failed += compare_doubles(w[i],w_i[i]);
00383 }
00384 for( i = 0; i < n; i++ ) {
00385 failed += (iblock[i] == iblock_i[i]) ? 0 : 1;
00386 }
00387 for( i = 0; i < n; i++ ) {
00388 failed += (isplit[i] == isplit_i[i]) ? 0 : 1;
00389 }
00390 failed += (info == info_i) ? 0 : 1;
00391 if( info != 0 || info_i != 0 ) {
00392 printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00393 }
00394
00395 return failed;
00396 }