cgbrfs_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 * cgbrfs_1 is the test program for the C interface to LAPACK
00036 * routine cgbrfs
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_cgbrfs( char *trans, lapack_int *n, lapack_int *kl,
00055                                  lapack_int *ku, lapack_int *nrhs,
00056                                  lapack_int *ldab, lapack_int *ldafb,
00057                                  lapack_int *ldb, lapack_int *ldx );
00058 static void init_ab( lapack_int size, lapack_complex_float *ab );
00059 static void init_afb( lapack_int size, lapack_complex_float *afb );
00060 static void init_ipiv( lapack_int size, lapack_int *ipiv );
00061 static void init_b( lapack_int size, lapack_complex_float *b );
00062 static void init_x( lapack_int size, lapack_complex_float *x );
00063 static void init_ferr( lapack_int size, float *ferr );
00064 static void init_berr( lapack_int size, float *berr );
00065 static void init_work( lapack_int size, lapack_complex_float *work );
00066 static void init_rwork( lapack_int size, float *rwork );
00067 static int compare_cgbrfs( lapack_complex_float *x, lapack_complex_float *x_i,
00068                            float *ferr, float *ferr_i, float *berr,
00069                            float *berr_i, lapack_int info, lapack_int info_i,
00070                            lapack_int ldx, lapack_int nrhs );
00071 
00072 int main(void)
00073 {
00074     /* Local scalars */
00075     char trans, trans_i;
00076     lapack_int n, n_i;
00077     lapack_int kl, kl_i;
00078     lapack_int ku, ku_i;
00079     lapack_int nrhs, nrhs_i;
00080     lapack_int ldab, ldab_i;
00081     lapack_int ldab_r;
00082     lapack_int ldafb, ldafb_i;
00083     lapack_int ldafb_r;
00084     lapack_int ldb, ldb_i;
00085     lapack_int ldb_r;
00086     lapack_int ldx, ldx_i;
00087     lapack_int ldx_r;
00088     lapack_int info, info_i;
00089     lapack_int i;
00090     int failed;
00091 
00092     /* Local arrays */
00093     lapack_complex_float *ab = NULL, *ab_i = NULL;
00094     lapack_complex_float *afb = NULL, *afb_i = NULL;
00095     lapack_int *ipiv = NULL, *ipiv_i = NULL;
00096     lapack_complex_float *b = NULL, *b_i = NULL;
00097     lapack_complex_float *x = NULL, *x_i = NULL;
00098     float *ferr = NULL, *ferr_i = NULL;
00099     float *berr = NULL, *berr_i = NULL;
00100     lapack_complex_float *work = NULL, *work_i = NULL;
00101     float *rwork = NULL, *rwork_i = NULL;
00102     lapack_complex_float *x_save = NULL;
00103     float *ferr_save = NULL;
00104     float *berr_save = NULL;
00105     lapack_complex_float *ab_r = NULL;
00106     lapack_complex_float *afb_r = NULL;
00107     lapack_complex_float *b_r = NULL;
00108     lapack_complex_float *x_r = NULL;
00109 
00110     /* Iniitialize the scalar parameters */
00111     init_scalars_cgbrfs( &trans, &n, &kl, &ku, &nrhs, &ldab, &ldafb, &ldb,
00112                          &ldx );
00113     ldab_r = n+2;
00114     ldafb_r = n+2;
00115     ldb_r = nrhs+2;
00116     ldx_r = nrhs+2;
00117     trans_i = trans;
00118     n_i = n;
00119     kl_i = kl;
00120     ku_i = ku;
00121     nrhs_i = nrhs;
00122     ldab_i = ldab;
00123     ldafb_i = ldafb;
00124     ldb_i = ldb;
00125     ldx_i = ldx;
00126 
00127     /* Allocate memory for the LAPACK routine arrays */
00128     ab = (lapack_complex_float *)
00129         LAPACKE_malloc( ldab*n * sizeof(lapack_complex_float) );
00130     afb = (lapack_complex_float *)
00131         LAPACKE_malloc( ldafb*n * sizeof(lapack_complex_float) );
00132     ipiv = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
00133     b = (lapack_complex_float *)
00134         LAPACKE_malloc( ldb*nrhs * sizeof(lapack_complex_float) );
00135     x = (lapack_complex_float *)
00136         LAPACKE_malloc( ldx*nrhs * sizeof(lapack_complex_float) );
00137     ferr = (float *)LAPACKE_malloc( nrhs * sizeof(float) );
00138     berr = (float *)LAPACKE_malloc( nrhs * sizeof(float) );
00139     work = (lapack_complex_float *)
00140         LAPACKE_malloc( 2*n * sizeof(lapack_complex_float) );
00141     rwork = (float *)LAPACKE_malloc( n * sizeof(float) );
00142 
00143     /* Allocate memory for the C interface function arrays */
00144     ab_i = (lapack_complex_float *)
00145         LAPACKE_malloc( ldab*n * sizeof(lapack_complex_float) );
00146     afb_i = (lapack_complex_float *)
00147         LAPACKE_malloc( ldafb*n * sizeof(lapack_complex_float) );
00148     ipiv_i = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
00149     b_i = (lapack_complex_float *)
00150         LAPACKE_malloc( ldb*nrhs * sizeof(lapack_complex_float) );
00151     x_i = (lapack_complex_float *)
00152         LAPACKE_malloc( ldx*nrhs * sizeof(lapack_complex_float) );
00153     ferr_i = (float *)LAPACKE_malloc( nrhs * sizeof(float) );
00154     berr_i = (float *)LAPACKE_malloc( nrhs * sizeof(float) );
00155     work_i = (lapack_complex_float *)
00156         LAPACKE_malloc( 2*n * sizeof(lapack_complex_float) );
00157     rwork_i = (float *)LAPACKE_malloc( n * sizeof(float) );
00158 
00159     /* Allocate memory for the backup arrays */
00160     x_save = (lapack_complex_float *)
00161         LAPACKE_malloc( ldx*nrhs * sizeof(lapack_complex_float) );
00162     ferr_save = (float *)LAPACKE_malloc( nrhs * sizeof(float) );
00163     berr_save = (float *)LAPACKE_malloc( nrhs * sizeof(float) );
00164 
00165     /* Allocate memory for the row-major arrays */
00166     ab_r = (lapack_complex_float *)
00167         LAPACKE_malloc( (kl+ku+1)*(n+2) * sizeof(lapack_complex_float) );
00168     afb_r = (lapack_complex_float *)
00169         LAPACKE_malloc( ((2*kl+ku+1)*(n+2)) * sizeof(lapack_complex_float) );
00170     b_r = (lapack_complex_float *)
00171         LAPACKE_malloc( n*(nrhs+2) * sizeof(lapack_complex_float) );
00172     x_r = (lapack_complex_float *)
00173         LAPACKE_malloc( n*(nrhs+2) * sizeof(lapack_complex_float) );
00174 
00175     /* Initialize input arrays */
00176     init_ab( ldab*n, ab );
00177     init_afb( ldafb*n, afb );
00178     init_ipiv( n, ipiv );
00179     init_b( ldb*nrhs, b );
00180     init_x( ldx*nrhs, x );
00181     init_ferr( nrhs, ferr );
00182     init_berr( nrhs, berr );
00183     init_work( 2*n, work );
00184     init_rwork( n, rwork );
00185 
00186     /* Backup the ouptut arrays */
00187     for( i = 0; i < ldx*nrhs; i++ ) {
00188         x_save[i] = x[i];
00189     }
00190     for( i = 0; i < nrhs; i++ ) {
00191         ferr_save[i] = ferr[i];
00192     }
00193     for( i = 0; i < nrhs; i++ ) {
00194         berr_save[i] = berr[i];
00195     }
00196 
00197     /* Call the LAPACK routine */
00198     cgbrfs_( &trans, &n, &kl, &ku, &nrhs, ab, &ldab, afb, &ldafb, ipiv, b, &ldb,
00199              x, &ldx, ferr, berr, work, rwork, &info );
00200 
00201     /* Initialize input data, call the column-major middle-level
00202      * interface to LAPACK routine and check the results */
00203     for( i = 0; i < ldab*n; i++ ) {
00204         ab_i[i] = ab[i];
00205     }
00206     for( i = 0; i < ldafb*n; i++ ) {
00207         afb_i[i] = afb[i];
00208     }
00209     for( i = 0; i < n; i++ ) {
00210         ipiv_i[i] = ipiv[i];
00211     }
00212     for( i = 0; i < ldb*nrhs; i++ ) {
00213         b_i[i] = b[i];
00214     }
00215     for( i = 0; i < ldx*nrhs; i++ ) {
00216         x_i[i] = x_save[i];
00217     }
00218     for( i = 0; i < nrhs; i++ ) {
00219         ferr_i[i] = ferr_save[i];
00220     }
00221     for( i = 0; i < nrhs; i++ ) {
00222         berr_i[i] = berr_save[i];
00223     }
00224     for( i = 0; i < 2*n; i++ ) {
00225         work_i[i] = work[i];
00226     }
00227     for( i = 0; i < n; i++ ) {
00228         rwork_i[i] = rwork[i];
00229     }
00230     info_i = LAPACKE_cgbrfs_work( LAPACK_COL_MAJOR, trans_i, n_i, kl_i, ku_i,
00231                                   nrhs_i, ab_i, ldab_i, afb_i, ldafb_i, ipiv_i,
00232                                   b_i, ldb_i, x_i, ldx_i, ferr_i, berr_i,
00233                                   work_i, rwork_i );
00234 
00235     failed = compare_cgbrfs( x, x_i, ferr, ferr_i, berr, berr_i, info, info_i,
00236                              ldx, nrhs );
00237     if( failed == 0 ) {
00238         printf( "PASSED: column-major middle-level interface to cgbrfs\n" );
00239     } else {
00240         printf( "FAILED: column-major middle-level interface to cgbrfs\n" );
00241     }
00242 
00243     /* Initialize input data, call the column-major high-level
00244      * interface to LAPACK routine and check the results */
00245     for( i = 0; i < ldab*n; i++ ) {
00246         ab_i[i] = ab[i];
00247     }
00248     for( i = 0; i < ldafb*n; i++ ) {
00249         afb_i[i] = afb[i];
00250     }
00251     for( i = 0; i < n; i++ ) {
00252         ipiv_i[i] = ipiv[i];
00253     }
00254     for( i = 0; i < ldb*nrhs; i++ ) {
00255         b_i[i] = b[i];
00256     }
00257     for( i = 0; i < ldx*nrhs; i++ ) {
00258         x_i[i] = x_save[i];
00259     }
00260     for( i = 0; i < nrhs; i++ ) {
00261         ferr_i[i] = ferr_save[i];
00262     }
00263     for( i = 0; i < nrhs; i++ ) {
00264         berr_i[i] = berr_save[i];
00265     }
00266     for( i = 0; i < 2*n; i++ ) {
00267         work_i[i] = work[i];
00268     }
00269     for( i = 0; i < n; i++ ) {
00270         rwork_i[i] = rwork[i];
00271     }
00272     info_i = LAPACKE_cgbrfs( LAPACK_COL_MAJOR, trans_i, n_i, kl_i, ku_i, nrhs_i,
00273                              ab_i, ldab_i, afb_i, ldafb_i, ipiv_i, b_i, ldb_i,
00274                              x_i, ldx_i, ferr_i, berr_i );
00275 
00276     failed = compare_cgbrfs( x, x_i, ferr, ferr_i, berr, berr_i, info, info_i,
00277                              ldx, nrhs );
00278     if( failed == 0 ) {
00279         printf( "PASSED: column-major high-level interface to cgbrfs\n" );
00280     } else {
00281         printf( "FAILED: column-major high-level interface to cgbrfs\n" );
00282     }
00283 
00284     /* Initialize input data, call the row-major middle-level
00285      * interface to LAPACK routine and check the results */
00286     for( i = 0; i < ldab*n; i++ ) {
00287         ab_i[i] = ab[i];
00288     }
00289     for( i = 0; i < ldafb*n; i++ ) {
00290         afb_i[i] = afb[i];
00291     }
00292     for( i = 0; i < n; i++ ) {
00293         ipiv_i[i] = ipiv[i];
00294     }
00295     for( i = 0; i < ldb*nrhs; i++ ) {
00296         b_i[i] = b[i];
00297     }
00298     for( i = 0; i < ldx*nrhs; i++ ) {
00299         x_i[i] = x_save[i];
00300     }
00301     for( i = 0; i < nrhs; i++ ) {
00302         ferr_i[i] = ferr_save[i];
00303     }
00304     for( i = 0; i < nrhs; i++ ) {
00305         berr_i[i] = berr_save[i];
00306     }
00307     for( i = 0; i < 2*n; i++ ) {
00308         work_i[i] = work[i];
00309     }
00310     for( i = 0; i < n; i++ ) {
00311         rwork_i[i] = rwork[i];
00312     }
00313 
00314     LAPACKE_cge_trans( LAPACK_COL_MAJOR, kl+ku+1, n, ab_i, ldab, ab_r, n+2 );
00315     LAPACKE_cge_trans( LAPACK_COL_MAJOR, 2*kl+ku+1, n, afb_i, ldafb, afb_r,
00316                        n+2 );
00317     LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, nrhs, b_i, ldb, b_r, nrhs+2 );
00318     LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, nrhs, x_i, ldx, x_r, nrhs+2 );
00319     info_i = LAPACKE_cgbrfs_work( LAPACK_ROW_MAJOR, trans_i, n_i, kl_i, ku_i,
00320                                   nrhs_i, ab_r, ldab_r, afb_r, ldafb_r, ipiv_i,
00321                                   b_r, ldb_r, x_r, ldx_r, ferr_i, berr_i,
00322                                   work_i, rwork_i );
00323 
00324     LAPACKE_cge_trans( LAPACK_ROW_MAJOR, n, nrhs, x_r, nrhs+2, x_i, ldx );
00325 
00326     failed = compare_cgbrfs( x, x_i, ferr, ferr_i, berr, berr_i, info, info_i,
00327                              ldx, nrhs );
00328     if( failed == 0 ) {
00329         printf( "PASSED: row-major middle-level interface to cgbrfs\n" );
00330     } else {
00331         printf( "FAILED: row-major middle-level interface to cgbrfs\n" );
00332     }
00333 
00334     /* Initialize input data, call the row-major high-level
00335      * interface to LAPACK routine and check the results */
00336     for( i = 0; i < ldab*n; i++ ) {
00337         ab_i[i] = ab[i];
00338     }
00339     for( i = 0; i < ldafb*n; i++ ) {
00340         afb_i[i] = afb[i];
00341     }
00342     for( i = 0; i < n; i++ ) {
00343         ipiv_i[i] = ipiv[i];
00344     }
00345     for( i = 0; i < ldb*nrhs; i++ ) {
00346         b_i[i] = b[i];
00347     }
00348     for( i = 0; i < ldx*nrhs; i++ ) {
00349         x_i[i] = x_save[i];
00350     }
00351     for( i = 0; i < nrhs; i++ ) {
00352         ferr_i[i] = ferr_save[i];
00353     }
00354     for( i = 0; i < nrhs; i++ ) {
00355         berr_i[i] = berr_save[i];
00356     }
00357     for( i = 0; i < 2*n; i++ ) {
00358         work_i[i] = work[i];
00359     }
00360     for( i = 0; i < n; i++ ) {
00361         rwork_i[i] = rwork[i];
00362     }
00363 
00364     /* Init row_major arrays */
00365     LAPACKE_cge_trans( LAPACK_COL_MAJOR, kl+ku+1, n, ab_i, ldab, ab_r, n+2 );
00366     LAPACKE_cge_trans( LAPACK_COL_MAJOR, 2*kl+ku+1, n, afb_i, ldafb, afb_r,
00367                        n+2 );
00368     LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, nrhs, b_i, ldb, b_r, nrhs+2 );
00369     LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, nrhs, x_i, ldx, x_r, nrhs+2 );
00370     info_i = LAPACKE_cgbrfs( LAPACK_ROW_MAJOR, trans_i, n_i, kl_i, ku_i, nrhs_i,
00371                              ab_r, ldab_r, afb_r, ldafb_r, ipiv_i, b_r, ldb_r,
00372                              x_r, ldx_r, ferr_i, berr_i );
00373 
00374     LAPACKE_cge_trans( LAPACK_ROW_MAJOR, n, nrhs, x_r, nrhs+2, x_i, ldx );
00375 
00376     failed = compare_cgbrfs( x, x_i, ferr, ferr_i, berr, berr_i, info, info_i,
00377                              ldx, nrhs );
00378     if( failed == 0 ) {
00379         printf( "PASSED: row-major high-level interface to cgbrfs\n" );
00380     } else {
00381         printf( "FAILED: row-major high-level interface to cgbrfs\n" );
00382     }
00383 
00384     /* Release memory */
00385     if( ab != NULL ) {
00386         LAPACKE_free( ab );
00387     }
00388     if( ab_i != NULL ) {
00389         LAPACKE_free( ab_i );
00390     }
00391     if( ab_r != NULL ) {
00392         LAPACKE_free( ab_r );
00393     }
00394     if( afb != NULL ) {
00395         LAPACKE_free( afb );
00396     }
00397     if( afb_i != NULL ) {
00398         LAPACKE_free( afb_i );
00399     }
00400     if( afb_r != NULL ) {
00401         LAPACKE_free( afb_r );
00402     }
00403     if( ipiv != NULL ) {
00404         LAPACKE_free( ipiv );
00405     }
00406     if( ipiv_i != NULL ) {
00407         LAPACKE_free( ipiv_i );
00408     }
00409     if( b != NULL ) {
00410         LAPACKE_free( b );
00411     }
00412     if( b_i != NULL ) {
00413         LAPACKE_free( b_i );
00414     }
00415     if( b_r != NULL ) {
00416         LAPACKE_free( b_r );
00417     }
00418     if( x != NULL ) {
00419         LAPACKE_free( x );
00420     }
00421     if( x_i != NULL ) {
00422         LAPACKE_free( x_i );
00423     }
00424     if( x_r != NULL ) {
00425         LAPACKE_free( x_r );
00426     }
00427     if( x_save != NULL ) {
00428         LAPACKE_free( x_save );
00429     }
00430     if( ferr != NULL ) {
00431         LAPACKE_free( ferr );
00432     }
00433     if( ferr_i != NULL ) {
00434         LAPACKE_free( ferr_i );
00435     }
00436     if( ferr_save != NULL ) {
00437         LAPACKE_free( ferr_save );
00438     }
00439     if( berr != NULL ) {
00440         LAPACKE_free( berr );
00441     }
00442     if( berr_i != NULL ) {
00443         LAPACKE_free( berr_i );
00444     }
00445     if( berr_save != NULL ) {
00446         LAPACKE_free( berr_save );
00447     }
00448     if( work != NULL ) {
00449         LAPACKE_free( work );
00450     }
00451     if( work_i != NULL ) {
00452         LAPACKE_free( work_i );
00453     }
00454     if( rwork != NULL ) {
00455         LAPACKE_free( rwork );
00456     }
00457     if( rwork_i != NULL ) {
00458         LAPACKE_free( rwork_i );
00459     }
00460 
00461     return 0;
00462 }
00463 
00464 /* Auxiliary function: cgbrfs scalar parameters initialization */
00465 static void init_scalars_cgbrfs( char *trans, lapack_int *n, lapack_int *kl,
00466                                  lapack_int *ku, lapack_int *nrhs,
00467                                  lapack_int *ldab, lapack_int *ldafb,
00468                                  lapack_int *ldb, lapack_int *ldx )
00469 {
00470     *trans = 'N';
00471     *n = 4;
00472     *kl = 1;
00473     *ku = 2;
00474     *nrhs = 2;
00475     *ldab = 17;
00476     *ldafb = 25;
00477     *ldb = 8;
00478     *ldx = 8;
00479 
00480     return;
00481 }
00482 
00483 /* Auxiliary functions: cgbrfs array parameters initialization */
00484 static void init_ab( lapack_int size, lapack_complex_float *ab ) {
00485     lapack_int i;
00486     for( i = 0; i < size; i++ ) {
00487         ab[i] = lapack_make_complex_float( 0.0f, 0.0f );
00488     }
00489     ab[0] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00490     ab[17] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00491     ab[34] = lapack_make_complex_float( 9.700000286e-001, -2.839999914e+000 );
00492     ab[51] = lapack_make_complex_float( 5.899999738e-001, -4.799999893e-001 );
00493     ab[1] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00494     ab[18] = lapack_make_complex_float( -2.049999952e+000, -8.500000238e-001 );
00495     ab[35] = lapack_make_complex_float( -3.990000010e+000, 4.010000229e+000 );
00496     ab[52] = lapack_make_complex_float( 3.329999924e+000, -1.039999962e+000 );
00497     ab[2] = lapack_make_complex_float( -1.649999976e+000, 2.259999990e+000 );
00498     ab[19] = lapack_make_complex_float( -1.480000019e+000, -1.750000000e+000 );
00499     ab[36] = lapack_make_complex_float( -1.059999943e+000, 1.940000057e+000 );
00500     ab[53] = lapack_make_complex_float( -4.600000083e-001, -1.720000029e+000 );
00501     ab[3] = lapack_make_complex_float( 0.000000000e+000, 6.300000191e+000 );
00502     ab[20] = lapack_make_complex_float( -7.699999809e-001, 2.829999924e+000 );
00503     ab[37] = lapack_make_complex_float( 4.480000019e+000, -1.090000033e+000 );
00504     ab[54] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00505 }
00506 static void init_afb( lapack_int size, lapack_complex_float *afb ) {
00507     lapack_int i;
00508     for( i = 0; i < size; i++ ) {
00509         afb[i] = lapack_make_complex_float( 0.0f, 0.0f );
00510     }
00511     afb[0] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00512     afb[25] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00513     afb[50] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00514     afb[75] = lapack_make_complex_float( 5.899999738e-001, -4.799999893e-001 );
00515     afb[1] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00516     afb[26] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00517     afb[51] = lapack_make_complex_float( -3.990000010e+000, 4.010000229e+000 );
00518     afb[76] = lapack_make_complex_float( 3.329999924e+000, -1.039999962e+000 );
00519     afb[2] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00520     afb[27] = lapack_make_complex_float( -1.480000019e+000, -1.750000000e+000 );
00521     afb[52] = lapack_make_complex_float( -1.059999943e+000, 1.940000057e+000 );
00522     afb[77] = lapack_make_complex_float( -1.769209266e+000, -1.858747363e+000 );
00523     afb[3] = lapack_make_complex_float( 0.000000000e+000, 6.300000191e+000 );
00524     afb[28] = lapack_make_complex_float( -7.699999809e-001, 2.829999924e+000 );
00525     afb[53] = lapack_make_complex_float( 4.930266857e+000, -3.008563757e+000 );
00526     afb[78] = lapack_make_complex_float( 4.337749183e-001, 1.232528687e-001 );
00527     afb[4] = lapack_make_complex_float( 3.587301373e-001, 2.619047463e-001 );
00528     afb[29] = lapack_make_complex_float( 2.314260751e-001, 6.357648969e-001 );
00529     afb[54] = lapack_make_complex_float( 7.604227066e-001, 2.429442555e-001 );
00530     afb[79] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00531 }
00532 static void init_ipiv( lapack_int size, lapack_int *ipiv ) {
00533     lapack_int i;
00534     for( i = 0; i < size; i++ ) {
00535         ipiv[i] = 0;
00536     }
00537     ipiv[0] = 2;
00538     ipiv[1] = 3;
00539     ipiv[2] = 3;
00540     ipiv[3] = 4;
00541 }
00542 static void init_b( lapack_int size, lapack_complex_float *b ) {
00543     lapack_int i;
00544     for( i = 0; i < size; i++ ) {
00545         b[i] = lapack_make_complex_float( 0.0f, 0.0f );
00546     }
00547     b[0] = lapack_make_complex_float( -1.059999943e+000, 2.150000000e+001 );
00548     b[8] = lapack_make_complex_float( 1.285000038e+001, 2.839999914e+000 );
00549     b[1] = lapack_make_complex_float( -2.271999931e+001, -5.390000153e+001 );
00550     b[9] = lapack_make_complex_float( -7.022000122e+001, 2.156999969e+001 );
00551     b[2] = lapack_make_complex_float( 2.823999977e+001, -3.859999847e+001 );
00552     b[10] = lapack_make_complex_float( -2.072999954e+001, -1.230000019e+000 );
00553     b[3] = lapack_make_complex_float( -3.456000137e+001, 1.672999954e+001 );
00554     b[11] = lapack_make_complex_float( 2.601000023e+001, 3.196999931e+001 );
00555 }
00556 static void init_x( lapack_int size, lapack_complex_float *x ) {
00557     lapack_int i;
00558     for( i = 0; i < size; i++ ) {
00559         x[i] = lapack_make_complex_float( 0.0f, 0.0f );
00560     }
00561     x[0] = lapack_make_complex_float( -3.000000715e+000, 1.999998450e+000 );
00562     x[8] = lapack_make_complex_float( 9.999980330e-001, 5.999998093e+000 );
00563     x[1] = lapack_make_complex_float( 1.000001788e+000, -7.000001431e+000 );
00564     x[9] = lapack_make_complex_float( -6.999998093e+000, -4.000003815e+000 );
00565     x[2] = lapack_make_complex_float( -4.999999523e+000, 4.000000000e+000 );
00566     x[10] = lapack_make_complex_float( 3.000001431e+000, 4.999998569e+000 );
00567     x[3] = lapack_make_complex_float( 6.000000000e+000, -8.000000954e+000 );
00568     x[11] = lapack_make_complex_float( -8.000001907e+000, 1.999996185e+000 );
00569 }
00570 static void init_ferr( lapack_int size, float *ferr ) {
00571     lapack_int i;
00572     for( i = 0; i < size; i++ ) {
00573         ferr[i] = 0;
00574     }
00575 }
00576 static void init_berr( lapack_int size, float *berr ) {
00577     lapack_int i;
00578     for( i = 0; i < size; i++ ) {
00579         berr[i] = 0;
00580     }
00581 }
00582 static void init_work( lapack_int size, lapack_complex_float *work ) {
00583     lapack_int i;
00584     for( i = 0; i < size; i++ ) {
00585         work[i] = lapack_make_complex_float( 0.0f, 0.0f );
00586     }
00587 }
00588 static void init_rwork( lapack_int size, float *rwork ) {
00589     lapack_int i;
00590     for( i = 0; i < size; i++ ) {
00591         rwork[i] = 0;
00592     }
00593 }
00594 
00595 /* Auxiliary function: C interface to cgbrfs results check */
00596 /* Return value: 0 - test is passed, non-zero - test is failed */
00597 static int compare_cgbrfs( lapack_complex_float *x, lapack_complex_float *x_i,
00598                            float *ferr, float *ferr_i, float *berr,
00599                            float *berr_i, lapack_int info, lapack_int info_i,
00600                            lapack_int ldx, lapack_int nrhs )
00601 {
00602     lapack_int i;
00603     int failed = 0;
00604     for( i = 0; i < ldx*nrhs; i++ ) {
00605         failed += compare_complex_floats(x[i],x_i[i]);
00606     }
00607     for( i = 0; i < nrhs; i++ ) {
00608         failed += compare_floats(ferr[i],ferr_i[i]);
00609     }
00610     for( i = 0; i < nrhs; i++ ) {
00611         failed += compare_floats(berr[i],berr_i[i]);
00612     }
00613     failed += (info == info_i) ? 0 : 1;
00614     if( info != 0 || info_i != 0 ) {
00615         printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00616     }
00617 
00618     return failed;
00619 }


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