spbrfs_1.c
Go to the documentation of this file.
00001 /*****************************************************************************
00002   Copyright (c) 2010, Intel Corp.
00003   All rights reserved.
00004 
00005   Redistribution and use in source and binary forms, with or without
00006   modification, are permitted provided that the following conditions are met:
00007 
00008     * Redistributions of source code must retain the above copyright notice,
00009       this list of conditions and the following disclaimer.
00010     * Redistributions in binary form must reproduce the above copyright
00011       notice, this list of conditions and the following disclaimer in the
00012       documentation and/or other materials provided with the distribution.
00013     * Neither the name of Intel Corporation nor the names of its contributors
00014       may be used to endorse or promote products derived from this software
00015       without specific prior written permission.
00016 
00017   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00018   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00021   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00022   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00023   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00024   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00025   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00026   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
00027   THE POSSIBILITY OF SUCH DAMAGE.
00028 *****************************************************************************/
00029 /*  Contents: test routine for C interface to LAPACK
00030 *   Author: Intel Corporation
00031 *   Created in March, 2010
00032 *
00033 * Purpose
00034 *
00035 * spbrfs_1 is the test program for the C interface to LAPACK
00036 * routine spbrfs
00037 * The program doesn't require an input, the input data is hardcoded in the
00038 * test program.
00039 * The program tests the C interface in the four combinations:
00040 *   1) column-major layout, middle-level interface
00041 *   2) column-major layout, high-level interface
00042 *   3) row-major layout, middle-level interface
00043 *   4) row-major layout, high-level interface
00044 * The output of the C interface function is compared to those obtained from
00045 * the corresponiding LAPACK routine with the same input data, and the
00046 * comparison diagnostics is then printed on the standard output having PASSED
00047 * keyword if the test is passed, and FAILED keyword if the test isn't passed.
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_spbrfs( char *uplo, lapack_int *n, lapack_int *kd,
00055                                  lapack_int *nrhs, lapack_int *ldab,
00056                                  lapack_int *ldafb, lapack_int *ldb,
00057                                  lapack_int *ldx );
00058 static void init_ab( lapack_int size, float *ab );
00059 static void init_afb( lapack_int size, float *afb );
00060 static void init_b( lapack_int size, float *b );
00061 static void init_x( lapack_int size, float *x );
00062 static void init_ferr( lapack_int size, float *ferr );
00063 static void init_berr( lapack_int size, float *berr );
00064 static void init_work( lapack_int size, float *work );
00065 static void init_iwork( lapack_int size, lapack_int *iwork );
00066 static int compare_spbrfs( float *x, float *x_i, float *ferr, float *ferr_i,
00067                            float *berr, float *berr_i, lapack_int info,
00068                            lapack_int info_i, lapack_int ldx, lapack_int nrhs );
00069 
00070 int main(void)
00071 {
00072     /* Local scalars */
00073     char uplo, uplo_i;
00074     lapack_int n, n_i;
00075     lapack_int kd, kd_i;
00076     lapack_int nrhs, nrhs_i;
00077     lapack_int ldab, ldab_i;
00078     lapack_int ldab_r;
00079     lapack_int ldafb, ldafb_i;
00080     lapack_int ldafb_r;
00081     lapack_int ldb, ldb_i;
00082     lapack_int ldb_r;
00083     lapack_int ldx, ldx_i;
00084     lapack_int ldx_r;
00085     lapack_int info, info_i;
00086     lapack_int i;
00087     int failed;
00088 
00089     /* Local arrays */
00090     float *ab = NULL, *ab_i = NULL;
00091     float *afb = NULL, *afb_i = NULL;
00092     float *b = NULL, *b_i = NULL;
00093     float *x = NULL, *x_i = NULL;
00094     float *ferr = NULL, *ferr_i = NULL;
00095     float *berr = NULL, *berr_i = NULL;
00096     float *work = NULL, *work_i = NULL;
00097     lapack_int *iwork = NULL, *iwork_i = NULL;
00098     float *x_save = NULL;
00099     float *ferr_save = NULL;
00100     float *berr_save = NULL;
00101     float *ab_r = NULL;
00102     float *afb_r = NULL;
00103     float *b_r = NULL;
00104     float *x_r = NULL;
00105 
00106     /* Iniitialize the scalar parameters */
00107     init_scalars_spbrfs( &uplo, &n, &kd, &nrhs, &ldab, &ldafb, &ldb, &ldx );
00108     ldab_r = n+2;
00109     ldafb_r = n+2;
00110     ldb_r = nrhs+2;
00111     ldx_r = nrhs+2;
00112     uplo_i = uplo;
00113     n_i = n;
00114     kd_i = kd;
00115     nrhs_i = nrhs;
00116     ldab_i = ldab;
00117     ldafb_i = ldafb;
00118     ldb_i = ldb;
00119     ldx_i = ldx;
00120 
00121     /* Allocate memory for the LAPACK routine arrays */
00122     ab = (float *)LAPACKE_malloc( ldab*n * sizeof(float) );
00123     afb = (float *)LAPACKE_malloc( ldafb*n * sizeof(float) );
00124     b = (float *)LAPACKE_malloc( ldb*nrhs * sizeof(float) );
00125     x = (float *)LAPACKE_malloc( ldx*nrhs * sizeof(float) );
00126     ferr = (float *)LAPACKE_malloc( nrhs * sizeof(float) );
00127     berr = (float *)LAPACKE_malloc( nrhs * sizeof(float) );
00128     work = (float *)LAPACKE_malloc( 3*n * sizeof(float) );
00129     iwork = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
00130 
00131     /* Allocate memory for the C interface function arrays */
00132     ab_i = (float *)LAPACKE_malloc( ldab*n * sizeof(float) );
00133     afb_i = (float *)LAPACKE_malloc( ldafb*n * sizeof(float) );
00134     b_i = (float *)LAPACKE_malloc( ldb*nrhs * sizeof(float) );
00135     x_i = (float *)LAPACKE_malloc( ldx*nrhs * sizeof(float) );
00136     ferr_i = (float *)LAPACKE_malloc( nrhs * sizeof(float) );
00137     berr_i = (float *)LAPACKE_malloc( nrhs * sizeof(float) );
00138     work_i = (float *)LAPACKE_malloc( 3*n * sizeof(float) );
00139     iwork_i = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
00140 
00141     /* Allocate memory for the backup arrays */
00142     x_save = (float *)LAPACKE_malloc( ldx*nrhs * sizeof(float) );
00143     ferr_save = (float *)LAPACKE_malloc( nrhs * sizeof(float) );
00144     berr_save = (float *)LAPACKE_malloc( nrhs * sizeof(float) );
00145 
00146     /* Allocate memory for the row-major arrays */
00147     ab_r = (float *)LAPACKE_malloc( (kd+1)*(n+2) * sizeof(float) );
00148     afb_r = (float *)LAPACKE_malloc( (kd+1)*(n+2) * sizeof(float) );
00149     b_r = (float *)LAPACKE_malloc( n*(nrhs+2) * sizeof(float) );
00150     x_r = (float *)LAPACKE_malloc( n*(nrhs+2) * sizeof(float) );
00151 
00152     /* Initialize input arrays */
00153     init_ab( ldab*n, ab );
00154     init_afb( ldafb*n, afb );
00155     init_b( ldb*nrhs, b );
00156     init_x( ldx*nrhs, x );
00157     init_ferr( nrhs, ferr );
00158     init_berr( nrhs, berr );
00159     init_work( 3*n, work );
00160     init_iwork( n, iwork );
00161 
00162     /* Backup the ouptut arrays */
00163     for( i = 0; i < ldx*nrhs; i++ ) {
00164         x_save[i] = x[i];
00165     }
00166     for( i = 0; i < nrhs; i++ ) {
00167         ferr_save[i] = ferr[i];
00168     }
00169     for( i = 0; i < nrhs; i++ ) {
00170         berr_save[i] = berr[i];
00171     }
00172 
00173     /* Call the LAPACK routine */
00174     spbrfs_( &uplo, &n, &kd, &nrhs, ab, &ldab, afb, &ldafb, b, &ldb, x, &ldx,
00175              ferr, berr, work, iwork, &info );
00176 
00177     /* Initialize input data, call the column-major middle-level
00178      * interface to LAPACK routine and check the results */
00179     for( i = 0; i < ldab*n; i++ ) {
00180         ab_i[i] = ab[i];
00181     }
00182     for( i = 0; i < ldafb*n; i++ ) {
00183         afb_i[i] = afb[i];
00184     }
00185     for( i = 0; i < ldb*nrhs; i++ ) {
00186         b_i[i] = b[i];
00187     }
00188     for( i = 0; i < ldx*nrhs; i++ ) {
00189         x_i[i] = x_save[i];
00190     }
00191     for( i = 0; i < nrhs; i++ ) {
00192         ferr_i[i] = ferr_save[i];
00193     }
00194     for( i = 0; i < nrhs; i++ ) {
00195         berr_i[i] = berr_save[i];
00196     }
00197     for( i = 0; i < 3*n; i++ ) {
00198         work_i[i] = work[i];
00199     }
00200     for( i = 0; i < n; i++ ) {
00201         iwork_i[i] = iwork[i];
00202     }
00203     info_i = LAPACKE_spbrfs_work( LAPACK_COL_MAJOR, uplo_i, n_i, kd_i, nrhs_i,
00204                                   ab_i, ldab_i, afb_i, ldafb_i, b_i, ldb_i, x_i,
00205                                   ldx_i, ferr_i, berr_i, work_i, iwork_i );
00206 
00207     failed = compare_spbrfs( x, x_i, ferr, ferr_i, berr, berr_i, info, info_i,
00208                              ldx, nrhs );
00209     if( failed == 0 ) {
00210         printf( "PASSED: column-major middle-level interface to spbrfs\n" );
00211     } else {
00212         printf( "FAILED: column-major middle-level interface to spbrfs\n" );
00213     }
00214 
00215     /* Initialize input data, call the column-major high-level
00216      * interface to LAPACK routine and check the results */
00217     for( i = 0; i < ldab*n; i++ ) {
00218         ab_i[i] = ab[i];
00219     }
00220     for( i = 0; i < ldafb*n; i++ ) {
00221         afb_i[i] = afb[i];
00222     }
00223     for( i = 0; i < ldb*nrhs; i++ ) {
00224         b_i[i] = b[i];
00225     }
00226     for( i = 0; i < ldx*nrhs; i++ ) {
00227         x_i[i] = x_save[i];
00228     }
00229     for( i = 0; i < nrhs; i++ ) {
00230         ferr_i[i] = ferr_save[i];
00231     }
00232     for( i = 0; i < nrhs; i++ ) {
00233         berr_i[i] = berr_save[i];
00234     }
00235     for( i = 0; i < 3*n; i++ ) {
00236         work_i[i] = work[i];
00237     }
00238     for( i = 0; i < n; i++ ) {
00239         iwork_i[i] = iwork[i];
00240     }
00241     info_i = LAPACKE_spbrfs( LAPACK_COL_MAJOR, uplo_i, n_i, kd_i, nrhs_i, ab_i,
00242                              ldab_i, afb_i, ldafb_i, b_i, ldb_i, x_i, ldx_i,
00243                              ferr_i, berr_i );
00244 
00245     failed = compare_spbrfs( x, x_i, ferr, ferr_i, berr, berr_i, info, info_i,
00246                              ldx, nrhs );
00247     if( failed == 0 ) {
00248         printf( "PASSED: column-major high-level interface to spbrfs\n" );
00249     } else {
00250         printf( "FAILED: column-major high-level interface to spbrfs\n" );
00251     }
00252 
00253     /* Initialize input data, call the row-major middle-level
00254      * interface to LAPACK routine and check the results */
00255     for( i = 0; i < ldab*n; i++ ) {
00256         ab_i[i] = ab[i];
00257     }
00258     for( i = 0; i < ldafb*n; i++ ) {
00259         afb_i[i] = afb[i];
00260     }
00261     for( i = 0; i < ldb*nrhs; i++ ) {
00262         b_i[i] = b[i];
00263     }
00264     for( i = 0; i < ldx*nrhs; i++ ) {
00265         x_i[i] = x_save[i];
00266     }
00267     for( i = 0; i < nrhs; i++ ) {
00268         ferr_i[i] = ferr_save[i];
00269     }
00270     for( i = 0; i < nrhs; i++ ) {
00271         berr_i[i] = berr_save[i];
00272     }
00273     for( i = 0; i < 3*n; i++ ) {
00274         work_i[i] = work[i];
00275     }
00276     for( i = 0; i < n; i++ ) {
00277         iwork_i[i] = iwork[i];
00278     }
00279 
00280     LAPACKE_sge_trans( LAPACK_COL_MAJOR, kd+1, n, ab_i, ldab, ab_r, n+2 );
00281     LAPACKE_sge_trans( LAPACK_COL_MAJOR, kd+1, n, afb_i, ldafb, afb_r, n+2 );
00282     LAPACKE_sge_trans( LAPACK_COL_MAJOR, n, nrhs, b_i, ldb, b_r, nrhs+2 );
00283     LAPACKE_sge_trans( LAPACK_COL_MAJOR, n, nrhs, x_i, ldx, x_r, nrhs+2 );
00284     info_i = LAPACKE_spbrfs_work( LAPACK_ROW_MAJOR, uplo_i, n_i, kd_i, nrhs_i,
00285                                   ab_r, ldab_r, afb_r, ldafb_r, b_r, ldb_r, x_r,
00286                                   ldx_r, ferr_i, berr_i, work_i, iwork_i );
00287 
00288     LAPACKE_sge_trans( LAPACK_ROW_MAJOR, n, nrhs, x_r, nrhs+2, x_i, ldx );
00289 
00290     failed = compare_spbrfs( x, x_i, ferr, ferr_i, berr, berr_i, info, info_i,
00291                              ldx, nrhs );
00292     if( failed == 0 ) {
00293         printf( "PASSED: row-major middle-level interface to spbrfs\n" );
00294     } else {
00295         printf( "FAILED: row-major middle-level interface to spbrfs\n" );
00296     }
00297 
00298     /* Initialize input data, call the row-major high-level
00299      * interface to LAPACK routine and check the results */
00300     for( i = 0; i < ldab*n; i++ ) {
00301         ab_i[i] = ab[i];
00302     }
00303     for( i = 0; i < ldafb*n; i++ ) {
00304         afb_i[i] = afb[i];
00305     }
00306     for( i = 0; i < ldb*nrhs; i++ ) {
00307         b_i[i] = b[i];
00308     }
00309     for( i = 0; i < ldx*nrhs; i++ ) {
00310         x_i[i] = x_save[i];
00311     }
00312     for( i = 0; i < nrhs; i++ ) {
00313         ferr_i[i] = ferr_save[i];
00314     }
00315     for( i = 0; i < nrhs; i++ ) {
00316         berr_i[i] = berr_save[i];
00317     }
00318     for( i = 0; i < 3*n; i++ ) {
00319         work_i[i] = work[i];
00320     }
00321     for( i = 0; i < n; i++ ) {
00322         iwork_i[i] = iwork[i];
00323     }
00324 
00325     /* Init row_major arrays */
00326     LAPACKE_sge_trans( LAPACK_COL_MAJOR, kd+1, n, ab_i, ldab, ab_r, n+2 );
00327     LAPACKE_sge_trans( LAPACK_COL_MAJOR, kd+1, n, afb_i, ldafb, afb_r, n+2 );
00328     LAPACKE_sge_trans( LAPACK_COL_MAJOR, n, nrhs, b_i, ldb, b_r, nrhs+2 );
00329     LAPACKE_sge_trans( LAPACK_COL_MAJOR, n, nrhs, x_i, ldx, x_r, nrhs+2 );
00330     info_i = LAPACKE_spbrfs( LAPACK_ROW_MAJOR, uplo_i, n_i, kd_i, nrhs_i, ab_r,
00331                              ldab_r, afb_r, ldafb_r, b_r, ldb_r, x_r, ldx_r,
00332                              ferr_i, berr_i );
00333 
00334     LAPACKE_sge_trans( LAPACK_ROW_MAJOR, n, nrhs, x_r, nrhs+2, x_i, ldx );
00335 
00336     failed = compare_spbrfs( x, x_i, ferr, ferr_i, berr, berr_i, info, info_i,
00337                              ldx, nrhs );
00338     if( failed == 0 ) {
00339         printf( "PASSED: row-major high-level interface to spbrfs\n" );
00340     } else {
00341         printf( "FAILED: row-major high-level interface to spbrfs\n" );
00342     }
00343 
00344     /* Release memory */
00345     if( ab != NULL ) {
00346         LAPACKE_free( ab );
00347     }
00348     if( ab_i != NULL ) {
00349         LAPACKE_free( ab_i );
00350     }
00351     if( ab_r != NULL ) {
00352         LAPACKE_free( ab_r );
00353     }
00354     if( afb != NULL ) {
00355         LAPACKE_free( afb );
00356     }
00357     if( afb_i != NULL ) {
00358         LAPACKE_free( afb_i );
00359     }
00360     if( afb_r != NULL ) {
00361         LAPACKE_free( afb_r );
00362     }
00363     if( b != NULL ) {
00364         LAPACKE_free( b );
00365     }
00366     if( b_i != NULL ) {
00367         LAPACKE_free( b_i );
00368     }
00369     if( b_r != NULL ) {
00370         LAPACKE_free( b_r );
00371     }
00372     if( x != NULL ) {
00373         LAPACKE_free( x );
00374     }
00375     if( x_i != NULL ) {
00376         LAPACKE_free( x_i );
00377     }
00378     if( x_r != NULL ) {
00379         LAPACKE_free( x_r );
00380     }
00381     if( x_save != NULL ) {
00382         LAPACKE_free( x_save );
00383     }
00384     if( ferr != NULL ) {
00385         LAPACKE_free( ferr );
00386     }
00387     if( ferr_i != NULL ) {
00388         LAPACKE_free( ferr_i );
00389     }
00390     if( ferr_save != NULL ) {
00391         LAPACKE_free( ferr_save );
00392     }
00393     if( berr != NULL ) {
00394         LAPACKE_free( berr );
00395     }
00396     if( berr_i != NULL ) {
00397         LAPACKE_free( berr_i );
00398     }
00399     if( berr_save != NULL ) {
00400         LAPACKE_free( berr_save );
00401     }
00402     if( work != NULL ) {
00403         LAPACKE_free( work );
00404     }
00405     if( work_i != NULL ) {
00406         LAPACKE_free( work_i );
00407     }
00408     if( iwork != NULL ) {
00409         LAPACKE_free( iwork );
00410     }
00411     if( iwork_i != NULL ) {
00412         LAPACKE_free( iwork_i );
00413     }
00414 
00415     return 0;
00416 }
00417 
00418 /* Auxiliary function: spbrfs scalar parameters initialization */
00419 static void init_scalars_spbrfs( char *uplo, lapack_int *n, lapack_int *kd,
00420                                  lapack_int *nrhs, lapack_int *ldab,
00421                                  lapack_int *ldafb, lapack_int *ldb,
00422                                  lapack_int *ldx )
00423 {
00424     *uplo = 'L';
00425     *n = 4;
00426     *kd = 1;
00427     *nrhs = 2;
00428     *ldab = 9;
00429     *ldafb = 9;
00430     *ldb = 8;
00431     *ldx = 8;
00432 
00433     return;
00434 }
00435 
00436 /* Auxiliary functions: spbrfs array parameters initialization */
00437 static void init_ab( lapack_int size, float *ab ) {
00438     lapack_int i;
00439     for( i = 0; i < size; i++ ) {
00440         ab[i] = 0;
00441     }
00442     ab[0] = 5.489999771e+000;  /* ab[0,0] */
00443     ab[9] = 5.630000114e+000;  /* ab[0,1] */
00444     ab[18] = 2.599999905e+000;  /* ab[0,2] */
00445     ab[27] = 5.170000076e+000;  /* ab[0,3] */
00446     ab[1] = 2.680000067e+000;  /* ab[1,0] */
00447     ab[10] = -2.390000105e+000;  /* ab[1,1] */
00448     ab[19] = -2.220000029e+000;  /* ab[1,2] */
00449     ab[28] = 0.000000000e+000;  /* ab[1,3] */
00450 }
00451 static void init_afb( lapack_int size, float *afb ) {
00452     lapack_int i;
00453     for( i = 0; i < size; i++ ) {
00454         afb[i] = 0;
00455     }
00456     afb[0] = 2.343074799e+000;  /* afb[0,0] */
00457     afb[9] = 2.078877211e+000;  /* afb[0,1] */
00458     afb[18] = 1.130612254e+000;  /* afb[0,2] */
00459     afb[27] = 1.146524668e+000;  /* afb[0,3] */
00460     afb[1] = 1.143796206e+000;  /* afb[1,0] */
00461     afb[10] = -1.149659038e+000;  /* afb[1,1] */
00462     afb[19] = -1.963537931e+000;  /* afb[1,2] */
00463     afb[28] = 0.000000000e+000;  /* afb[1,3] */
00464 }
00465 static void init_b( lapack_int size, float *b ) {
00466     lapack_int i;
00467     for( i = 0; i < size; i++ ) {
00468         b[i] = 0;
00469     }
00470     b[0] = 2.209000015e+001;  /* b[0,0] */
00471     b[8] = 5.099999905e+000;  /* b[0,1] */
00472     b[1] = 9.310000420e+000;  /* b[1,0] */
00473     b[9] = 3.080999947e+001;  /* b[1,1] */
00474     b[2] = -5.239999771e+000;  /* b[2,0] */
00475     b[10] = -2.581999969e+001;  /* b[2,1] */
00476     b[3] = 1.182999992e+001;  /* b[3,0] */
00477     b[11] = 2.289999962e+001;  /* b[3,1] */
00478 }
00479 static void init_x( lapack_int size, float *x ) {
00480     lapack_int i;
00481     for( i = 0; i < size; i++ ) {
00482         x[i] = 0;
00483     }
00484     x[0] = 5.000001431e+000;  /* x[0,0] */
00485     x[8] = -1.999999642e+000;  /* x[0,1] */
00486     x[1] = -2.000000954e+000;  /* x[1,0] */
00487     x[9] = 5.999998569e+000;  /* x[1,1] */
00488     x[2] = -3.000001192e+000;  /* x[2,0] */
00489     x[10] = -1.000002265e+000;  /* x[2,1] */
00490     x[3] = 9.999994040e-001;  /* x[3,0] */
00491     x[11] = 3.999998808e+000;  /* x[3,1] */
00492 }
00493 static void init_ferr( lapack_int size, float *ferr ) {
00494     lapack_int i;
00495     for( i = 0; i < size; i++ ) {
00496         ferr[i] = 0;
00497     }
00498 }
00499 static void init_berr( lapack_int size, float *berr ) {
00500     lapack_int i;
00501     for( i = 0; i < size; i++ ) {
00502         berr[i] = 0;
00503     }
00504 }
00505 static void init_work( lapack_int size, float *work ) {
00506     lapack_int i;
00507     for( i = 0; i < size; i++ ) {
00508         work[i] = 0;
00509     }
00510 }
00511 static void init_iwork( lapack_int size, lapack_int *iwork ) {
00512     lapack_int i;
00513     for( i = 0; i < size; i++ ) {
00514         iwork[i] = 0;
00515     }
00516 }
00517 
00518 /* Auxiliary function: C interface to spbrfs results check */
00519 /* Return value: 0 - test is passed, non-zero - test is failed */
00520 static int compare_spbrfs( float *x, float *x_i, float *ferr, float *ferr_i,
00521                            float *berr, float *berr_i, lapack_int info,
00522                            lapack_int info_i, lapack_int ldx, lapack_int nrhs )
00523 {
00524     lapack_int i;
00525     int failed = 0;
00526     for( i = 0; i < ldx*nrhs; i++ ) {
00527         failed += compare_floats(x[i],x_i[i]);
00528     }
00529     for( i = 0; i < nrhs; i++ ) {
00530         failed += compare_floats(ferr[i],ferr_i[i]);
00531     }
00532     for( i = 0; i < nrhs; i++ ) {
00533         failed += compare_floats(berr[i],berr_i[i]);
00534     }
00535     failed += (info == info_i) ? 0 : 1;
00536     if( info != 0 || info_i != 0 ) {
00537         printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00538     }
00539 
00540     return failed;
00541 }


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:56:12