zsprfs_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 * zsprfs_1 is the test program for the C interface to LAPACK
00036 * routine zsprfs
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_zsprfs( 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_double *ap );
00057 static void init_afp( lapack_int size, lapack_complex_double *afp );
00058 static void init_ipiv( lapack_int size, lapack_int *ipiv );
00059 static void init_b( lapack_int size, lapack_complex_double *b );
00060 static void init_x( lapack_int size, lapack_complex_double *x );
00061 static void init_ferr( lapack_int size, double *ferr );
00062 static void init_berr( lapack_int size, double *berr );
00063 static void init_work( lapack_int size, lapack_complex_double *work );
00064 static void init_rwork( lapack_int size, double *rwork );
00065 static int compare_zsprfs( lapack_complex_double *x, lapack_complex_double *x_i,
00066                            double *ferr, double *ferr_i, double *berr,
00067                            double *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_double *ap = NULL, *ap_i = NULL;
00086     lapack_complex_double *afp = NULL, *afp_i = NULL;
00087     lapack_int *ipiv = NULL, *ipiv_i = NULL;
00088     lapack_complex_double *b = NULL, *b_i = NULL;
00089     lapack_complex_double *x = NULL, *x_i = NULL;
00090     double *ferr = NULL, *ferr_i = NULL;
00091     double *berr = NULL, *berr_i = NULL;
00092     lapack_complex_double *work = NULL, *work_i = NULL;
00093     double *rwork = NULL, *rwork_i = NULL;
00094     lapack_complex_double *x_save = NULL;
00095     double *ferr_save = NULL;
00096     double *berr_save = NULL;
00097     lapack_complex_double *ap_r = NULL;
00098     lapack_complex_double *afp_r = NULL;
00099     lapack_complex_double *b_r = NULL;
00100     lapack_complex_double *x_r = NULL;
00101 
00102     /* Iniitialize the scalar parameters */
00103     init_scalars_zsprfs( &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_double *)
00114         LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(lapack_complex_double) );
00115     afp = (lapack_complex_double *)
00116         LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(lapack_complex_double) );
00117     ipiv = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
00118     b = (lapack_complex_double *)
00119         LAPACKE_malloc( ldb*nrhs * sizeof(lapack_complex_double) );
00120     x = (lapack_complex_double *)
00121         LAPACKE_malloc( ldx*nrhs * sizeof(lapack_complex_double) );
00122     ferr = (double *)LAPACKE_malloc( nrhs * sizeof(double) );
00123     berr = (double *)LAPACKE_malloc( nrhs * sizeof(double) );
00124     work = (lapack_complex_double *)
00125         LAPACKE_malloc( 2*n * sizeof(lapack_complex_double) );
00126     rwork = (double *)LAPACKE_malloc( n * sizeof(double) );
00127 
00128     /* Allocate memory for the C interface function arrays */
00129     ap_i = (lapack_complex_double *)
00130         LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(lapack_complex_double) );
00131     afp_i = (lapack_complex_double *)
00132         LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(lapack_complex_double) );
00133     ipiv_i = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
00134     b_i = (lapack_complex_double *)
00135         LAPACKE_malloc( ldb*nrhs * sizeof(lapack_complex_double) );
00136     x_i = (lapack_complex_double *)
00137         LAPACKE_malloc( ldx*nrhs * sizeof(lapack_complex_double) );
00138     ferr_i = (double *)LAPACKE_malloc( nrhs * sizeof(double) );
00139     berr_i = (double *)LAPACKE_malloc( nrhs * sizeof(double) );
00140     work_i = (lapack_complex_double *)
00141         LAPACKE_malloc( 2*n * sizeof(lapack_complex_double) );
00142     rwork_i = (double *)LAPACKE_malloc( n * sizeof(double) );
00143 
00144     /* Allocate memory for the backup arrays */
00145     x_save = (lapack_complex_double *)
00146         LAPACKE_malloc( ldx*nrhs * sizeof(lapack_complex_double) );
00147     ferr_save = (double *)LAPACKE_malloc( nrhs * sizeof(double) );
00148     berr_save = (double *)LAPACKE_malloc( nrhs * sizeof(double) );
00149 
00150     /* Allocate memory for the row-major arrays */
00151     ap_r = (lapack_complex_double *)
00152         LAPACKE_malloc( n*(n+1)/2 * sizeof(lapack_complex_double) );
00153     afp_r = (lapack_complex_double *)
00154         LAPACKE_malloc( n*(n+1)/2 * sizeof(lapack_complex_double) );
00155     b_r = (lapack_complex_double *)
00156         LAPACKE_malloc( n*(nrhs+2) * sizeof(lapack_complex_double) );
00157     x_r = (lapack_complex_double *)
00158         LAPACKE_malloc( n*(nrhs+2) * sizeof(lapack_complex_double) );
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     zsprfs_( &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_zsprfs_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_zsprfs( 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 zsprfs\n" );
00223     } else {
00224         printf( "FAILED: column-major middle-level interface to zsprfs\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_zsprfs( 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_zsprfs( 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 zsprfs\n" );
00263     } else {
00264         printf( "FAILED: column-major high-level interface to zsprfs\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_zpp_trans( LAPACK_COL_MAJOR, uplo, n, ap_i, ap_r );
00298     LAPACKE_zpp_trans( LAPACK_COL_MAJOR, uplo, n, afp_i, afp_r );
00299     LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, nrhs, b_i, ldb, b_r, nrhs+2 );
00300     LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, nrhs, x_i, ldx, x_r, nrhs+2 );
00301     info_i = LAPACKE_zsprfs_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_zge_trans( LAPACK_ROW_MAJOR, n, nrhs, x_r, nrhs+2, x_i, ldx );
00306 
00307     failed = compare_zsprfs( 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 zsprfs\n" );
00311     } else {
00312         printf( "FAILED: row-major middle-level interface to zsprfs\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_zpp_trans( LAPACK_COL_MAJOR, uplo, n, ap_i, ap_r );
00347     LAPACKE_zpp_trans( LAPACK_COL_MAJOR, uplo, n, afp_i, afp_r );
00348     LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, nrhs, b_i, ldb, b_r, nrhs+2 );
00349     LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, nrhs, x_i, ldx, x_r, nrhs+2 );
00350     info_i = LAPACKE_zsprfs( 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_zge_trans( LAPACK_ROW_MAJOR, n, nrhs, x_r, nrhs+2, x_i, ldx );
00354 
00355     failed = compare_zsprfs( 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 zsprfs\n" );
00359     } else {
00360         printf( "FAILED: row-major high-level interface to zsprfs\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: zsprfs scalar parameters initialization */
00444 static void init_scalars_zsprfs( 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: zsprfs array parameters initialization */
00457 static void init_ap( lapack_int size, lapack_complex_double *ap ) {
00458     lapack_int i;
00459     for( i = 0; i < size; i++ ) {
00460         ap[i] = lapack_make_complex_double( 0.0, 0.0 );
00461     }
00462     ap[0] = lapack_make_complex_double( -3.90000000000000010e-001,
00463                                         -7.09999999999999960e-001 );
00464     ap[1] = lapack_make_complex_double( 5.13999999999999970e+000,
00465                                         -6.40000000000000010e-001 );
00466     ap[2] = lapack_make_complex_double( -7.86000000000000030e+000,
00467                                         -2.96000000000000000e+000 );
00468     ap[3] = lapack_make_complex_double( 3.79999999999999980e+000,
00469                                         9.20000000000000040e-001 );
00470     ap[4] = lapack_make_complex_double( 8.85999999999999940e+000,
00471                                         1.81000000000000010e+000 );
00472     ap[5] = lapack_make_complex_double( -3.52000000000000000e+000,
00473                                         5.79999999999999960e-001 );
00474     ap[6] = lapack_make_complex_double( 5.32000000000000030e+000,
00475                                         -1.59000000000000010e+000 );
00476     ap[7] = lapack_make_complex_double( -2.83000000000000010e+000,
00477                                         -2.99999999999999990e-002 );
00478     ap[8] = lapack_make_complex_double( -1.54000000000000000e+000,
00479                                         -2.85999999999999990e+000 );
00480     ap[9] = lapack_make_complex_double( -5.60000000000000050e-001,
00481                                         1.20000000000000000e-001 );
00482 }
00483 static void init_afp( lapack_int size, lapack_complex_double *afp ) {
00484     lapack_int i;
00485     for( i = 0; i < size; i++ ) {
00486         afp[i] = lapack_make_complex_double( 0.0, 0.0 );
00487     }
00488     afp[0] = lapack_make_complex_double( -3.90000000000000010e-001,
00489                                          -7.09999999999999960e-001 );
00490     afp[1] = lapack_make_complex_double( -7.86000000000000030e+000,
00491                                          -2.96000000000000000e+000 );
00492     afp[2] = lapack_make_complex_double( 5.27872480164079950e-001,
00493                                          -3.71466001482590570e-001 );
00494     afp[3] = lapack_make_complex_double( 4.42558238872675090e-001,
00495                                          1.93648369829740290e-001 );
00496     afp[4] = lapack_make_complex_double( -2.83000000000000010e+000,
00497                                          -2.99999999999999990e-002 );
00498     afp[5] = lapack_make_complex_double( -6.07839105668319330e-001,
00499                                          2.81079647893121950e-001 );
00500     afp[6] = lapack_make_complex_double( -4.82282297518538240e-001,
00501                                          1.49893621910528460e-002 );
00502     afp[7] = lapack_make_complex_double( 4.40790623673101310e+000,
00503                                          5.39912067679694110e+000 );
00504     afp[8] = lapack_make_complex_double( -1.07082188009268410e-001,
00505                                          -3.15678086248845520e-001 );
00506     afp[9] = lapack_make_complex_double( -2.09541488784005650e+000,
00507                                          -2.20113928144078570e+000 );
00508 }
00509 static void init_ipiv( lapack_int size, lapack_int *ipiv ) {
00510     lapack_int i;
00511     for( i = 0; i < size; i++ ) {
00512         ipiv[i] = 0;
00513     }
00514     ipiv[0] = -3;
00515     ipiv[1] = -3;
00516     ipiv[2] = 3;
00517     ipiv[3] = 4;
00518 }
00519 static void init_b( lapack_int size, lapack_complex_double *b ) {
00520     lapack_int i;
00521     for( i = 0; i < size; i++ ) {
00522         b[i] = lapack_make_complex_double( 0.0, 0.0 );
00523     }
00524     b[0] = lapack_make_complex_double( -5.56400000000000010e+001,
00525                                        4.12199999999999990e+001 );
00526     b[8] = lapack_make_complex_double( -1.90900000000000000e+001,
00527                                        -3.59699999999999990e+001 );
00528     b[1] = lapack_make_complex_double( -4.81800000000000000e+001,
00529                                        6.60000000000000000e+001 );
00530     b[9] = lapack_make_complex_double( -1.20800000000000000e+001,
00531                                        -2.70200000000000000e+001 );
00532     b[2] = lapack_make_complex_double( -4.89999999999999990e-001,
00533                                        -1.47000000000000000e+000 );
00534     b[10] = lapack_make_complex_double( 6.95000000000000020e+000,
00535                                         2.04899999999999980e+001 );
00536     b[3] = lapack_make_complex_double( -6.42999999999999970e+000,
00537                                        1.92399999999999980e+001 );
00538     b[11] = lapack_make_complex_double( -4.58999999999999990e+000,
00539                                         -3.55300000000000010e+001 );
00540 }
00541 static void init_x( lapack_int size, lapack_complex_double *x ) {
00542     lapack_int i;
00543     for( i = 0; i < size; i++ ) {
00544         x[i] = lapack_make_complex_double( 0.0, 0.0 );
00545     }
00546     x[0] = lapack_make_complex_double( 1.00000000000000110e+000,
00547                                        -1.00000000000000180e+000 );
00548     x[8] = lapack_make_complex_double( -1.99999999999999890e+000,
00549                                        -1.00000000000000000e+000 );
00550     x[1] = lapack_make_complex_double( -2.00000000000000130e+000,
00551                                        5.00000000000000090e+000 );
00552     x[9] = lapack_make_complex_double( 9.99999999999999560e-001,
00553                                        -3.00000000000000040e+000 );
00554     x[2] = lapack_make_complex_double( 3.00000000000000000e+000,
00555                                        -1.99999999999999640e+000 );
00556     x[10] = lapack_make_complex_double( 2.99999999999999820e+000,
00557                                         1.99999999999999930e+000 );
00558     x[3] = lapack_make_complex_double( -4.00000000000000000e+000,
00559                                        3.00000000000000270e+000 );
00560     x[11] = lapack_make_complex_double( -1.00000000000000020e+000,
00561                                         1.00000000000000070e+000 );
00562 }
00563 static void init_ferr( lapack_int size, double *ferr ) {
00564     lapack_int i;
00565     for( i = 0; i < size; i++ ) {
00566         ferr[i] = 0;
00567     }
00568 }
00569 static void init_berr( lapack_int size, double *berr ) {
00570     lapack_int i;
00571     for( i = 0; i < size; i++ ) {
00572         berr[i] = 0;
00573     }
00574 }
00575 static void init_work( lapack_int size, lapack_complex_double *work ) {
00576     lapack_int i;
00577     for( i = 0; i < size; i++ ) {
00578         work[i] = lapack_make_complex_double( 0.0, 0.0 );
00579     }
00580 }
00581 static void init_rwork( lapack_int size, double *rwork ) {
00582     lapack_int i;
00583     for( i = 0; i < size; i++ ) {
00584         rwork[i] = 0;
00585     }
00586 }
00587 
00588 /* Auxiliary function: C interface to zsprfs results check */
00589 /* Return value: 0 - test is passed, non-zero - test is failed */
00590 static int compare_zsprfs( lapack_complex_double *x, lapack_complex_double *x_i,
00591                            double *ferr, double *ferr_i, double *berr,
00592                            double *berr_i, lapack_int info, lapack_int info_i,
00593                            lapack_int ldx, lapack_int nrhs )
00594 {
00595     lapack_int i;
00596     int failed = 0;
00597     for( i = 0; i < ldx*nrhs; i++ ) {
00598         failed += compare_complex_doubles(x[i],x_i[i]);
00599     }
00600     for( i = 0; i < nrhs; i++ ) {
00601         failed += compare_doubles(ferr[i],ferr_i[i]);
00602     }
00603     for( i = 0; i < nrhs; i++ ) {
00604         failed += compare_doubles(berr[i],berr_i[i]);
00605     }
00606     failed += (info == info_i) ? 0 : 1;
00607     if( info != 0 || info_i != 0 ) {
00608         printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00609     }
00610 
00611     return failed;
00612 }


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:56:43