cherfs_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 * cherfs_1 is the test program for the C interface to LAPACK
00036 * routine cherfs
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_cherfs( 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_ipiv( lapack_int size, lapack_int *ipiv );
00060 static void init_b( lapack_int size, lapack_complex_float *b );
00061 static void init_x( lapack_int size, lapack_complex_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, lapack_complex_float *work );
00065 static void init_rwork( lapack_int size, float *rwork );
00066 static int compare_cherfs( lapack_complex_float *x, lapack_complex_float *x_i,
00067                            float *ferr, float *ferr_i, float *berr,
00068                            float *berr_i, lapack_int info, lapack_int info_i,
00069                            lapack_int ldx, lapack_int nrhs );
00070 
00071 int main(void)
00072 {
00073     /* Local scalars */
00074     char uplo, uplo_i;
00075     lapack_int n, n_i;
00076     lapack_int nrhs, nrhs_i;
00077     lapack_int lda, lda_i;
00078     lapack_int lda_r;
00079     lapack_int ldaf, ldaf_i;
00080     lapack_int ldaf_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     lapack_complex_float *a = NULL, *a_i = NULL;
00091     lapack_complex_float *af = NULL, *af_i = NULL;
00092     lapack_int *ipiv = NULL, *ipiv_i = NULL;
00093     lapack_complex_float *b = NULL, *b_i = NULL;
00094     lapack_complex_float *x = NULL, *x_i = NULL;
00095     float *ferr = NULL, *ferr_i = NULL;
00096     float *berr = NULL, *berr_i = NULL;
00097     lapack_complex_float *work = NULL, *work_i = NULL;
00098     float *rwork = NULL, *rwork_i = NULL;
00099     lapack_complex_float *x_save = NULL;
00100     float *ferr_save = NULL;
00101     float *berr_save = NULL;
00102     lapack_complex_float *a_r = NULL;
00103     lapack_complex_float *af_r = NULL;
00104     lapack_complex_float *b_r = NULL;
00105     lapack_complex_float *x_r = NULL;
00106 
00107     /* Iniitialize the scalar parameters */
00108     init_scalars_cherfs( &uplo, &n, &nrhs, &lda, &ldaf, &ldb, &ldx );
00109     lda_r = n+2;
00110     ldaf_r = n+2;
00111     ldb_r = nrhs+2;
00112     ldx_r = nrhs+2;
00113     uplo_i = uplo;
00114     n_i = n;
00115     nrhs_i = nrhs;
00116     lda_i = lda;
00117     ldaf_i = ldaf;
00118     ldb_i = ldb;
00119     ldx_i = ldx;
00120 
00121     /* Allocate memory for the LAPACK routine arrays */
00122     a = (lapack_complex_float *)
00123         LAPACKE_malloc( lda*n * sizeof(lapack_complex_float) );
00124     af = (lapack_complex_float *)
00125         LAPACKE_malloc( ldaf*n * sizeof(lapack_complex_float) );
00126     ipiv = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
00127     b = (lapack_complex_float *)
00128         LAPACKE_malloc( ldb*nrhs * sizeof(lapack_complex_float) );
00129     x = (lapack_complex_float *)
00130         LAPACKE_malloc( ldx*nrhs * sizeof(lapack_complex_float) );
00131     ferr = (float *)LAPACKE_malloc( nrhs * sizeof(float) );
00132     berr = (float *)LAPACKE_malloc( nrhs * sizeof(float) );
00133     work = (lapack_complex_float *)
00134         LAPACKE_malloc( 2*n * sizeof(lapack_complex_float) );
00135     rwork = (float *)LAPACKE_malloc( n * sizeof(float) );
00136 
00137     /* Allocate memory for the C interface function arrays */
00138     a_i = (lapack_complex_float *)
00139         LAPACKE_malloc( lda*n * sizeof(lapack_complex_float) );
00140     af_i = (lapack_complex_float *)
00141         LAPACKE_malloc( ldaf*n * sizeof(lapack_complex_float) );
00142     ipiv_i = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
00143     b_i = (lapack_complex_float *)
00144         LAPACKE_malloc( ldb*nrhs * sizeof(lapack_complex_float) );
00145     x_i = (lapack_complex_float *)
00146         LAPACKE_malloc( ldx*nrhs * sizeof(lapack_complex_float) );
00147     ferr_i = (float *)LAPACKE_malloc( nrhs * sizeof(float) );
00148     berr_i = (float *)LAPACKE_malloc( nrhs * sizeof(float) );
00149     work_i = (lapack_complex_float *)
00150         LAPACKE_malloc( 2*n * sizeof(lapack_complex_float) );
00151     rwork_i = (float *)LAPACKE_malloc( n * sizeof(float) );
00152 
00153     /* Allocate memory for the backup arrays */
00154     x_save = (lapack_complex_float *)
00155         LAPACKE_malloc( ldx*nrhs * sizeof(lapack_complex_float) );
00156     ferr_save = (float *)LAPACKE_malloc( nrhs * sizeof(float) );
00157     berr_save = (float *)LAPACKE_malloc( nrhs * sizeof(float) );
00158 
00159     /* Allocate memory for the row-major arrays */
00160     a_r = (lapack_complex_float *)
00161         LAPACKE_malloc( n*(n+2) * sizeof(lapack_complex_float) );
00162     af_r = (lapack_complex_float *)
00163         LAPACKE_malloc( n*(n+2) * sizeof(lapack_complex_float) );
00164     b_r = (lapack_complex_float *)
00165         LAPACKE_malloc( n*(nrhs+2) * sizeof(lapack_complex_float) );
00166     x_r = (lapack_complex_float *)
00167         LAPACKE_malloc( n*(nrhs+2) * sizeof(lapack_complex_float) );
00168 
00169     /* Initialize input arrays */
00170     init_a( lda*n, a );
00171     init_af( ldaf*n, af );
00172     init_ipiv( n, ipiv );
00173     init_b( ldb*nrhs, b );
00174     init_x( ldx*nrhs, x );
00175     init_ferr( nrhs, ferr );
00176     init_berr( nrhs, berr );
00177     init_work( 2*n, work );
00178     init_rwork( n, rwork );
00179 
00180     /* Backup the ouptut arrays */
00181     for( i = 0; i < ldx*nrhs; i++ ) {
00182         x_save[i] = x[i];
00183     }
00184     for( i = 0; i < nrhs; i++ ) {
00185         ferr_save[i] = ferr[i];
00186     }
00187     for( i = 0; i < nrhs; i++ ) {
00188         berr_save[i] = berr[i];
00189     }
00190 
00191     /* Call the LAPACK routine */
00192     cherfs_( &uplo, &n, &nrhs, a, &lda, af, &ldaf, ipiv, b, &ldb, x, &ldx, ferr,
00193              berr, work, rwork, &info );
00194 
00195     /* Initialize input data, call the column-major middle-level
00196      * interface to LAPACK routine and check the results */
00197     for( i = 0; i < lda*n; i++ ) {
00198         a_i[i] = a[i];
00199     }
00200     for( i = 0; i < ldaf*n; i++ ) {
00201         af_i[i] = af[i];
00202     }
00203     for( i = 0; i < n; i++ ) {
00204         ipiv_i[i] = ipiv[i];
00205     }
00206     for( i = 0; i < ldb*nrhs; i++ ) {
00207         b_i[i] = b[i];
00208     }
00209     for( i = 0; i < ldx*nrhs; i++ ) {
00210         x_i[i] = x_save[i];
00211     }
00212     for( i = 0; i < nrhs; i++ ) {
00213         ferr_i[i] = ferr_save[i];
00214     }
00215     for( i = 0; i < nrhs; i++ ) {
00216         berr_i[i] = berr_save[i];
00217     }
00218     for( i = 0; i < 2*n; i++ ) {
00219         work_i[i] = work[i];
00220     }
00221     for( i = 0; i < n; i++ ) {
00222         rwork_i[i] = rwork[i];
00223     }
00224     info_i = LAPACKE_cherfs_work( LAPACK_COL_MAJOR, uplo_i, n_i, nrhs_i, a_i,
00225                                   lda_i, af_i, ldaf_i, ipiv_i, b_i, ldb_i, x_i,
00226                                   ldx_i, ferr_i, berr_i, work_i, rwork_i );
00227 
00228     failed = compare_cherfs( x, x_i, ferr, ferr_i, berr, berr_i, info, info_i,
00229                              ldx, nrhs );
00230     if( failed == 0 ) {
00231         printf( "PASSED: column-major middle-level interface to cherfs\n" );
00232     } else {
00233         printf( "FAILED: column-major middle-level interface to cherfs\n" );
00234     }
00235 
00236     /* Initialize input data, call the column-major high-level
00237      * interface to LAPACK routine and check the results */
00238     for( i = 0; i < lda*n; i++ ) {
00239         a_i[i] = a[i];
00240     }
00241     for( i = 0; i < ldaf*n; i++ ) {
00242         af_i[i] = af[i];
00243     }
00244     for( i = 0; i < n; i++ ) {
00245         ipiv_i[i] = ipiv[i];
00246     }
00247     for( i = 0; i < ldb*nrhs; i++ ) {
00248         b_i[i] = b[i];
00249     }
00250     for( i = 0; i < ldx*nrhs; i++ ) {
00251         x_i[i] = x_save[i];
00252     }
00253     for( i = 0; i < nrhs; i++ ) {
00254         ferr_i[i] = ferr_save[i];
00255     }
00256     for( i = 0; i < nrhs; i++ ) {
00257         berr_i[i] = berr_save[i];
00258     }
00259     for( i = 0; i < 2*n; i++ ) {
00260         work_i[i] = work[i];
00261     }
00262     for( i = 0; i < n; i++ ) {
00263         rwork_i[i] = rwork[i];
00264     }
00265     info_i = LAPACKE_cherfs( LAPACK_COL_MAJOR, uplo_i, n_i, nrhs_i, a_i, lda_i,
00266                              af_i, ldaf_i, ipiv_i, b_i, ldb_i, x_i, ldx_i,
00267                              ferr_i, berr_i );
00268 
00269     failed = compare_cherfs( x, x_i, ferr, ferr_i, berr, berr_i, info, info_i,
00270                              ldx, nrhs );
00271     if( failed == 0 ) {
00272         printf( "PASSED: column-major high-level interface to cherfs\n" );
00273     } else {
00274         printf( "FAILED: column-major high-level interface to cherfs\n" );
00275     }
00276 
00277     /* Initialize input data, call the row-major middle-level
00278      * interface to LAPACK routine and check the results */
00279     for( i = 0; i < lda*n; i++ ) {
00280         a_i[i] = a[i];
00281     }
00282     for( i = 0; i < ldaf*n; i++ ) {
00283         af_i[i] = af[i];
00284     }
00285     for( i = 0; i < n; i++ ) {
00286         ipiv_i[i] = ipiv[i];
00287     }
00288     for( i = 0; i < ldb*nrhs; i++ ) {
00289         b_i[i] = b[i];
00290     }
00291     for( i = 0; i < ldx*nrhs; i++ ) {
00292         x_i[i] = x_save[i];
00293     }
00294     for( i = 0; i < nrhs; i++ ) {
00295         ferr_i[i] = ferr_save[i];
00296     }
00297     for( i = 0; i < nrhs; i++ ) {
00298         berr_i[i] = berr_save[i];
00299     }
00300     for( i = 0; i < 2*n; i++ ) {
00301         work_i[i] = work[i];
00302     }
00303     for( i = 0; i < n; i++ ) {
00304         rwork_i[i] = rwork[i];
00305     }
00306 
00307     LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, n, a_i, lda, a_r, n+2 );
00308     LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, n, af_i, ldaf, af_r, n+2 );
00309     LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, nrhs, b_i, ldb, b_r, nrhs+2 );
00310     LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, nrhs, x_i, ldx, x_r, nrhs+2 );
00311     info_i = LAPACKE_cherfs_work( LAPACK_ROW_MAJOR, uplo_i, n_i, nrhs_i, a_r,
00312                                   lda_r, af_r, ldaf_r, ipiv_i, b_r, ldb_r, x_r,
00313                                   ldx_r, ferr_i, berr_i, work_i, rwork_i );
00314 
00315     LAPACKE_cge_trans( LAPACK_ROW_MAJOR, n, nrhs, x_r, nrhs+2, x_i, ldx );
00316 
00317     failed = compare_cherfs( x, x_i, ferr, ferr_i, berr, berr_i, info, info_i,
00318                              ldx, nrhs );
00319     if( failed == 0 ) {
00320         printf( "PASSED: row-major middle-level interface to cherfs\n" );
00321     } else {
00322         printf( "FAILED: row-major middle-level interface to cherfs\n" );
00323     }
00324 
00325     /* Initialize input data, call the row-major high-level
00326      * interface to LAPACK routine and check the results */
00327     for( i = 0; i < lda*n; i++ ) {
00328         a_i[i] = a[i];
00329     }
00330     for( i = 0; i < ldaf*n; i++ ) {
00331         af_i[i] = af[i];
00332     }
00333     for( i = 0; i < n; i++ ) {
00334         ipiv_i[i] = ipiv[i];
00335     }
00336     for( i = 0; i < ldb*nrhs; i++ ) {
00337         b_i[i] = b[i];
00338     }
00339     for( i = 0; i < ldx*nrhs; i++ ) {
00340         x_i[i] = x_save[i];
00341     }
00342     for( i = 0; i < nrhs; i++ ) {
00343         ferr_i[i] = ferr_save[i];
00344     }
00345     for( i = 0; i < nrhs; i++ ) {
00346         berr_i[i] = berr_save[i];
00347     }
00348     for( i = 0; i < 2*n; i++ ) {
00349         work_i[i] = work[i];
00350     }
00351     for( i = 0; i < n; i++ ) {
00352         rwork_i[i] = rwork[i];
00353     }
00354 
00355     /* Init row_major arrays */
00356     LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, n, a_i, lda, a_r, n+2 );
00357     LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, n, af_i, ldaf, af_r, n+2 );
00358     LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, nrhs, b_i, ldb, b_r, nrhs+2 );
00359     LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, nrhs, x_i, ldx, x_r, nrhs+2 );
00360     info_i = LAPACKE_cherfs( LAPACK_ROW_MAJOR, uplo_i, n_i, nrhs_i, a_r, lda_r,
00361                              af_r, ldaf_r, ipiv_i, b_r, ldb_r, x_r, ldx_r,
00362                              ferr_i, berr_i );
00363 
00364     LAPACKE_cge_trans( LAPACK_ROW_MAJOR, n, nrhs, x_r, nrhs+2, x_i, ldx );
00365 
00366     failed = compare_cherfs( x, x_i, ferr, ferr_i, berr, berr_i, info, info_i,
00367                              ldx, nrhs );
00368     if( failed == 0 ) {
00369         printf( "PASSED: row-major high-level interface to cherfs\n" );
00370     } else {
00371         printf( "FAILED: row-major high-level interface to cherfs\n" );
00372     }
00373 
00374     /* Release memory */
00375     if( a != NULL ) {
00376         LAPACKE_free( a );
00377     }
00378     if( a_i != NULL ) {
00379         LAPACKE_free( a_i );
00380     }
00381     if( a_r != NULL ) {
00382         LAPACKE_free( a_r );
00383     }
00384     if( af != NULL ) {
00385         LAPACKE_free( af );
00386     }
00387     if( af_i != NULL ) {
00388         LAPACKE_free( af_i );
00389     }
00390     if( af_r != NULL ) {
00391         LAPACKE_free( af_r );
00392     }
00393     if( ipiv != NULL ) {
00394         LAPACKE_free( ipiv );
00395     }
00396     if( ipiv_i != NULL ) {
00397         LAPACKE_free( ipiv_i );
00398     }
00399     if( b != NULL ) {
00400         LAPACKE_free( b );
00401     }
00402     if( b_i != NULL ) {
00403         LAPACKE_free( b_i );
00404     }
00405     if( b_r != NULL ) {
00406         LAPACKE_free( b_r );
00407     }
00408     if( x != NULL ) {
00409         LAPACKE_free( x );
00410     }
00411     if( x_i != NULL ) {
00412         LAPACKE_free( x_i );
00413     }
00414     if( x_r != NULL ) {
00415         LAPACKE_free( x_r );
00416     }
00417     if( x_save != NULL ) {
00418         LAPACKE_free( x_save );
00419     }
00420     if( ferr != NULL ) {
00421         LAPACKE_free( ferr );
00422     }
00423     if( ferr_i != NULL ) {
00424         LAPACKE_free( ferr_i );
00425     }
00426     if( ferr_save != NULL ) {
00427         LAPACKE_free( ferr_save );
00428     }
00429     if( berr != NULL ) {
00430         LAPACKE_free( berr );
00431     }
00432     if( berr_i != NULL ) {
00433         LAPACKE_free( berr_i );
00434     }
00435     if( berr_save != NULL ) {
00436         LAPACKE_free( berr_save );
00437     }
00438     if( work != NULL ) {
00439         LAPACKE_free( work );
00440     }
00441     if( work_i != NULL ) {
00442         LAPACKE_free( work_i );
00443     }
00444     if( rwork != NULL ) {
00445         LAPACKE_free( rwork );
00446     }
00447     if( rwork_i != NULL ) {
00448         LAPACKE_free( rwork_i );
00449     }
00450 
00451     return 0;
00452 }
00453 
00454 /* Auxiliary function: cherfs scalar parameters initialization */
00455 static void init_scalars_cherfs( char *uplo, lapack_int *n, lapack_int *nrhs,
00456                                  lapack_int *lda, lapack_int *ldaf,
00457                                  lapack_int *ldb, lapack_int *ldx )
00458 {
00459     *uplo = 'L';
00460     *n = 4;
00461     *nrhs = 2;
00462     *lda = 8;
00463     *ldaf = 8;
00464     *ldb = 8;
00465     *ldx = 8;
00466 
00467     return;
00468 }
00469 
00470 /* Auxiliary functions: cherfs array parameters initialization */
00471 static void init_a( lapack_int size, lapack_complex_float *a ) {
00472     lapack_int i;
00473     for( i = 0; i < size; i++ ) {
00474         a[i] = lapack_make_complex_float( 0.0f, 0.0f );
00475     }
00476     a[0] = lapack_make_complex_float( -1.360000014e+000, 0.000000000e+000 );
00477     a[8] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00478     a[16] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00479     a[24] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00480     a[1] = lapack_make_complex_float( 1.580000043e+000, -8.999999762e-001 );
00481     a[9] = lapack_make_complex_float( -8.869999886e+000, 0.000000000e+000 );
00482     a[17] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00483     a[25] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00484     a[2] = lapack_make_complex_float( 2.210000038e+000, 2.099999934e-001 );
00485     a[10] = lapack_make_complex_float( -1.840000033e+000, 2.999999933e-002 );
00486     a[18] = lapack_make_complex_float( -4.630000114e+000, 0.000000000e+000 );
00487     a[26] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00488     a[3] = lapack_make_complex_float( 3.910000086e+000, -1.500000000e+000 );
00489     a[11] = lapack_make_complex_float( -1.779999971e+000, -1.179999948e+000 );
00490     a[19] = lapack_make_complex_float( 1.099999994e-001, -1.099999994e-001 );
00491     a[27] = lapack_make_complex_float( -1.840000033e+000, 0.000000000e+000 );
00492 }
00493 static void init_af( lapack_int size, lapack_complex_float *af ) {
00494     lapack_int i;
00495     for( i = 0; i < size; i++ ) {
00496         af[i] = lapack_make_complex_float( 0.0f, 0.0f );
00497     }
00498     af[0] = lapack_make_complex_float( -1.360000014e+000, 0.000000000e+000 );
00499     af[8] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00500     af[16] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00501     af[24] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00502     af[1] = lapack_make_complex_float( 3.910000086e+000, -1.500000000e+000 );
00503     af[9] = lapack_make_complex_float( -1.840000033e+000, 0.000000000e+000 );
00504     af[17] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00505     af[25] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00506     af[2] = lapack_make_complex_float( 3.100287914e-001, 4.333020747e-002 );
00507     af[10] = lapack_make_complex_float( 5.637050867e-001, 2.850349545e-001 );
00508     af[18] = lapack_make_complex_float( -5.417624474e+000, 0.000000000e+000 );
00509     af[26] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00510     af[3] = lapack_make_complex_float( -1.518120319e-001, 3.742958307e-001 );
00511     af[11] = lapack_make_complex_float( 3.396582901e-001, 3.031452000e-002 );
00512     af[19] = lapack_make_complex_float( 2.997244596e-001, 1.578268409e-001 );
00513     af[27] = lapack_make_complex_float( -7.102809906e+000, 0.000000000e+000 );
00514 }
00515 static void init_ipiv( lapack_int size, lapack_int *ipiv ) {
00516     lapack_int i;
00517     for( i = 0; i < size; i++ ) {
00518         ipiv[i] = 0;
00519     }
00520     ipiv[0] = -4;
00521     ipiv[1] = -4;
00522     ipiv[2] = 3;
00523     ipiv[3] = 4;
00524 }
00525 static void init_b( lapack_int size, lapack_complex_float *b ) {
00526     lapack_int i;
00527     for( i = 0; i < size; i++ ) {
00528         b[i] = lapack_make_complex_float( 0.0f, 0.0f );
00529     }
00530     b[0] = lapack_make_complex_float( 7.789999962e+000, 5.480000019e+000 );
00531     b[8] = lapack_make_complex_float( -3.538999939e+001, 1.801000023e+001 );
00532     b[1] = lapack_make_complex_float( -7.699999809e-001, -1.604999924e+001 );
00533     b[9] = lapack_make_complex_float( 4.230000019e+000, -7.001999664e+001 );
00534     b[2] = lapack_make_complex_float( -9.579999924e+000, 3.880000114e+000 );
00535     b[10] = lapack_make_complex_float( -2.479000092e+001, -8.399999619e+000 );
00536     b[3] = lapack_make_complex_float( 2.980000019e+000, -1.018000031e+001 );
00537     b[11] = lapack_make_complex_float( 2.868000031e+001, -3.988999939e+001 );
00538 }
00539 static void init_x( lapack_int size, lapack_complex_float *x ) {
00540     lapack_int i;
00541     for( i = 0; i < size; i++ ) {
00542         x[i] = lapack_make_complex_float( 0.0f, 0.0f );
00543     }
00544     x[0] = lapack_make_complex_float( 9.999998808e-001, -1.000000000e+000 );
00545     x[8] = lapack_make_complex_float( 3.000000000e+000, -4.000000000e+000 );
00546     x[1] = lapack_make_complex_float( -1.000000000e+000, 1.999999881e+000 );
00547     x[9] = lapack_make_complex_float( -9.999999404e-001, 4.999999046e+000 );
00548     x[2] = lapack_make_complex_float( 3.000000000e+000, -2.000000000e+000 );
00549     x[10] = lapack_make_complex_float( 7.000000000e+000, -2.000000000e+000 );
00550     x[3] = lapack_make_complex_float( 1.999999881e+000, 1.000000238e+000 );
00551     x[11] = lapack_make_complex_float( -8.000000000e+000, 6.000000000e+000 );
00552 }
00553 static void init_ferr( lapack_int size, float *ferr ) {
00554     lapack_int i;
00555     for( i = 0; i < size; i++ ) {
00556         ferr[i] = 0;
00557     }
00558 }
00559 static void init_berr( lapack_int size, float *berr ) {
00560     lapack_int i;
00561     for( i = 0; i < size; i++ ) {
00562         berr[i] = 0;
00563     }
00564 }
00565 static void init_work( lapack_int size, lapack_complex_float *work ) {
00566     lapack_int i;
00567     for( i = 0; i < size; i++ ) {
00568         work[i] = lapack_make_complex_float( 0.0f, 0.0f );
00569     }
00570 }
00571 static void init_rwork( lapack_int size, float *rwork ) {
00572     lapack_int i;
00573     for( i = 0; i < size; i++ ) {
00574         rwork[i] = 0;
00575     }
00576 }
00577 
00578 /* Auxiliary function: C interface to cherfs results check */
00579 /* Return value: 0 - test is passed, non-zero - test is failed */
00580 static int compare_cherfs( lapack_complex_float *x, lapack_complex_float *x_i,
00581                            float *ferr, float *ferr_i, float *berr,
00582                            float *berr_i, lapack_int info, lapack_int info_i,
00583                            lapack_int ldx, lapack_int nrhs )
00584 {
00585     lapack_int i;
00586     int failed = 0;
00587     for( i = 0; i < ldx*nrhs; i++ ) {
00588         failed += compare_complex_floats(x[i],x_i[i]);
00589     }
00590     for( i = 0; i < nrhs; i++ ) {
00591         failed += compare_floats(ferr[i],ferr_i[i]);
00592     }
00593     for( i = 0; i < nrhs; i++ ) {
00594         failed += compare_floats(berr[i],berr_i[i]);
00595     }
00596     failed += (info == info_i) ? 0 : 1;
00597     if( info != 0 || info_i != 0 ) {
00598         printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00599     }
00600 
00601     return failed;
00602 }


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