cporfs_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 * cporfs_1 is the test program for the C interface to LAPACK
00036 * routine cporfs
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_cporfs( 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, lapack_complex_float *a );
00058 static void init_af( lapack_int size, lapack_complex_float *af );
00059 static void init_b( lapack_int size, lapack_complex_float *b );
00060 static void init_x( lapack_int size, lapack_complex_float *x );
00061 static void init_ferr( lapack_int size, float *ferr );
00062 static void init_berr( lapack_int size, float *berr );
00063 static void init_work( lapack_int size, lapack_complex_float *work );
00064 static void init_rwork( lapack_int size, float *rwork );
00065 static int compare_cporfs( lapack_complex_float *x, lapack_complex_float *x_i,
00066                            float *ferr, float *ferr_i, float *berr,
00067                            float *berr_i, lapack_int info, lapack_int info_i,
00068                            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 nrhs, nrhs_i;
00076     lapack_int lda, lda_i;
00077     lapack_int lda_r;
00078     lapack_int ldaf, ldaf_i;
00079     lapack_int ldaf_r;
00080     lapack_int ldb, ldb_i;
00081     lapack_int ldb_r;
00082     lapack_int ldx, ldx_i;
00083     lapack_int ldx_r;
00084     lapack_int info, info_i;
00085     lapack_int i;
00086     int failed;
00087 
00088     /* Local arrays */
00089     lapack_complex_float *a = NULL, *a_i = NULL;
00090     lapack_complex_float *af = NULL, *af_i = NULL;
00091     lapack_complex_float *b = NULL, *b_i = NULL;
00092     lapack_complex_float *x = NULL, *x_i = NULL;
00093     float *ferr = NULL, *ferr_i = NULL;
00094     float *berr = NULL, *berr_i = NULL;
00095     lapack_complex_float *work = NULL, *work_i = NULL;
00096     float *rwork = NULL, *rwork_i = NULL;
00097     lapack_complex_float *x_save = NULL;
00098     float *ferr_save = NULL;
00099     float *berr_save = NULL;
00100     lapack_complex_float *a_r = NULL;
00101     lapack_complex_float *af_r = NULL;
00102     lapack_complex_float *b_r = NULL;
00103     lapack_complex_float *x_r = NULL;
00104 
00105     /* Iniitialize the scalar parameters */
00106     init_scalars_cporfs( &uplo, &n, &nrhs, &lda, &ldaf, &ldb, &ldx );
00107     lda_r = n+2;
00108     ldaf_r = n+2;
00109     ldb_r = nrhs+2;
00110     ldx_r = nrhs+2;
00111     uplo_i = uplo;
00112     n_i = n;
00113     nrhs_i = nrhs;
00114     lda_i = lda;
00115     ldaf_i = ldaf;
00116     ldb_i = ldb;
00117     ldx_i = ldx;
00118 
00119     /* Allocate memory for the LAPACK routine arrays */
00120     a = (lapack_complex_float *)
00121         LAPACKE_malloc( lda*n * sizeof(lapack_complex_float) );
00122     af = (lapack_complex_float *)
00123         LAPACKE_malloc( ldaf*n * sizeof(lapack_complex_float) );
00124     b = (lapack_complex_float *)
00125         LAPACKE_malloc( ldb*nrhs * sizeof(lapack_complex_float) );
00126     x = (lapack_complex_float *)
00127         LAPACKE_malloc( ldx*nrhs * sizeof(lapack_complex_float) );
00128     ferr = (float *)LAPACKE_malloc( nrhs * sizeof(float) );
00129     berr = (float *)LAPACKE_malloc( nrhs * sizeof(float) );
00130     work = (lapack_complex_float *)
00131         LAPACKE_malloc( 2*n * sizeof(lapack_complex_float) );
00132     rwork = (float *)LAPACKE_malloc( n * sizeof(float) );
00133 
00134     /* Allocate memory for the C interface function arrays */
00135     a_i = (lapack_complex_float *)
00136         LAPACKE_malloc( lda*n * sizeof(lapack_complex_float) );
00137     af_i = (lapack_complex_float *)
00138         LAPACKE_malloc( ldaf*n * sizeof(lapack_complex_float) );
00139     b_i = (lapack_complex_float *)
00140         LAPACKE_malloc( ldb*nrhs * sizeof(lapack_complex_float) );
00141     x_i = (lapack_complex_float *)
00142         LAPACKE_malloc( ldx*nrhs * sizeof(lapack_complex_float) );
00143     ferr_i = (float *)LAPACKE_malloc( nrhs * sizeof(float) );
00144     berr_i = (float *)LAPACKE_malloc( nrhs * sizeof(float) );
00145     work_i = (lapack_complex_float *)
00146         LAPACKE_malloc( 2*n * sizeof(lapack_complex_float) );
00147     rwork_i = (float *)LAPACKE_malloc( n * sizeof(float) );
00148 
00149     /* Allocate memory for the backup arrays */
00150     x_save = (lapack_complex_float *)
00151         LAPACKE_malloc( ldx*nrhs * sizeof(lapack_complex_float) );
00152     ferr_save = (float *)LAPACKE_malloc( nrhs * sizeof(float) );
00153     berr_save = (float *)LAPACKE_malloc( nrhs * sizeof(float) );
00154 
00155     /* Allocate memory for the row-major arrays */
00156     a_r = (lapack_complex_float *)
00157         LAPACKE_malloc( n*(n+2) * sizeof(lapack_complex_float) );
00158     af_r = (lapack_complex_float *)
00159         LAPACKE_malloc( n*(n+2) * sizeof(lapack_complex_float) );
00160     b_r = (lapack_complex_float *)
00161         LAPACKE_malloc( n*(nrhs+2) * sizeof(lapack_complex_float) );
00162     x_r = (lapack_complex_float *)
00163         LAPACKE_malloc( n*(nrhs+2) * sizeof(lapack_complex_float) );
00164 
00165     /* Initialize input arrays */
00166     init_a( lda*n, a );
00167     init_af( ldaf*n, af );
00168     init_b( ldb*nrhs, b );
00169     init_x( ldx*nrhs, x );
00170     init_ferr( nrhs, ferr );
00171     init_berr( nrhs, berr );
00172     init_work( 2*n, work );
00173     init_rwork( n, rwork );
00174 
00175     /* Backup the ouptut arrays */
00176     for( i = 0; i < ldx*nrhs; i++ ) {
00177         x_save[i] = x[i];
00178     }
00179     for( i = 0; i < nrhs; i++ ) {
00180         ferr_save[i] = ferr[i];
00181     }
00182     for( i = 0; i < nrhs; i++ ) {
00183         berr_save[i] = berr[i];
00184     }
00185 
00186     /* Call the LAPACK routine */
00187     cporfs_( &uplo, &n, &nrhs, a, &lda, af, &ldaf, b, &ldb, x, &ldx, ferr, berr,
00188              work, rwork, &info );
00189 
00190     /* Initialize input data, call the column-major middle-level
00191      * interface to LAPACK routine and check the results */
00192     for( i = 0; i < lda*n; i++ ) {
00193         a_i[i] = a[i];
00194     }
00195     for( i = 0; i < ldaf*n; i++ ) {
00196         af_i[i] = af[i];
00197     }
00198     for( i = 0; i < ldb*nrhs; i++ ) {
00199         b_i[i] = b[i];
00200     }
00201     for( i = 0; i < ldx*nrhs; i++ ) {
00202         x_i[i] = x_save[i];
00203     }
00204     for( i = 0; i < nrhs; i++ ) {
00205         ferr_i[i] = ferr_save[i];
00206     }
00207     for( i = 0; i < nrhs; i++ ) {
00208         berr_i[i] = berr_save[i];
00209     }
00210     for( i = 0; i < 2*n; i++ ) {
00211         work_i[i] = work[i];
00212     }
00213     for( i = 0; i < n; i++ ) {
00214         rwork_i[i] = rwork[i];
00215     }
00216     info_i = LAPACKE_cporfs_work( LAPACK_COL_MAJOR, uplo_i, n_i, nrhs_i, a_i,
00217                                   lda_i, af_i, ldaf_i, b_i, ldb_i, x_i, ldx_i,
00218                                   ferr_i, berr_i, work_i, rwork_i );
00219 
00220     failed = compare_cporfs( x, x_i, ferr, ferr_i, berr, berr_i, info, info_i,
00221                              ldx, nrhs );
00222     if( failed == 0 ) {
00223         printf( "PASSED: column-major middle-level interface to cporfs\n" );
00224     } else {
00225         printf( "FAILED: column-major middle-level interface to cporfs\n" );
00226     }
00227 
00228     /* Initialize input data, call the column-major high-level
00229      * interface to LAPACK routine and check the results */
00230     for( i = 0; i < lda*n; i++ ) {
00231         a_i[i] = a[i];
00232     }
00233     for( i = 0; i < ldaf*n; i++ ) {
00234         af_i[i] = af[i];
00235     }
00236     for( i = 0; i < ldb*nrhs; i++ ) {
00237         b_i[i] = b[i];
00238     }
00239     for( i = 0; i < ldx*nrhs; i++ ) {
00240         x_i[i] = x_save[i];
00241     }
00242     for( i = 0; i < nrhs; i++ ) {
00243         ferr_i[i] = ferr_save[i];
00244     }
00245     for( i = 0; i < nrhs; i++ ) {
00246         berr_i[i] = berr_save[i];
00247     }
00248     for( i = 0; i < 2*n; i++ ) {
00249         work_i[i] = work[i];
00250     }
00251     for( i = 0; i < n; i++ ) {
00252         rwork_i[i] = rwork[i];
00253     }
00254     info_i = LAPACKE_cporfs( LAPACK_COL_MAJOR, uplo_i, n_i, nrhs_i, a_i, lda_i,
00255                              af_i, ldaf_i, b_i, ldb_i, x_i, ldx_i, ferr_i,
00256                              berr_i );
00257 
00258     failed = compare_cporfs( x, x_i, ferr, ferr_i, berr, berr_i, info, info_i,
00259                              ldx, nrhs );
00260     if( failed == 0 ) {
00261         printf( "PASSED: column-major high-level interface to cporfs\n" );
00262     } else {
00263         printf( "FAILED: column-major high-level interface to cporfs\n" );
00264     }
00265 
00266     /* Initialize input data, call the row-major middle-level
00267      * interface to LAPACK routine and check the results */
00268     for( i = 0; i < lda*n; i++ ) {
00269         a_i[i] = a[i];
00270     }
00271     for( i = 0; i < ldaf*n; i++ ) {
00272         af_i[i] = af[i];
00273     }
00274     for( i = 0; i < ldb*nrhs; i++ ) {
00275         b_i[i] = b[i];
00276     }
00277     for( i = 0; i < ldx*nrhs; i++ ) {
00278         x_i[i] = x_save[i];
00279     }
00280     for( i = 0; i < nrhs; i++ ) {
00281         ferr_i[i] = ferr_save[i];
00282     }
00283     for( i = 0; i < nrhs; i++ ) {
00284         berr_i[i] = berr_save[i];
00285     }
00286     for( i = 0; i < 2*n; i++ ) {
00287         work_i[i] = work[i];
00288     }
00289     for( i = 0; i < n; i++ ) {
00290         rwork_i[i] = rwork[i];
00291     }
00292 
00293     LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, n, a_i, lda, a_r, n+2 );
00294     LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, n, af_i, ldaf, af_r, n+2 );
00295     LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, nrhs, b_i, ldb, b_r, nrhs+2 );
00296     LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, nrhs, x_i, ldx, x_r, nrhs+2 );
00297     info_i = LAPACKE_cporfs_work( LAPACK_ROW_MAJOR, uplo_i, n_i, nrhs_i, a_r,
00298                                   lda_r, af_r, ldaf_r, b_r, ldb_r, x_r, ldx_r,
00299                                   ferr_i, berr_i, work_i, rwork_i );
00300 
00301     LAPACKE_cge_trans( LAPACK_ROW_MAJOR, n, nrhs, x_r, nrhs+2, x_i, ldx );
00302 
00303     failed = compare_cporfs( x, x_i, ferr, ferr_i, berr, berr_i, info, info_i,
00304                              ldx, nrhs );
00305     if( failed == 0 ) {
00306         printf( "PASSED: row-major middle-level interface to cporfs\n" );
00307     } else {
00308         printf( "FAILED: row-major middle-level interface to cporfs\n" );
00309     }
00310 
00311     /* Initialize input data, call the row-major high-level
00312      * interface to LAPACK routine and check the results */
00313     for( i = 0; i < lda*n; i++ ) {
00314         a_i[i] = a[i];
00315     }
00316     for( i = 0; i < ldaf*n; i++ ) {
00317         af_i[i] = af[i];
00318     }
00319     for( i = 0; i < ldb*nrhs; i++ ) {
00320         b_i[i] = b[i];
00321     }
00322     for( i = 0; i < ldx*nrhs; i++ ) {
00323         x_i[i] = x_save[i];
00324     }
00325     for( i = 0; i < nrhs; i++ ) {
00326         ferr_i[i] = ferr_save[i];
00327     }
00328     for( i = 0; i < nrhs; i++ ) {
00329         berr_i[i] = berr_save[i];
00330     }
00331     for( i = 0; i < 2*n; i++ ) {
00332         work_i[i] = work[i];
00333     }
00334     for( i = 0; i < n; i++ ) {
00335         rwork_i[i] = rwork[i];
00336     }
00337 
00338     /* Init row_major arrays */
00339     LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, n, a_i, lda, a_r, n+2 );
00340     LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, n, af_i, ldaf, af_r, n+2 );
00341     LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, nrhs, b_i, ldb, b_r, nrhs+2 );
00342     LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, nrhs, x_i, ldx, x_r, nrhs+2 );
00343     info_i = LAPACKE_cporfs( LAPACK_ROW_MAJOR, uplo_i, n_i, nrhs_i, a_r, lda_r,
00344                              af_r, ldaf_r, b_r, ldb_r, x_r, ldx_r, ferr_i,
00345                              berr_i );
00346 
00347     LAPACKE_cge_trans( LAPACK_ROW_MAJOR, n, nrhs, x_r, nrhs+2, x_i, ldx );
00348 
00349     failed = compare_cporfs( x, x_i, ferr, ferr_i, berr, berr_i, info, info_i,
00350                              ldx, nrhs );
00351     if( failed == 0 ) {
00352         printf( "PASSED: row-major high-level interface to cporfs\n" );
00353     } else {
00354         printf( "FAILED: row-major high-level interface to cporfs\n" );
00355     }
00356 
00357     /* Release memory */
00358     if( a != NULL ) {
00359         LAPACKE_free( a );
00360     }
00361     if( a_i != NULL ) {
00362         LAPACKE_free( a_i );
00363     }
00364     if( a_r != NULL ) {
00365         LAPACKE_free( a_r );
00366     }
00367     if( af != NULL ) {
00368         LAPACKE_free( af );
00369     }
00370     if( af_i != NULL ) {
00371         LAPACKE_free( af_i );
00372     }
00373     if( af_r != NULL ) {
00374         LAPACKE_free( af_r );
00375     }
00376     if( b != NULL ) {
00377         LAPACKE_free( b );
00378     }
00379     if( b_i != NULL ) {
00380         LAPACKE_free( b_i );
00381     }
00382     if( b_r != NULL ) {
00383         LAPACKE_free( b_r );
00384     }
00385     if( x != NULL ) {
00386         LAPACKE_free( x );
00387     }
00388     if( x_i != NULL ) {
00389         LAPACKE_free( x_i );
00390     }
00391     if( x_r != NULL ) {
00392         LAPACKE_free( x_r );
00393     }
00394     if( x_save != NULL ) {
00395         LAPACKE_free( x_save );
00396     }
00397     if( ferr != NULL ) {
00398         LAPACKE_free( ferr );
00399     }
00400     if( ferr_i != NULL ) {
00401         LAPACKE_free( ferr_i );
00402     }
00403     if( ferr_save != NULL ) {
00404         LAPACKE_free( ferr_save );
00405     }
00406     if( berr != NULL ) {
00407         LAPACKE_free( berr );
00408     }
00409     if( berr_i != NULL ) {
00410         LAPACKE_free( berr_i );
00411     }
00412     if( berr_save != NULL ) {
00413         LAPACKE_free( berr_save );
00414     }
00415     if( work != NULL ) {
00416         LAPACKE_free( work );
00417     }
00418     if( work_i != NULL ) {
00419         LAPACKE_free( work_i );
00420     }
00421     if( rwork != NULL ) {
00422         LAPACKE_free( rwork );
00423     }
00424     if( rwork_i != NULL ) {
00425         LAPACKE_free( rwork_i );
00426     }
00427 
00428     return 0;
00429 }
00430 
00431 /* Auxiliary function: cporfs scalar parameters initialization */
00432 static void init_scalars_cporfs( char *uplo, lapack_int *n, lapack_int *nrhs,
00433                                  lapack_int *lda, lapack_int *ldaf,
00434                                  lapack_int *ldb, lapack_int *ldx )
00435 {
00436     *uplo = 'L';
00437     *n = 4;
00438     *nrhs = 2;
00439     *lda = 8;
00440     *ldaf = 8;
00441     *ldb = 8;
00442     *ldx = 8;
00443 
00444     return;
00445 }
00446 
00447 /* Auxiliary functions: cporfs array parameters initialization */
00448 static void init_a( lapack_int size, lapack_complex_float *a ) {
00449     lapack_int i;
00450     for( i = 0; i < size; i++ ) {
00451         a[i] = lapack_make_complex_float( 0.0f, 0.0f );
00452     }
00453     a[0] = lapack_make_complex_float( 3.230000019e+000, 0.000000000e+000 );
00454     a[8] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00455     a[16] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00456     a[24] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00457     a[1] = lapack_make_complex_float( 1.509999990e+000, 1.919999957e+000 );
00458     a[9] = lapack_make_complex_float( 3.579999924e+000, 0.000000000e+000 );
00459     a[17] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00460     a[25] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00461     a[2] = lapack_make_complex_float( 1.899999976e+000, -8.399999738e-001 );
00462     a[10] = lapack_make_complex_float( -2.300000042e-001, -1.110000014e+000 );
00463     a[18] = lapack_make_complex_float( 4.090000153e+000, 0.000000000e+000 );
00464     a[26] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00465     a[3] = lapack_make_complex_float( 4.199999869e-001, -2.500000000e+000 );
00466     a[11] = lapack_make_complex_float( -1.179999948e+000, -1.370000005e+000 );
00467     a[19] = lapack_make_complex_float( 2.329999924e+000, 1.400000006e-001 );
00468     a[27] = lapack_make_complex_float( 4.289999962e+000, 0.000000000e+000 );
00469 }
00470 static void init_af( lapack_int size, lapack_complex_float *af ) {
00471     lapack_int i;
00472     for( i = 0; i < size; i++ ) {
00473         af[i] = lapack_make_complex_float( 0.0f, 0.0f );
00474     }
00475     af[0] = lapack_make_complex_float( 1.797220111e+000, 0.000000000e+000 );
00476     af[8] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00477     af[16] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00478     af[24] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00479     af[1] = lapack_make_complex_float( 8.401864767e-001, 1.068316579e+000 );
00480     af[9] = lapack_make_complex_float( 1.316353440e+000, 0.000000000e+000 );
00481     af[17] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00482     af[25] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00483     af[2] = lapack_make_complex_float( 1.057188272e+000, -4.673885107e-001 );
00484     af[10] = lapack_make_complex_float( -4.701749086e-001, 3.130658567e-001 );
00485     af[18] = lapack_make_complex_float( 1.560392976e+000, 0.000000000e+000 );
00486     af[26] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00487     af[3] = lapack_make_complex_float( 2.336942554e-001, -1.391037226e+000 );
00488     af[11] = lapack_make_complex_float( 8.335255086e-002, 3.676066548e-002 );
00489     af[19] = lapack_make_complex_float( 9.359616637e-001, 9.899691939e-001 );
00490     af[27] = lapack_make_complex_float( 6.603333950e-001, 0.000000000e+000 );
00491 }
00492 static void init_b( lapack_int size, lapack_complex_float *b ) {
00493     lapack_int i;
00494     for( i = 0; i < size; i++ ) {
00495         b[i] = lapack_make_complex_float( 0.0f, 0.0f );
00496     }
00497     b[0] = lapack_make_complex_float( 3.930000067e+000, -6.139999866e+000 );
00498     b[8] = lapack_make_complex_float( 1.480000019e+000, 6.579999924e+000 );
00499     b[1] = lapack_make_complex_float( 6.170000076e+000, 9.420000076e+000 );
00500     b[9] = lapack_make_complex_float( 4.650000095e+000, -4.750000000e+000 );
00501     b[2] = lapack_make_complex_float( -7.170000076e+000, -2.182999992e+001 );
00502     b[10] = lapack_make_complex_float( -4.909999847e+000, 2.289999962e+000 );
00503     b[3] = lapack_make_complex_float( 1.990000010e+000, -1.438000011e+001 );
00504     b[11] = lapack_make_complex_float( 7.639999866e+000, -1.078999996e+001 );
00505 }
00506 static void init_x( lapack_int size, lapack_complex_float *x ) {
00507     lapack_int i;
00508     for( i = 0; i < size; i++ ) {
00509         x[i] = lapack_make_complex_float( 0.0f, 0.0f );
00510     }
00511     x[0] = lapack_make_complex_float( 9.999942780e-001, -9.999976158e-001 );
00512     x[8] = lapack_make_complex_float( -1.000000358e+000, 2.000002861e+000 );
00513     x[1] = lapack_make_complex_float( 2.128165761e-006, 3.000000954e+000 );
00514     x[9] = lapack_make_complex_float( 3.000000477e+000, -4.000000477e+000 );
00515     x[2] = lapack_make_complex_float( -3.999995947e+000, -5.000000000e+000 );
00516     x[10] = lapack_make_complex_float( -1.999999404e+000, 2.999998093e+000 );
00517     x[3] = lapack_make_complex_float( 1.999997139e+000, 9.999971986e-001 );
00518     x[11] = lapack_make_complex_float( 3.999998569e+000, -4.999999523e+000 );
00519 }
00520 static void init_ferr( lapack_int size, float *ferr ) {
00521     lapack_int i;
00522     for( i = 0; i < size; i++ ) {
00523         ferr[i] = 0;
00524     }
00525 }
00526 static void init_berr( lapack_int size, float *berr ) {
00527     lapack_int i;
00528     for( i = 0; i < size; i++ ) {
00529         berr[i] = 0;
00530     }
00531 }
00532 static void init_work( lapack_int size, lapack_complex_float *work ) {
00533     lapack_int i;
00534     for( i = 0; i < size; i++ ) {
00535         work[i] = lapack_make_complex_float( 0.0f, 0.0f );
00536     }
00537 }
00538 static void init_rwork( lapack_int size, float *rwork ) {
00539     lapack_int i;
00540     for( i = 0; i < size; i++ ) {
00541         rwork[i] = 0;
00542     }
00543 }
00544 
00545 /* Auxiliary function: C interface to cporfs results check */
00546 /* Return value: 0 - test is passed, non-zero - test is failed */
00547 static int compare_cporfs( lapack_complex_float *x, lapack_complex_float *x_i,
00548                            float *ferr, float *ferr_i, float *berr,
00549                            float *berr_i, lapack_int info, lapack_int info_i,
00550                            lapack_int ldx, lapack_int nrhs )
00551 {
00552     lapack_int i;
00553     int failed = 0;
00554     for( i = 0; i < ldx*nrhs; i++ ) {
00555         failed += compare_complex_floats(x[i],x_i[i]);
00556     }
00557     for( i = 0; i < nrhs; i++ ) {
00558         failed += compare_floats(ferr[i],ferr_i[i]);
00559     }
00560     for( i = 0; i < nrhs; i++ ) {
00561         failed += compare_floats(berr[i],berr_i[i]);
00562     }
00563     failed += (info == info_i) ? 0 : 1;
00564     if( info != 0 || info_i != 0 ) {
00565         printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00566     }
00567 
00568     return failed;
00569 }


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