dporfs_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 * dporfs_1 is the test program for the C interface to LAPACK
00036 * routine dporfs
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_dporfs( char *uplo, lapack_int *n, lapack_int *nrhs,
00055                                  lapack_int *lda, lapack_int *ldaf,
00056                                  lapack_int *ldb, lapack_int *ldx );
00057 static void init_a( lapack_int size, double *a );
00058 static void init_af( lapack_int size, double *af );
00059 static void init_b( lapack_int size, double *b );
00060 static void init_x( lapack_int size, double *x );
00061 static void init_ferr( lapack_int size, double *ferr );
00062 static void init_berr( lapack_int size, double *berr );
00063 static void init_work( lapack_int size, double *work );
00064 static void init_iwork( lapack_int size, lapack_int *iwork );
00065 static int compare_dporfs( double *x, double *x_i, double *ferr, double *ferr_i,
00066                            double *berr, double *berr_i, lapack_int info,
00067                            lapack_int info_i, lapack_int ldx, lapack_int nrhs );
00068 
00069 int main(void)
00070 {
00071     /* Local scalars */
00072     char uplo, uplo_i;
00073     lapack_int n, n_i;
00074     lapack_int nrhs, nrhs_i;
00075     lapack_int lda, lda_i;
00076     lapack_int lda_r;
00077     lapack_int ldaf, ldaf_i;
00078     lapack_int ldaf_r;
00079     lapack_int ldb, ldb_i;
00080     lapack_int ldb_r;
00081     lapack_int ldx, ldx_i;
00082     lapack_int ldx_r;
00083     lapack_int info, info_i;
00084     lapack_int i;
00085     int failed;
00086 
00087     /* Local arrays */
00088     double *a = NULL, *a_i = NULL;
00089     double *af = NULL, *af_i = NULL;
00090     double *b = NULL, *b_i = NULL;
00091     double *x = NULL, *x_i = NULL;
00092     double *ferr = NULL, *ferr_i = NULL;
00093     double *berr = NULL, *berr_i = NULL;
00094     double *work = NULL, *work_i = NULL;
00095     lapack_int *iwork = NULL, *iwork_i = NULL;
00096     double *x_save = NULL;
00097     double *ferr_save = NULL;
00098     double *berr_save = NULL;
00099     double *a_r = NULL;
00100     double *af_r = NULL;
00101     double *b_r = NULL;
00102     double *x_r = NULL;
00103 
00104     /* Iniitialize the scalar parameters */
00105     init_scalars_dporfs( &uplo, &n, &nrhs, &lda, &ldaf, &ldb, &ldx );
00106     lda_r = n+2;
00107     ldaf_r = n+2;
00108     ldb_r = nrhs+2;
00109     ldx_r = nrhs+2;
00110     uplo_i = uplo;
00111     n_i = n;
00112     nrhs_i = nrhs;
00113     lda_i = lda;
00114     ldaf_i = ldaf;
00115     ldb_i = ldb;
00116     ldx_i = ldx;
00117 
00118     /* Allocate memory for the LAPACK routine arrays */
00119     a = (double *)LAPACKE_malloc( lda*n * sizeof(double) );
00120     af = (double *)LAPACKE_malloc( ldaf*n * sizeof(double) );
00121     b = (double *)LAPACKE_malloc( ldb*nrhs * sizeof(double) );
00122     x = (double *)LAPACKE_malloc( ldx*nrhs * sizeof(double) );
00123     ferr = (double *)LAPACKE_malloc( nrhs * sizeof(double) );
00124     berr = (double *)LAPACKE_malloc( nrhs * sizeof(double) );
00125     work = (double *)LAPACKE_malloc( 3*n * sizeof(double) );
00126     iwork = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
00127 
00128     /* Allocate memory for the C interface function arrays */
00129     a_i = (double *)LAPACKE_malloc( lda*n * sizeof(double) );
00130     af_i = (double *)LAPACKE_malloc( ldaf*n * sizeof(double) );
00131     b_i = (double *)LAPACKE_malloc( ldb*nrhs * sizeof(double) );
00132     x_i = (double *)LAPACKE_malloc( ldx*nrhs * sizeof(double) );
00133     ferr_i = (double *)LAPACKE_malloc( nrhs * sizeof(double) );
00134     berr_i = (double *)LAPACKE_malloc( nrhs * sizeof(double) );
00135     work_i = (double *)LAPACKE_malloc( 3*n * sizeof(double) );
00136     iwork_i = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
00137 
00138     /* Allocate memory for the backup arrays */
00139     x_save = (double *)LAPACKE_malloc( ldx*nrhs * sizeof(double) );
00140     ferr_save = (double *)LAPACKE_malloc( nrhs * sizeof(double) );
00141     berr_save = (double *)LAPACKE_malloc( nrhs * sizeof(double) );
00142 
00143     /* Allocate memory for the row-major arrays */
00144     a_r = (double *)LAPACKE_malloc( n*(n+2) * sizeof(double) );
00145     af_r = (double *)LAPACKE_malloc( n*(n+2) * sizeof(double) );
00146     b_r = (double *)LAPACKE_malloc( n*(nrhs+2) * sizeof(double) );
00147     x_r = (double *)LAPACKE_malloc( n*(nrhs+2) * sizeof(double) );
00148 
00149     /* Initialize input arrays */
00150     init_a( lda*n, a );
00151     init_af( ldaf*n, af );
00152     init_b( ldb*nrhs, b );
00153     init_x( ldx*nrhs, x );
00154     init_ferr( nrhs, ferr );
00155     init_berr( nrhs, berr );
00156     init_work( 3*n, work );
00157     init_iwork( n, iwork );
00158 
00159     /* Backup the ouptut arrays */
00160     for( i = 0; i < ldx*nrhs; i++ ) {
00161         x_save[i] = x[i];
00162     }
00163     for( i = 0; i < nrhs; i++ ) {
00164         ferr_save[i] = ferr[i];
00165     }
00166     for( i = 0; i < nrhs; i++ ) {
00167         berr_save[i] = berr[i];
00168     }
00169 
00170     /* Call the LAPACK routine */
00171     dporfs_( &uplo, &n, &nrhs, a, &lda, af, &ldaf, b, &ldb, x, &ldx, ferr, berr,
00172              work, iwork, &info );
00173 
00174     /* Initialize input data, call the column-major middle-level
00175      * interface to LAPACK routine and check the results */
00176     for( i = 0; i < lda*n; i++ ) {
00177         a_i[i] = a[i];
00178     }
00179     for( i = 0; i < ldaf*n; i++ ) {
00180         af_i[i] = af[i];
00181     }
00182     for( i = 0; i < ldb*nrhs; i++ ) {
00183         b_i[i] = b[i];
00184     }
00185     for( i = 0; i < ldx*nrhs; i++ ) {
00186         x_i[i] = x_save[i];
00187     }
00188     for( i = 0; i < nrhs; i++ ) {
00189         ferr_i[i] = ferr_save[i];
00190     }
00191     for( i = 0; i < nrhs; i++ ) {
00192         berr_i[i] = berr_save[i];
00193     }
00194     for( i = 0; i < 3*n; i++ ) {
00195         work_i[i] = work[i];
00196     }
00197     for( i = 0; i < n; i++ ) {
00198         iwork_i[i] = iwork[i];
00199     }
00200     info_i = LAPACKE_dporfs_work( LAPACK_COL_MAJOR, uplo_i, n_i, nrhs_i, a_i,
00201                                   lda_i, af_i, ldaf_i, b_i, ldb_i, x_i, ldx_i,
00202                                   ferr_i, berr_i, work_i, iwork_i );
00203 
00204     failed = compare_dporfs( x, x_i, ferr, ferr_i, berr, berr_i, info, info_i,
00205                              ldx, nrhs );
00206     if( failed == 0 ) {
00207         printf( "PASSED: column-major middle-level interface to dporfs\n" );
00208     } else {
00209         printf( "FAILED: column-major middle-level interface to dporfs\n" );
00210     }
00211 
00212     /* Initialize input data, call the column-major high-level
00213      * interface to LAPACK routine and check the results */
00214     for( i = 0; i < lda*n; i++ ) {
00215         a_i[i] = a[i];
00216     }
00217     for( i = 0; i < ldaf*n; i++ ) {
00218         af_i[i] = af[i];
00219     }
00220     for( i = 0; i < ldb*nrhs; i++ ) {
00221         b_i[i] = b[i];
00222     }
00223     for( i = 0; i < ldx*nrhs; i++ ) {
00224         x_i[i] = x_save[i];
00225     }
00226     for( i = 0; i < nrhs; i++ ) {
00227         ferr_i[i] = ferr_save[i];
00228     }
00229     for( i = 0; i < nrhs; i++ ) {
00230         berr_i[i] = berr_save[i];
00231     }
00232     for( i = 0; i < 3*n; i++ ) {
00233         work_i[i] = work[i];
00234     }
00235     for( i = 0; i < n; i++ ) {
00236         iwork_i[i] = iwork[i];
00237     }
00238     info_i = LAPACKE_dporfs( LAPACK_COL_MAJOR, uplo_i, n_i, nrhs_i, a_i, lda_i,
00239                              af_i, ldaf_i, b_i, ldb_i, x_i, ldx_i, ferr_i,
00240                              berr_i );
00241 
00242     failed = compare_dporfs( x, x_i, ferr, ferr_i, berr, berr_i, info, info_i,
00243                              ldx, nrhs );
00244     if( failed == 0 ) {
00245         printf( "PASSED: column-major high-level interface to dporfs\n" );
00246     } else {
00247         printf( "FAILED: column-major high-level interface to dporfs\n" );
00248     }
00249 
00250     /* Initialize input data, call the row-major middle-level
00251      * interface to LAPACK routine and check the results */
00252     for( i = 0; i < lda*n; i++ ) {
00253         a_i[i] = a[i];
00254     }
00255     for( i = 0; i < ldaf*n; i++ ) {
00256         af_i[i] = af[i];
00257     }
00258     for( i = 0; i < ldb*nrhs; i++ ) {
00259         b_i[i] = b[i];
00260     }
00261     for( i = 0; i < ldx*nrhs; i++ ) {
00262         x_i[i] = x_save[i];
00263     }
00264     for( i = 0; i < nrhs; i++ ) {
00265         ferr_i[i] = ferr_save[i];
00266     }
00267     for( i = 0; i < nrhs; i++ ) {
00268         berr_i[i] = berr_save[i];
00269     }
00270     for( i = 0; i < 3*n; i++ ) {
00271         work_i[i] = work[i];
00272     }
00273     for( i = 0; i < n; i++ ) {
00274         iwork_i[i] = iwork[i];
00275     }
00276 
00277     LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, n, a_i, lda, a_r, n+2 );
00278     LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, n, af_i, ldaf, af_r, n+2 );
00279     LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, nrhs, b_i, ldb, b_r, nrhs+2 );
00280     LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, nrhs, x_i, ldx, x_r, nrhs+2 );
00281     info_i = LAPACKE_dporfs_work( LAPACK_ROW_MAJOR, uplo_i, n_i, nrhs_i, a_r,
00282                                   lda_r, af_r, ldaf_r, b_r, ldb_r, x_r, ldx_r,
00283                                   ferr_i, berr_i, work_i, iwork_i );
00284 
00285     LAPACKE_dge_trans( LAPACK_ROW_MAJOR, n, nrhs, x_r, nrhs+2, x_i, ldx );
00286 
00287     failed = compare_dporfs( x, x_i, ferr, ferr_i, berr, berr_i, info, info_i,
00288                              ldx, nrhs );
00289     if( failed == 0 ) {
00290         printf( "PASSED: row-major middle-level interface to dporfs\n" );
00291     } else {
00292         printf( "FAILED: row-major middle-level interface to dporfs\n" );
00293     }
00294 
00295     /* Initialize input data, call the row-major high-level
00296      * interface to LAPACK routine and check the results */
00297     for( i = 0; i < lda*n; i++ ) {
00298         a_i[i] = a[i];
00299     }
00300     for( i = 0; i < ldaf*n; i++ ) {
00301         af_i[i] = af[i];
00302     }
00303     for( i = 0; i < ldb*nrhs; i++ ) {
00304         b_i[i] = b[i];
00305     }
00306     for( i = 0; i < ldx*nrhs; i++ ) {
00307         x_i[i] = x_save[i];
00308     }
00309     for( i = 0; i < nrhs; i++ ) {
00310         ferr_i[i] = ferr_save[i];
00311     }
00312     for( i = 0; i < nrhs; i++ ) {
00313         berr_i[i] = berr_save[i];
00314     }
00315     for( i = 0; i < 3*n; i++ ) {
00316         work_i[i] = work[i];
00317     }
00318     for( i = 0; i < n; i++ ) {
00319         iwork_i[i] = iwork[i];
00320     }
00321 
00322     /* Init row_major arrays */
00323     LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, n, a_i, lda, a_r, n+2 );
00324     LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, n, af_i, ldaf, af_r, n+2 );
00325     LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, nrhs, b_i, ldb, b_r, nrhs+2 );
00326     LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, nrhs, x_i, ldx, x_r, nrhs+2 );
00327     info_i = LAPACKE_dporfs( LAPACK_ROW_MAJOR, uplo_i, n_i, nrhs_i, a_r, lda_r,
00328                              af_r, ldaf_r, b_r, ldb_r, x_r, ldx_r, ferr_i,
00329                              berr_i );
00330 
00331     LAPACKE_dge_trans( LAPACK_ROW_MAJOR, n, nrhs, x_r, nrhs+2, x_i, ldx );
00332 
00333     failed = compare_dporfs( x, x_i, ferr, ferr_i, berr, berr_i, info, info_i,
00334                              ldx, nrhs );
00335     if( failed == 0 ) {
00336         printf( "PASSED: row-major high-level interface to dporfs\n" );
00337     } else {
00338         printf( "FAILED: row-major high-level interface to dporfs\n" );
00339     }
00340 
00341     /* Release memory */
00342     if( a != NULL ) {
00343         LAPACKE_free( a );
00344     }
00345     if( a_i != NULL ) {
00346         LAPACKE_free( a_i );
00347     }
00348     if( a_r != NULL ) {
00349         LAPACKE_free( a_r );
00350     }
00351     if( af != NULL ) {
00352         LAPACKE_free( af );
00353     }
00354     if( af_i != NULL ) {
00355         LAPACKE_free( af_i );
00356     }
00357     if( af_r != NULL ) {
00358         LAPACKE_free( af_r );
00359     }
00360     if( b != NULL ) {
00361         LAPACKE_free( b );
00362     }
00363     if( b_i != NULL ) {
00364         LAPACKE_free( b_i );
00365     }
00366     if( b_r != NULL ) {
00367         LAPACKE_free( b_r );
00368     }
00369     if( x != NULL ) {
00370         LAPACKE_free( x );
00371     }
00372     if( x_i != NULL ) {
00373         LAPACKE_free( x_i );
00374     }
00375     if( x_r != NULL ) {
00376         LAPACKE_free( x_r );
00377     }
00378     if( x_save != NULL ) {
00379         LAPACKE_free( x_save );
00380     }
00381     if( ferr != NULL ) {
00382         LAPACKE_free( ferr );
00383     }
00384     if( ferr_i != NULL ) {
00385         LAPACKE_free( ferr_i );
00386     }
00387     if( ferr_save != NULL ) {
00388         LAPACKE_free( ferr_save );
00389     }
00390     if( berr != NULL ) {
00391         LAPACKE_free( berr );
00392     }
00393     if( berr_i != NULL ) {
00394         LAPACKE_free( berr_i );
00395     }
00396     if( berr_save != NULL ) {
00397         LAPACKE_free( berr_save );
00398     }
00399     if( work != NULL ) {
00400         LAPACKE_free( work );
00401     }
00402     if( work_i != NULL ) {
00403         LAPACKE_free( work_i );
00404     }
00405     if( iwork != NULL ) {
00406         LAPACKE_free( iwork );
00407     }
00408     if( iwork_i != NULL ) {
00409         LAPACKE_free( iwork_i );
00410     }
00411 
00412     return 0;
00413 }
00414 
00415 /* Auxiliary function: dporfs scalar parameters initialization */
00416 static void init_scalars_dporfs( char *uplo, lapack_int *n, lapack_int *nrhs,
00417                                  lapack_int *lda, lapack_int *ldaf,
00418                                  lapack_int *ldb, lapack_int *ldx )
00419 {
00420     *uplo = 'L';
00421     *n = 4;
00422     *nrhs = 2;
00423     *lda = 8;
00424     *ldaf = 8;
00425     *ldb = 8;
00426     *ldx = 8;
00427 
00428     return;
00429 }
00430 
00431 /* Auxiliary functions: dporfs array parameters initialization */
00432 static void init_a( lapack_int size, double *a ) {
00433     lapack_int i;
00434     for( i = 0; i < size; i++ ) {
00435         a[i] = 0;
00436     }
00437     a[0] = 4.16000000000000010e+000;  /* a[0,0] */
00438     a[8] = 0.00000000000000000e+000;  /* a[0,1] */
00439     a[16] = 0.00000000000000000e+000;  /* a[0,2] */
00440     a[24] = 0.00000000000000000e+000;  /* a[0,3] */
00441     a[1] = -3.12000000000000010e+000;  /* a[1,0] */
00442     a[9] = 5.03000000000000020e+000;  /* a[1,1] */
00443     a[17] = 0.00000000000000000e+000;  /* a[1,2] */
00444     a[25] = 0.00000000000000000e+000;  /* a[1,3] */
00445     a[2] = 5.60000000000000050e-001;  /* a[2,0] */
00446     a[10] = -8.29999999999999960e-001;  /* a[2,1] */
00447     a[18] = 7.60000000000000010e-001;  /* a[2,2] */
00448     a[26] = 0.00000000000000000e+000;  /* a[2,3] */
00449     a[3] = -1.00000000000000010e-001;  /* a[3,0] */
00450     a[11] = 1.17999999999999990e+000;  /* a[3,1] */
00451     a[19] = 3.40000000000000020e-001;  /* a[3,2] */
00452     a[27] = 1.17999999999999990e+000;  /* a[3,3] */
00453 }
00454 static void init_af( lapack_int size, double *af ) {
00455     lapack_int i;
00456     for( i = 0; i < size; i++ ) {
00457         af[i] = 0;
00458     }
00459     af[0] = 2.03960780543711410e+000;  /* af[0,0] */
00460     af[8] = 0.00000000000000000e+000;  /* af[0,1] */
00461     af[16] = 0.00000000000000000e+000;  /* af[0,2] */
00462     af[24] = 0.00000000000000000e+000;  /* af[0,3] */
00463     af[1] = -1.52970585407783540e+000;  /* af[1,0] */
00464     af[9] = 1.64012194668567270e+000;  /* af[1,1] */
00465     af[17] = 0.00000000000000000e+000;  /* af[1,2] */
00466     af[25] = 0.00000000000000000e+000;  /* af[1,3] */
00467     af[2] = 2.74562589193457660e-001;  /* af[2,0] */
00468     af[10] = -2.49981411948373810e-001;  /* af[2,1] */
00469     af[18] = 7.88748805574805310e-001;  /* af[2,2] */
00470     af[26] = 0.00000000000000000e+000;  /* af[2,3] */
00471     af[3] = -4.90290337845460110e-002;  /* af[3,0] */
00472     af[11] = 6.73730390738910060e-001;  /* af[3,1] */
00473     af[19] = 6.61657563374256520e-001;  /* af[3,2] */
00474     af[27] = 5.34689426929868430e-001;  /* af[3,3] */
00475 }
00476 static void init_b( lapack_int size, double *b ) {
00477     lapack_int i;
00478     for( i = 0; i < size; i++ ) {
00479         b[i] = 0;
00480     }
00481     b[0] = 8.69999999999999930e+000;  /* b[0,0] */
00482     b[8] = 8.30000000000000070e+000;  /* b[0,1] */
00483     b[1] = -1.33500000000000000e+001;  /* b[1,0] */
00484     b[9] = 2.12999999999999990e+000;  /* b[1,1] */
00485     b[2] = 1.88999999999999990e+000;  /* b[2,0] */
00486     b[10] = 1.61000000000000010e+000;  /* b[2,1] */
00487     b[3] = -4.13999999999999970e+000;  /* b[3,0] */
00488     b[11] = 5.00000000000000000e+000;  /* b[3,1] */
00489 }
00490 static void init_x( lapack_int size, double *x ) {
00491     lapack_int i;
00492     for( i = 0; i < size; i++ ) {
00493         x[i] = 0;
00494     }
00495     x[0] = 9.99999999999999780e-001;  /* x[0,0] */
00496     x[8] = 3.99999999999999820e+000;  /* x[0,1] */
00497     x[1] = -9.99999999999999220e-001;  /* x[1,0] */
00498     x[9] = 2.99999999999999820e+000;  /* x[1,1] */
00499     x[2] = 2.00000000000000180e+000;  /* x[2,0] */
00500     x[10] = 1.99999999999999780e+000;  /* x[2,1] */
00501     x[3] = -3.00000000000000130e+000;  /* x[3,0] */
00502     x[11] = 1.00000000000000220e+000;  /* x[3,1] */
00503 }
00504 static void init_ferr( lapack_int size, double *ferr ) {
00505     lapack_int i;
00506     for( i = 0; i < size; i++ ) {
00507         ferr[i] = 0;
00508     }
00509 }
00510 static void init_berr( lapack_int size, double *berr ) {
00511     lapack_int i;
00512     for( i = 0; i < size; i++ ) {
00513         berr[i] = 0;
00514     }
00515 }
00516 static void init_work( lapack_int size, double *work ) {
00517     lapack_int i;
00518     for( i = 0; i < size; i++ ) {
00519         work[i] = 0;
00520     }
00521 }
00522 static void init_iwork( lapack_int size, lapack_int *iwork ) {
00523     lapack_int i;
00524     for( i = 0; i < size; i++ ) {
00525         iwork[i] = 0;
00526     }
00527 }
00528 
00529 /* Auxiliary function: C interface to dporfs results check */
00530 /* Return value: 0 - test is passed, non-zero - test is failed */
00531 static int compare_dporfs( double *x, double *x_i, double *ferr, double *ferr_i,
00532                            double *berr, double *berr_i, lapack_int info,
00533                            lapack_int info_i, lapack_int ldx, lapack_int nrhs )
00534 {
00535     lapack_int i;
00536     int failed = 0;
00537     for( i = 0; i < ldx*nrhs; i++ ) {
00538         failed += compare_doubles(x[i],x_i[i]);
00539     }
00540     for( i = 0; i < nrhs; i++ ) {
00541         failed += compare_doubles(ferr[i],ferr_i[i]);
00542     }
00543     for( i = 0; i < nrhs; i++ ) {
00544         failed += compare_doubles(berr[i],berr_i[i]);
00545     }
00546     failed += (info == info_i) ? 0 : 1;
00547     if( info != 0 || info_i != 0 ) {
00548         printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00549     }
00550 
00551     return failed;
00552 }


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:47