csprfs_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 * csprfs_1 is the test program for the C interface to LAPACK
00036 * routine csprfs
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_csprfs( char *uplo, lapack_int *n, lapack_int *nrhs,
00055                                  lapack_int *ldb, lapack_int *ldx );
00056 static void init_ap( lapack_int size, lapack_complex_float *ap );
00057 static void init_afp( lapack_int size, lapack_complex_float *afp );
00058 static void init_ipiv( lapack_int size, lapack_int *ipiv );
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_csprfs( 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 ldb, ldb_i;
00077     lapack_int ldb_r;
00078     lapack_int ldx, ldx_i;
00079     lapack_int ldx_r;
00080     lapack_int info, info_i;
00081     lapack_int i;
00082     int failed;
00083 
00084     /* Local arrays */
00085     lapack_complex_float *ap = NULL, *ap_i = NULL;
00086     lapack_complex_float *afp = NULL, *afp_i = NULL;
00087     lapack_int *ipiv = NULL, *ipiv_i = NULL;
00088     lapack_complex_float *b = NULL, *b_i = NULL;
00089     lapack_complex_float *x = NULL, *x_i = NULL;
00090     float *ferr = NULL, *ferr_i = NULL;
00091     float *berr = NULL, *berr_i = NULL;
00092     lapack_complex_float *work = NULL, *work_i = NULL;
00093     float *rwork = NULL, *rwork_i = NULL;
00094     lapack_complex_float *x_save = NULL;
00095     float *ferr_save = NULL;
00096     float *berr_save = NULL;
00097     lapack_complex_float *ap_r = NULL;
00098     lapack_complex_float *afp_r = NULL;
00099     lapack_complex_float *b_r = NULL;
00100     lapack_complex_float *x_r = NULL;
00101 
00102     /* Iniitialize the scalar parameters */
00103     init_scalars_csprfs( &uplo, &n, &nrhs, &ldb, &ldx );
00104     ldb_r = nrhs+2;
00105     ldx_r = nrhs+2;
00106     uplo_i = uplo;
00107     n_i = n;
00108     nrhs_i = nrhs;
00109     ldb_i = ldb;
00110     ldx_i = ldx;
00111 
00112     /* Allocate memory for the LAPACK routine arrays */
00113     ap = (lapack_complex_float *)
00114         LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(lapack_complex_float) );
00115     afp = (lapack_complex_float *)
00116         LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(lapack_complex_float) );
00117     ipiv = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
00118     b = (lapack_complex_float *)
00119         LAPACKE_malloc( ldb*nrhs * sizeof(lapack_complex_float) );
00120     x = (lapack_complex_float *)
00121         LAPACKE_malloc( ldx*nrhs * sizeof(lapack_complex_float) );
00122     ferr = (float *)LAPACKE_malloc( nrhs * sizeof(float) );
00123     berr = (float *)LAPACKE_malloc( nrhs * sizeof(float) );
00124     work = (lapack_complex_float *)
00125         LAPACKE_malloc( 2*n * sizeof(lapack_complex_float) );
00126     rwork = (float *)LAPACKE_malloc( n * sizeof(float) );
00127 
00128     /* Allocate memory for the C interface function arrays */
00129     ap_i = (lapack_complex_float *)
00130         LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(lapack_complex_float) );
00131     afp_i = (lapack_complex_float *)
00132         LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(lapack_complex_float) );
00133     ipiv_i = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
00134     b_i = (lapack_complex_float *)
00135         LAPACKE_malloc( ldb*nrhs * sizeof(lapack_complex_float) );
00136     x_i = (lapack_complex_float *)
00137         LAPACKE_malloc( ldx*nrhs * sizeof(lapack_complex_float) );
00138     ferr_i = (float *)LAPACKE_malloc( nrhs * sizeof(float) );
00139     berr_i = (float *)LAPACKE_malloc( nrhs * sizeof(float) );
00140     work_i = (lapack_complex_float *)
00141         LAPACKE_malloc( 2*n * sizeof(lapack_complex_float) );
00142     rwork_i = (float *)LAPACKE_malloc( n * sizeof(float) );
00143 
00144     /* Allocate memory for the backup arrays */
00145     x_save = (lapack_complex_float *)
00146         LAPACKE_malloc( ldx*nrhs * sizeof(lapack_complex_float) );
00147     ferr_save = (float *)LAPACKE_malloc( nrhs * sizeof(float) );
00148     berr_save = (float *)LAPACKE_malloc( nrhs * sizeof(float) );
00149 
00150     /* Allocate memory for the row-major arrays */
00151     ap_r = (lapack_complex_float *)
00152         LAPACKE_malloc( n*(n+1)/2 * sizeof(lapack_complex_float) );
00153     afp_r = (lapack_complex_float *)
00154         LAPACKE_malloc( n*(n+1)/2 * sizeof(lapack_complex_float) );
00155     b_r = (lapack_complex_float *)
00156         LAPACKE_malloc( n*(nrhs+2) * sizeof(lapack_complex_float) );
00157     x_r = (lapack_complex_float *)
00158         LAPACKE_malloc( n*(nrhs+2) * sizeof(lapack_complex_float) );
00159 
00160     /* Initialize input arrays */
00161     init_ap( (n*(n+1)/2), ap );
00162     init_afp( (n*(n+1)/2), afp );
00163     init_ipiv( n, ipiv );
00164     init_b( ldb*nrhs, b );
00165     init_x( ldx*nrhs, x );
00166     init_ferr( nrhs, ferr );
00167     init_berr( nrhs, berr );
00168     init_work( 2*n, work );
00169     init_rwork( n, rwork );
00170 
00171     /* Backup the ouptut arrays */
00172     for( i = 0; i < ldx*nrhs; i++ ) {
00173         x_save[i] = x[i];
00174     }
00175     for( i = 0; i < nrhs; i++ ) {
00176         ferr_save[i] = ferr[i];
00177     }
00178     for( i = 0; i < nrhs; i++ ) {
00179         berr_save[i] = berr[i];
00180     }
00181 
00182     /* Call the LAPACK routine */
00183     csprfs_( &uplo, &n, &nrhs, ap, afp, ipiv, b, &ldb, x, &ldx, ferr, berr,
00184              work, rwork, &info );
00185 
00186     /* Initialize input data, call the column-major middle-level
00187      * interface to LAPACK routine and check the results */
00188     for( i = 0; i < (n*(n+1)/2); i++ ) {
00189         ap_i[i] = ap[i];
00190     }
00191     for( i = 0; i < (n*(n+1)/2); i++ ) {
00192         afp_i[i] = afp[i];
00193     }
00194     for( i = 0; i < n; i++ ) {
00195         ipiv_i[i] = ipiv[i];
00196     }
00197     for( i = 0; i < ldb*nrhs; i++ ) {
00198         b_i[i] = b[i];
00199     }
00200     for( i = 0; i < ldx*nrhs; i++ ) {
00201         x_i[i] = x_save[i];
00202     }
00203     for( i = 0; i < nrhs; i++ ) {
00204         ferr_i[i] = ferr_save[i];
00205     }
00206     for( i = 0; i < nrhs; i++ ) {
00207         berr_i[i] = berr_save[i];
00208     }
00209     for( i = 0; i < 2*n; i++ ) {
00210         work_i[i] = work[i];
00211     }
00212     for( i = 0; i < n; i++ ) {
00213         rwork_i[i] = rwork[i];
00214     }
00215     info_i = LAPACKE_csprfs_work( LAPACK_COL_MAJOR, uplo_i, n_i, nrhs_i, ap_i,
00216                                   afp_i, ipiv_i, b_i, ldb_i, x_i, ldx_i, ferr_i,
00217                                   berr_i, work_i, rwork_i );
00218 
00219     failed = compare_csprfs( x, x_i, ferr, ferr_i, berr, berr_i, info, info_i,
00220                              ldx, nrhs );
00221     if( failed == 0 ) {
00222         printf( "PASSED: column-major middle-level interface to csprfs\n" );
00223     } else {
00224         printf( "FAILED: column-major middle-level interface to csprfs\n" );
00225     }
00226 
00227     /* Initialize input data, call the column-major high-level
00228      * interface to LAPACK routine and check the results */
00229     for( i = 0; i < (n*(n+1)/2); i++ ) {
00230         ap_i[i] = ap[i];
00231     }
00232     for( i = 0; i < (n*(n+1)/2); i++ ) {
00233         afp_i[i] = afp[i];
00234     }
00235     for( i = 0; i < n; i++ ) {
00236         ipiv_i[i] = ipiv[i];
00237     }
00238     for( i = 0; i < ldb*nrhs; i++ ) {
00239         b_i[i] = b[i];
00240     }
00241     for( i = 0; i < ldx*nrhs; i++ ) {
00242         x_i[i] = x_save[i];
00243     }
00244     for( i = 0; i < nrhs; i++ ) {
00245         ferr_i[i] = ferr_save[i];
00246     }
00247     for( i = 0; i < nrhs; i++ ) {
00248         berr_i[i] = berr_save[i];
00249     }
00250     for( i = 0; i < 2*n; i++ ) {
00251         work_i[i] = work[i];
00252     }
00253     for( i = 0; i < n; i++ ) {
00254         rwork_i[i] = rwork[i];
00255     }
00256     info_i = LAPACKE_csprfs( LAPACK_COL_MAJOR, uplo_i, n_i, nrhs_i, ap_i, afp_i,
00257                              ipiv_i, b_i, ldb_i, x_i, ldx_i, ferr_i, berr_i );
00258 
00259     failed = compare_csprfs( x, x_i, ferr, ferr_i, berr, berr_i, info, info_i,
00260                              ldx, nrhs );
00261     if( failed == 0 ) {
00262         printf( "PASSED: column-major high-level interface to csprfs\n" );
00263     } else {
00264         printf( "FAILED: column-major high-level interface to csprfs\n" );
00265     }
00266 
00267     /* Initialize input data, call the row-major middle-level
00268      * interface to LAPACK routine and check the results */
00269     for( i = 0; i < (n*(n+1)/2); i++ ) {
00270         ap_i[i] = ap[i];
00271     }
00272     for( i = 0; i < (n*(n+1)/2); i++ ) {
00273         afp_i[i] = afp[i];
00274     }
00275     for( i = 0; i < n; i++ ) {
00276         ipiv_i[i] = ipiv[i];
00277     }
00278     for( i = 0; i < ldb*nrhs; i++ ) {
00279         b_i[i] = b[i];
00280     }
00281     for( i = 0; i < ldx*nrhs; i++ ) {
00282         x_i[i] = x_save[i];
00283     }
00284     for( i = 0; i < nrhs; i++ ) {
00285         ferr_i[i] = ferr_save[i];
00286     }
00287     for( i = 0; i < nrhs; i++ ) {
00288         berr_i[i] = berr_save[i];
00289     }
00290     for( i = 0; i < 2*n; i++ ) {
00291         work_i[i] = work[i];
00292     }
00293     for( i = 0; i < n; i++ ) {
00294         rwork_i[i] = rwork[i];
00295     }
00296 
00297     LAPACKE_cpp_trans( LAPACK_COL_MAJOR, uplo, n, ap_i, ap_r );
00298     LAPACKE_cpp_trans( LAPACK_COL_MAJOR, uplo, n, afp_i, afp_r );
00299     LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, nrhs, b_i, ldb, b_r, nrhs+2 );
00300     LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, nrhs, x_i, ldx, x_r, nrhs+2 );
00301     info_i = LAPACKE_csprfs_work( LAPACK_ROW_MAJOR, uplo_i, n_i, nrhs_i, ap_r,
00302                                   afp_r, ipiv_i, b_r, ldb_r, x_r, ldx_r, ferr_i,
00303                                   berr_i, work_i, rwork_i );
00304 
00305     LAPACKE_cge_trans( LAPACK_ROW_MAJOR, n, nrhs, x_r, nrhs+2, x_i, ldx );
00306 
00307     failed = compare_csprfs( x, x_i, ferr, ferr_i, berr, berr_i, info, info_i,
00308                              ldx, nrhs );
00309     if( failed == 0 ) {
00310         printf( "PASSED: row-major middle-level interface to csprfs\n" );
00311     } else {
00312         printf( "FAILED: row-major middle-level interface to csprfs\n" );
00313     }
00314 
00315     /* Initialize input data, call the row-major high-level
00316      * interface to LAPACK routine and check the results */
00317     for( i = 0; i < (n*(n+1)/2); i++ ) {
00318         ap_i[i] = ap[i];
00319     }
00320     for( i = 0; i < (n*(n+1)/2); i++ ) {
00321         afp_i[i] = afp[i];
00322     }
00323     for( i = 0; i < n; i++ ) {
00324         ipiv_i[i] = ipiv[i];
00325     }
00326     for( i = 0; i < ldb*nrhs; i++ ) {
00327         b_i[i] = b[i];
00328     }
00329     for( i = 0; i < ldx*nrhs; i++ ) {
00330         x_i[i] = x_save[i];
00331     }
00332     for( i = 0; i < nrhs; i++ ) {
00333         ferr_i[i] = ferr_save[i];
00334     }
00335     for( i = 0; i < nrhs; i++ ) {
00336         berr_i[i] = berr_save[i];
00337     }
00338     for( i = 0; i < 2*n; i++ ) {
00339         work_i[i] = work[i];
00340     }
00341     for( i = 0; i < n; i++ ) {
00342         rwork_i[i] = rwork[i];
00343     }
00344 
00345     /* Init row_major arrays */
00346     LAPACKE_cpp_trans( LAPACK_COL_MAJOR, uplo, n, ap_i, ap_r );
00347     LAPACKE_cpp_trans( LAPACK_COL_MAJOR, uplo, n, afp_i, afp_r );
00348     LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, nrhs, b_i, ldb, b_r, nrhs+2 );
00349     LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, nrhs, x_i, ldx, x_r, nrhs+2 );
00350     info_i = LAPACKE_csprfs( LAPACK_ROW_MAJOR, uplo_i, n_i, nrhs_i, ap_r, afp_r,
00351                              ipiv_i, b_r, ldb_r, x_r, ldx_r, ferr_i, berr_i );
00352 
00353     LAPACKE_cge_trans( LAPACK_ROW_MAJOR, n, nrhs, x_r, nrhs+2, x_i, ldx );
00354 
00355     failed = compare_csprfs( x, x_i, ferr, ferr_i, berr, berr_i, info, info_i,
00356                              ldx, nrhs );
00357     if( failed == 0 ) {
00358         printf( "PASSED: row-major high-level interface to csprfs\n" );
00359     } else {
00360         printf( "FAILED: row-major high-level interface to csprfs\n" );
00361     }
00362 
00363     /* Release memory */
00364     if( ap != NULL ) {
00365         LAPACKE_free( ap );
00366     }
00367     if( ap_i != NULL ) {
00368         LAPACKE_free( ap_i );
00369     }
00370     if( ap_r != NULL ) {
00371         LAPACKE_free( ap_r );
00372     }
00373     if( afp != NULL ) {
00374         LAPACKE_free( afp );
00375     }
00376     if( afp_i != NULL ) {
00377         LAPACKE_free( afp_i );
00378     }
00379     if( afp_r != NULL ) {
00380         LAPACKE_free( afp_r );
00381     }
00382     if( ipiv != NULL ) {
00383         LAPACKE_free( ipiv );
00384     }
00385     if( ipiv_i != NULL ) {
00386         LAPACKE_free( ipiv_i );
00387     }
00388     if( b != NULL ) {
00389         LAPACKE_free( b );
00390     }
00391     if( b_i != NULL ) {
00392         LAPACKE_free( b_i );
00393     }
00394     if( b_r != NULL ) {
00395         LAPACKE_free( b_r );
00396     }
00397     if( x != NULL ) {
00398         LAPACKE_free( x );
00399     }
00400     if( x_i != NULL ) {
00401         LAPACKE_free( x_i );
00402     }
00403     if( x_r != NULL ) {
00404         LAPACKE_free( x_r );
00405     }
00406     if( x_save != NULL ) {
00407         LAPACKE_free( x_save );
00408     }
00409     if( ferr != NULL ) {
00410         LAPACKE_free( ferr );
00411     }
00412     if( ferr_i != NULL ) {
00413         LAPACKE_free( ferr_i );
00414     }
00415     if( ferr_save != NULL ) {
00416         LAPACKE_free( ferr_save );
00417     }
00418     if( berr != NULL ) {
00419         LAPACKE_free( berr );
00420     }
00421     if( berr_i != NULL ) {
00422         LAPACKE_free( berr_i );
00423     }
00424     if( berr_save != NULL ) {
00425         LAPACKE_free( berr_save );
00426     }
00427     if( work != NULL ) {
00428         LAPACKE_free( work );
00429     }
00430     if( work_i != NULL ) {
00431         LAPACKE_free( work_i );
00432     }
00433     if( rwork != NULL ) {
00434         LAPACKE_free( rwork );
00435     }
00436     if( rwork_i != NULL ) {
00437         LAPACKE_free( rwork_i );
00438     }
00439 
00440     return 0;
00441 }
00442 
00443 /* Auxiliary function: csprfs scalar parameters initialization */
00444 static void init_scalars_csprfs( char *uplo, lapack_int *n, lapack_int *nrhs,
00445                                  lapack_int *ldb, lapack_int *ldx )
00446 {
00447     *uplo = 'L';
00448     *n = 4;
00449     *nrhs = 2;
00450     *ldb = 8;
00451     *ldx = 8;
00452 
00453     return;
00454 }
00455 
00456 /* Auxiliary functions: csprfs array parameters initialization */
00457 static void init_ap( lapack_int size, lapack_complex_float *ap ) {
00458     lapack_int i;
00459     for( i = 0; i < size; i++ ) {
00460         ap[i] = lapack_make_complex_float( 0.0f, 0.0f );
00461     }
00462     ap[0] = lapack_make_complex_float( -3.899999857e-001, -7.099999785e-001 );
00463     ap[1] = lapack_make_complex_float( 5.139999866e+000, -6.399999857e-001 );
00464     ap[2] = lapack_make_complex_float( -7.860000134e+000, -2.960000038e+000 );
00465     ap[3] = lapack_make_complex_float( 3.799999952e+000, 9.200000167e-001 );
00466     ap[4] = lapack_make_complex_float( 8.859999657e+000, 1.809999943e+000 );
00467     ap[5] = lapack_make_complex_float( -3.519999981e+000, 5.799999833e-001 );
00468     ap[6] = lapack_make_complex_float( 5.320000172e+000, -1.590000033e+000 );
00469     ap[7] = lapack_make_complex_float( -2.829999924e+000, -2.999999933e-002 );
00470     ap[8] = lapack_make_complex_float( -1.539999962e+000, -2.859999895e+000 );
00471     ap[9] = lapack_make_complex_float( -5.600000024e-001, 1.199999973e-001 );
00472 }
00473 static void init_afp( lapack_int size, lapack_complex_float *afp ) {
00474     lapack_int i;
00475     for( i = 0; i < size; i++ ) {
00476         afp[i] = lapack_make_complex_float( 0.0f, 0.0f );
00477     }
00478     afp[0] = lapack_make_complex_float( -3.899999857e-001, -7.099999785e-001 );
00479     afp[1] = lapack_make_complex_float( -7.860000134e+000, -2.960000038e+000 );
00480     afp[2] = lapack_make_complex_float( 5.278724432e-001, -3.714659810e-001 );
00481     afp[3] = lapack_make_complex_float( 4.425582290e-001, 1.936483681e-001 );
00482     afp[4] = lapack_make_complex_float( -2.829999924e+000, -2.999999933e-002 );
00483     afp[5] = lapack_make_complex_float( -6.078390479e-001, 2.810796499e-001 );
00484     afp[6] = lapack_make_complex_float( -4.822822809e-001, 1.498936117e-002 );
00485     afp[7] = lapack_make_complex_float( 4.407906532e+000, 5.399120808e+000 );
00486     afp[8] = lapack_make_complex_float( -1.070821285e-001, -3.156781197e-001 );
00487     afp[9] = lapack_make_complex_float( -2.095414639e+000, -2.201138735e+000 );
00488 }
00489 static void init_ipiv( lapack_int size, lapack_int *ipiv ) {
00490     lapack_int i;
00491     for( i = 0; i < size; i++ ) {
00492         ipiv[i] = 0;
00493     }
00494     ipiv[0] = -3;
00495     ipiv[1] = -3;
00496     ipiv[2] = 3;
00497     ipiv[3] = 4;
00498 }
00499 static void init_b( lapack_int size, lapack_complex_float *b ) {
00500     lapack_int i;
00501     for( i = 0; i < size; i++ ) {
00502         b[i] = lapack_make_complex_float( 0.0f, 0.0f );
00503     }
00504     b[0] = lapack_make_complex_float( -5.563999939e+001, 4.122000122e+001 );
00505     b[8] = lapack_make_complex_float( -1.909000015e+001, -3.597000122e+001 );
00506     b[1] = lapack_make_complex_float( -4.818000031e+001, 6.600000000e+001 );
00507     b[9] = lapack_make_complex_float( -1.207999992e+001, -2.702000046e+001 );
00508     b[2] = lapack_make_complex_float( -4.900000095e-001, -1.470000029e+000 );
00509     b[10] = lapack_make_complex_float( 6.949999809e+000, 2.048999977e+001 );
00510     b[3] = lapack_make_complex_float( -6.429999828e+000, 1.923999977e+001 );
00511     b[11] = lapack_make_complex_float( -4.590000153e+000, -3.552999878e+001 );
00512 }
00513 static void init_x( lapack_int size, lapack_complex_float *x ) {
00514     lapack_int i;
00515     for( i = 0; i < size; i++ ) {
00516         x[i] = lapack_make_complex_float( 0.0f, 0.0f );
00517     }
00518     x[0] = lapack_make_complex_float( 1.000000238e+000, -1.000000954e+000 );
00519     x[8] = lapack_make_complex_float( -1.999999285e+000, -9.999997616e-001 );
00520     x[1] = lapack_make_complex_float( -2.000000477e+000, 5.000000477e+000 );
00521     x[9] = lapack_make_complex_float( 9.999995232e-001, -3.000000238e+000 );
00522     x[2] = lapack_make_complex_float( 3.000000000e+000, -1.999999046e+000 );
00523     x[10] = lapack_make_complex_float( 2.999999285e+000, 2.000000000e+000 );
00524     x[3] = lapack_make_complex_float( -3.999999762e+000, 3.000001192e+000 );
00525     x[11] = lapack_make_complex_float( -1.000000477e+000, 9.999997020e-001 );
00526 }
00527 static void init_ferr( lapack_int size, float *ferr ) {
00528     lapack_int i;
00529     for( i = 0; i < size; i++ ) {
00530         ferr[i] = 0;
00531     }
00532 }
00533 static void init_berr( lapack_int size, float *berr ) {
00534     lapack_int i;
00535     for( i = 0; i < size; i++ ) {
00536         berr[i] = 0;
00537     }
00538 }
00539 static void init_work( lapack_int size, lapack_complex_float *work ) {
00540     lapack_int i;
00541     for( i = 0; i < size; i++ ) {
00542         work[i] = lapack_make_complex_float( 0.0f, 0.0f );
00543     }
00544 }
00545 static void init_rwork( lapack_int size, float *rwork ) {
00546     lapack_int i;
00547     for( i = 0; i < size; i++ ) {
00548         rwork[i] = 0;
00549     }
00550 }
00551 
00552 /* Auxiliary function: C interface to csprfs results check */
00553 /* Return value: 0 - test is passed, non-zero - test is failed */
00554 static int compare_csprfs( lapack_complex_float *x, lapack_complex_float *x_i,
00555                            float *ferr, float *ferr_i, float *berr,
00556                            float *berr_i, lapack_int info, lapack_int info_i,
00557                            lapack_int ldx, lapack_int nrhs )
00558 {
00559     lapack_int i;
00560     int failed = 0;
00561     for( i = 0; i < ldx*nrhs; i++ ) {
00562         failed += compare_complex_floats(x[i],x_i[i]);
00563     }
00564     for( i = 0; i < nrhs; i++ ) {
00565         failed += compare_floats(ferr[i],ferr_i[i]);
00566     }
00567     for( i = 0; i < nrhs; i++ ) {
00568         failed += compare_floats(berr[i],berr_i[i]);
00569     }
00570     failed += (info == info_i) ? 0 : 1;
00571     if( info != 0 || info_i != 0 ) {
00572         printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00573     }
00574 
00575     return failed;
00576 }


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