zbdsqr_2.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 * zbdsqr_2 is the test program for the C interface to LAPACK
00036 * routine zbdsqr
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_zbdsqr( char *uplo, lapack_int *n, lapack_int *ncvt,
00055                                  lapack_int *nru, lapack_int *ncc,
00056                                  lapack_int *ldvt, lapack_int *ldu,
00057                                  lapack_int *ldc );
00058 static void init_d( lapack_int size, double *d );
00059 static void init_e( lapack_int size, double *e );
00060 static void init_vt( lapack_int size, lapack_complex_double *vt );
00061 static void init_u( lapack_int size, lapack_complex_double *u );
00062 static void init_c( lapack_int size, lapack_complex_double *c );
00063 static void init_work( lapack_int size, double *work );
00064 static int compare_zbdsqr( double *d, double *d_i, double *e, double *e_i,
00065                            lapack_complex_double *vt,
00066                            lapack_complex_double *vt_i,
00067                            lapack_complex_double *u, lapack_complex_double *u_i,
00068                            lapack_complex_double *c, lapack_complex_double *c_i,
00069                            lapack_int info, lapack_int info_i, lapack_int ldc,
00070                            lapack_int ldu, lapack_int ldvt, lapack_int n,
00071                            lapack_int ncc, lapack_int ncvt, lapack_int nru );
00072 
00073 int main(void)
00074 {
00075     /* Local scalars */
00076     char uplo, uplo_i;
00077     lapack_int n, n_i;
00078     lapack_int ncvt, ncvt_i;
00079     lapack_int nru, nru_i;
00080     lapack_int ncc, ncc_i;
00081     lapack_int ldvt, ldvt_i;
00082     lapack_int ldvt_r;
00083     lapack_int ldu, ldu_i;
00084     lapack_int ldu_r;
00085     lapack_int ldc, ldc_i;
00086     lapack_int ldc_r;
00087     lapack_int info, info_i;
00088     lapack_int i;
00089     int failed;
00090 
00091     /* Local arrays */
00092     double *d = NULL, *d_i = NULL;
00093     double *e = NULL, *e_i = NULL;
00094     lapack_complex_double *vt = NULL, *vt_i = NULL;
00095     lapack_complex_double *u = NULL, *u_i = NULL;
00096     lapack_complex_double *c = NULL, *c_i = NULL;
00097     double *work = NULL, *work_i = NULL;
00098     double *d_save = NULL;
00099     double *e_save = NULL;
00100     lapack_complex_double *vt_save = NULL;
00101     lapack_complex_double *u_save = NULL;
00102     lapack_complex_double *c_save = NULL;
00103     lapack_complex_double *vt_r = NULL;
00104     lapack_complex_double *u_r = NULL;
00105     lapack_complex_double *c_r = NULL;
00106 
00107     /* Iniitialize the scalar parameters */
00108     init_scalars_zbdsqr( &uplo, &n, &ncvt, &nru, &ncc, &ldvt, &ldu, &ldc );
00109     ldvt_r = ncvt+2;
00110     ldu_r = n+2;
00111     ldc_r = ncc+2;
00112     uplo_i = uplo;
00113     n_i = n;
00114     ncvt_i = ncvt;
00115     nru_i = nru;
00116     ncc_i = ncc;
00117     ldvt_i = ldvt;
00118     ldu_i = ldu;
00119     ldc_i = ldc;
00120 
00121     /* Allocate memory for the LAPACK routine arrays */
00122     d = (double *)LAPACKE_malloc( n * sizeof(double) );
00123     e = (double *)LAPACKE_malloc( n * sizeof(double) );
00124     vt = (lapack_complex_double *)
00125         LAPACKE_malloc( ldvt*ncvt * sizeof(lapack_complex_double) );
00126     u = (lapack_complex_double *)
00127         LAPACKE_malloc( ldu*n * sizeof(lapack_complex_double) );
00128     c = (lapack_complex_double *)
00129         LAPACKE_malloc( ldc*ncc * sizeof(lapack_complex_double) );
00130     work = (double *)LAPACKE_malloc( 4*n * sizeof(double) );
00131 
00132     /* Allocate memory for the C interface function arrays */
00133     d_i = (double *)LAPACKE_malloc( n * sizeof(double) );
00134     e_i = (double *)LAPACKE_malloc( n * sizeof(double) );
00135     vt_i = (lapack_complex_double *)
00136         LAPACKE_malloc( ldvt*ncvt * sizeof(lapack_complex_double) );
00137     u_i = (lapack_complex_double *)
00138         LAPACKE_malloc( ldu*n * sizeof(lapack_complex_double) );
00139     c_i = (lapack_complex_double *)
00140         LAPACKE_malloc( ldc*ncc * sizeof(lapack_complex_double) );
00141     work_i = (double *)LAPACKE_malloc( 4*n * sizeof(double) );
00142 
00143     /* Allocate memory for the backup arrays */
00144     d_save = (double *)LAPACKE_malloc( n * sizeof(double) );
00145     e_save = (double *)LAPACKE_malloc( n * sizeof(double) );
00146     vt_save = (lapack_complex_double *)
00147         LAPACKE_malloc( ldvt*ncvt * sizeof(lapack_complex_double) );
00148     u_save = (lapack_complex_double *)
00149         LAPACKE_malloc( ldu*n * sizeof(lapack_complex_double) );
00150     c_save = (lapack_complex_double *)
00151         LAPACKE_malloc( ldc*ncc * sizeof(lapack_complex_double) );
00152 
00153     /* Allocate memory for the row-major arrays */
00154     vt_r = (lapack_complex_double *)
00155         LAPACKE_malloc( n*(ncvt+2) * sizeof(lapack_complex_double) );
00156     u_r = (lapack_complex_double *)
00157         LAPACKE_malloc( nru*(n+2) * sizeof(lapack_complex_double) );
00158     c_r = (lapack_complex_double *)
00159         LAPACKE_malloc( n*(ncc+2) * sizeof(lapack_complex_double) );
00160 
00161     /* Initialize input arrays */
00162     init_d( n, d );
00163     init_e( n, e );
00164     init_vt( ldvt*ncvt, vt );
00165     init_u( ldu*n, u );
00166     init_c( ldc*ncc, c );
00167     init_work( 4*n, work );
00168 
00169     /* Backup the ouptut arrays */
00170     for( i = 0; i < n; i++ ) {
00171         d_save[i] = d[i];
00172     }
00173     for( i = 0; i < n; i++ ) {
00174         e_save[i] = e[i];
00175     }
00176     for( i = 0; i < ldvt*ncvt; i++ ) {
00177         vt_save[i] = vt[i];
00178     }
00179     for( i = 0; i < ldu*n; i++ ) {
00180         u_save[i] = u[i];
00181     }
00182     for( i = 0; i < ldc*ncc; i++ ) {
00183         c_save[i] = c[i];
00184     }
00185 
00186     /* Call the LAPACK routine */
00187     zbdsqr_( &uplo, &n, &ncvt, &nru, &ncc, d, e, vt, &ldvt, u, &ldu, c, &ldc,
00188              work, &info );
00189 
00190     /* Initialize input data, call the column-major middle-level
00191      * interface to LAPACK routine and check the results */
00192     for( i = 0; i < n; i++ ) {
00193         d_i[i] = d_save[i];
00194     }
00195     for( i = 0; i < n; i++ ) {
00196         e_i[i] = e_save[i];
00197     }
00198     for( i = 0; i < ldvt*ncvt; i++ ) {
00199         vt_i[i] = vt_save[i];
00200     }
00201     for( i = 0; i < ldu*n; i++ ) {
00202         u_i[i] = u_save[i];
00203     }
00204     for( i = 0; i < ldc*ncc; i++ ) {
00205         c_i[i] = c_save[i];
00206     }
00207     for( i = 0; i < 4*n; i++ ) {
00208         work_i[i] = work[i];
00209     }
00210     info_i = LAPACKE_zbdsqr_work( LAPACK_COL_MAJOR, uplo_i, n_i, ncvt_i, nru_i,
00211                                   ncc_i, d_i, e_i, vt_i, ldvt_i, u_i, ldu_i,
00212                                   c_i, ldc_i, work_i );
00213 
00214     failed = compare_zbdsqr( d, d_i, e, e_i, vt, vt_i, u, u_i, c, c_i, info,
00215                              info_i, ldc, ldu, ldvt, n, ncc, ncvt, nru );
00216     if( failed == 0 ) {
00217         printf( "PASSED: column-major middle-level interface to zbdsqr\n" );
00218     } else {
00219         printf( "FAILED: column-major middle-level interface to zbdsqr\n" );
00220     }
00221 
00222     /* Initialize input data, call the column-major high-level
00223      * interface to LAPACK routine and check the results */
00224     for( i = 0; i < n; i++ ) {
00225         d_i[i] = d_save[i];
00226     }
00227     for( i = 0; i < n; i++ ) {
00228         e_i[i] = e_save[i];
00229     }
00230     for( i = 0; i < ldvt*ncvt; i++ ) {
00231         vt_i[i] = vt_save[i];
00232     }
00233     for( i = 0; i < ldu*n; i++ ) {
00234         u_i[i] = u_save[i];
00235     }
00236     for( i = 0; i < ldc*ncc; i++ ) {
00237         c_i[i] = c_save[i];
00238     }
00239     for( i = 0; i < 4*n; i++ ) {
00240         work_i[i] = work[i];
00241     }
00242     info_i = LAPACKE_zbdsqr( LAPACK_COL_MAJOR, uplo_i, n_i, ncvt_i, nru_i,
00243                              ncc_i, d_i, e_i, vt_i, ldvt_i, u_i, ldu_i, c_i,
00244                              ldc_i );
00245 
00246     failed = compare_zbdsqr( d, d_i, e, e_i, vt, vt_i, u, u_i, c, c_i, info,
00247                              info_i, ldc, ldu, ldvt, n, ncc, ncvt, nru );
00248     if( failed == 0 ) {
00249         printf( "PASSED: column-major high-level interface to zbdsqr\n" );
00250     } else {
00251         printf( "FAILED: column-major high-level interface to zbdsqr\n" );
00252     }
00253 
00254     /* Initialize input data, call the row-major middle-level
00255      * interface to LAPACK routine and check the results */
00256     for( i = 0; i < n; i++ ) {
00257         d_i[i] = d_save[i];
00258     }
00259     for( i = 0; i < n; i++ ) {
00260         e_i[i] = e_save[i];
00261     }
00262     for( i = 0; i < ldvt*ncvt; i++ ) {
00263         vt_i[i] = vt_save[i];
00264     }
00265     for( i = 0; i < ldu*n; i++ ) {
00266         u_i[i] = u_save[i];
00267     }
00268     for( i = 0; i < ldc*ncc; i++ ) {
00269         c_i[i] = c_save[i];
00270     }
00271     for( i = 0; i < 4*n; i++ ) {
00272         work_i[i] = work[i];
00273     }
00274 
00275     if( ncvt != 0 ) {
00276         LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, ncvt, vt_i, ldvt, vt_r,
00277                            ncvt+2 );
00278     }
00279     if( nru != 0 ) {
00280         LAPACKE_zge_trans( LAPACK_COL_MAJOR, nru, n, u_i, ldu, u_r, n+2 );
00281     }
00282     if( ncc != 0 ) {
00283         LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, ncc, c_i, ldc, c_r, ncc+2 );
00284     }
00285     info_i = LAPACKE_zbdsqr_work( LAPACK_ROW_MAJOR, uplo_i, n_i, ncvt_i, nru_i,
00286                                   ncc_i, d_i, e_i, vt_r, ldvt_r, u_r, ldu_r,
00287                                   c_r, ldc_r, work_i );
00288 
00289     if( ncvt != 0 ) {
00290         LAPACKE_zge_trans( LAPACK_ROW_MAJOR, n, ncvt, vt_r, ncvt+2, vt_i,
00291                            ldvt );
00292     }
00293     if( nru != 0 ) {
00294         LAPACKE_zge_trans( LAPACK_ROW_MAJOR, nru, n, u_r, n+2, u_i, ldu );
00295     }
00296     if( ncc != 0 ) {
00297         LAPACKE_zge_trans( LAPACK_ROW_MAJOR, n, ncc, c_r, ncc+2, c_i, ldc );
00298     }
00299 
00300     failed = compare_zbdsqr( d, d_i, e, e_i, vt, vt_i, u, u_i, c, c_i, info,
00301                              info_i, ldc, ldu, ldvt, n, ncc, ncvt, nru );
00302     if( failed == 0 ) {
00303         printf( "PASSED: row-major middle-level interface to zbdsqr\n" );
00304     } else {
00305         printf( "FAILED: row-major middle-level interface to zbdsqr\n" );
00306     }
00307 
00308     /* Initialize input data, call the row-major high-level
00309      * interface to LAPACK routine and check the results */
00310     for( i = 0; i < n; i++ ) {
00311         d_i[i] = d_save[i];
00312     }
00313     for( i = 0; i < n; i++ ) {
00314         e_i[i] = e_save[i];
00315     }
00316     for( i = 0; i < ldvt*ncvt; i++ ) {
00317         vt_i[i] = vt_save[i];
00318     }
00319     for( i = 0; i < ldu*n; i++ ) {
00320         u_i[i] = u_save[i];
00321     }
00322     for( i = 0; i < ldc*ncc; i++ ) {
00323         c_i[i] = c_save[i];
00324     }
00325     for( i = 0; i < 4*n; i++ ) {
00326         work_i[i] = work[i];
00327     }
00328 
00329     /* Init row_major arrays */
00330     if( ncvt != 0 ) {
00331         LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, ncvt, vt_i, ldvt, vt_r,
00332                            ncvt+2 );
00333     }
00334     if( nru != 0 ) {
00335         LAPACKE_zge_trans( LAPACK_COL_MAJOR, nru, n, u_i, ldu, u_r, n+2 );
00336     }
00337     if( ncc != 0 ) {
00338         LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, ncc, c_i, ldc, c_r, ncc+2 );
00339     }
00340     info_i = LAPACKE_zbdsqr( LAPACK_ROW_MAJOR, uplo_i, n_i, ncvt_i, nru_i,
00341                              ncc_i, d_i, e_i, vt_r, ldvt_r, u_r, ldu_r, c_r,
00342                              ldc_r );
00343 
00344     if( ncvt != 0 ) {
00345         LAPACKE_zge_trans( LAPACK_ROW_MAJOR, n, ncvt, vt_r, ncvt+2, vt_i,
00346                            ldvt );
00347     }
00348     if( nru != 0 ) {
00349         LAPACKE_zge_trans( LAPACK_ROW_MAJOR, nru, n, u_r, n+2, u_i, ldu );
00350     }
00351     if( ncc != 0 ) {
00352         LAPACKE_zge_trans( LAPACK_ROW_MAJOR, n, ncc, c_r, ncc+2, c_i, ldc );
00353     }
00354 
00355     failed = compare_zbdsqr( d, d_i, e, e_i, vt, vt_i, u, u_i, c, c_i, info,
00356                              info_i, ldc, ldu, ldvt, n, ncc, ncvt, nru );
00357     if( failed == 0 ) {
00358         printf( "PASSED: row-major high-level interface to zbdsqr\n" );
00359     } else {
00360         printf( "FAILED: row-major high-level interface to zbdsqr\n" );
00361     }
00362 
00363     /* Release memory */
00364     if( d != NULL ) {
00365         LAPACKE_free( d );
00366     }
00367     if( d_i != NULL ) {
00368         LAPACKE_free( d_i );
00369     }
00370     if( d_save != NULL ) {
00371         LAPACKE_free( d_save );
00372     }
00373     if( e != NULL ) {
00374         LAPACKE_free( e );
00375     }
00376     if( e_i != NULL ) {
00377         LAPACKE_free( e_i );
00378     }
00379     if( e_save != NULL ) {
00380         LAPACKE_free( e_save );
00381     }
00382     if( vt != NULL ) {
00383         LAPACKE_free( vt );
00384     }
00385     if( vt_i != NULL ) {
00386         LAPACKE_free( vt_i );
00387     }
00388     if( vt_r != NULL ) {
00389         LAPACKE_free( vt_r );
00390     }
00391     if( vt_save != NULL ) {
00392         LAPACKE_free( vt_save );
00393     }
00394     if( u != NULL ) {
00395         LAPACKE_free( u );
00396     }
00397     if( u_i != NULL ) {
00398         LAPACKE_free( u_i );
00399     }
00400     if( u_r != NULL ) {
00401         LAPACKE_free( u_r );
00402     }
00403     if( u_save != NULL ) {
00404         LAPACKE_free( u_save );
00405     }
00406     if( c != NULL ) {
00407         LAPACKE_free( c );
00408     }
00409     if( c_i != NULL ) {
00410         LAPACKE_free( c_i );
00411     }
00412     if( c_r != NULL ) {
00413         LAPACKE_free( c_r );
00414     }
00415     if( c_save != NULL ) {
00416         LAPACKE_free( c_save );
00417     }
00418     if( work != NULL ) {
00419         LAPACKE_free( work );
00420     }
00421     if( work_i != NULL ) {
00422         LAPACKE_free( work_i );
00423     }
00424 
00425     return 0;
00426 }
00427 
00428 /* Auxiliary function: zbdsqr scalar parameters initialization */
00429 static void init_scalars_zbdsqr( char *uplo, lapack_int *n, lapack_int *ncvt,
00430                                  lapack_int *nru, lapack_int *ncc,
00431                                  lapack_int *ldvt, lapack_int *ldu,
00432                                  lapack_int *ldc )
00433 {
00434     *uplo = 'L';
00435     *n = 3;
00436     *ncvt = 4;
00437     *nru = 3;
00438     *ncc = 0;
00439     *ldvt = 8;
00440     *ldu = 8;
00441     *ldc = 8;
00442 
00443     return;
00444 }
00445 
00446 /* Auxiliary functions: zbdsqr array parameters initialization */
00447 static void init_d( lapack_int size, double *d ) {
00448     lapack_int i;
00449     for( i = 0; i < size; i++ ) {
00450         d[i] = 0;
00451     }
00452     d[0] = -2.22551117723546850e+000;
00453     d[1] = 1.60455842542666320e+000;
00454     d[2] = -1.67305626481148150e+000;
00455 }
00456 static void init_e( lapack_int size, double *e ) {
00457     lapack_int i;
00458     for( i = 0; i < size; i++ ) {
00459         e[i] = 0;
00460     }
00461     e[0] = -1.63488453997962370e+000;
00462     e[1] = 9.91931214905034660e-001;
00463     e[2] = 0.00000000000000000e+000;
00464 }
00465 static void init_vt( lapack_int size, lapack_complex_double *vt ) {
00466     lapack_int i;
00467     for( i = 0; i < size; i++ ) {
00468         vt[i] = lapack_make_complex_double( 0.0, 0.0 );
00469     }
00470     vt[0] = lapack_make_complex_double( -1.25813791844360030e-001,
00471                                         1.61760589514177240e-001 );
00472     vt[8] = lapack_make_complex_double( -2.24667485436357280e-001,
00473                                         3.86428074950534490e-001 );
00474     vt[16] = lapack_make_complex_double( 3.45987927571990260e-001,
00475                                          2.15680786018902980e-001 );
00476     vt[24] = lapack_make_complex_double( -7.09949253978889080e-001,
00477                                          -2.96561080775991640e-001 );
00478     vt[1] = lapack_make_complex_double( 4.14785092219841440e-001,
00479                                         1.79504972515068440e-001 );
00480     vt[9] = lapack_make_complex_double( 1.36782286410614380e-001,
00481                                         -3.97619520383010570e-001 );
00482     vt[17] = lapack_make_complex_double( 6.88479208824614890e-001,
00483                                          3.38638736715237810e-001 );
00484     vt[25] = lapack_make_complex_double( 1.66728569105729860e-001,
00485                                          -4.94204866963832150e-002 );
00486     vt[2] = lapack_make_complex_double( 4.57518505565114970e-001,
00487                                         -4.80657061196396170e-001 );
00488     vt[10] = lapack_make_complex_double( -2.73326699295941440e-001,
00489                                          4.98067456784206160e-001 );
00490     vt[18] = lapack_make_complex_double( -2.29670751731120840e-002,
00491                                          3.86052844703753340e-001 );
00492     vt[26] = lapack_make_complex_double( 1.73047045142453560e-001,
00493                                          2.39493977489214750e-001 );
00494 }
00495 static void init_u( lapack_int size, lapack_complex_double *u ) {
00496     lapack_int i;
00497     for( i = 0; i < size; i++ ) {
00498         u[i] = lapack_make_complex_double( 0.0, 0.0 );
00499     }
00500     u[0] = lapack_make_complex_double( 1.00000000000000000e+000,
00501                                        0.00000000000000000e+000 );
00502     u[8] = lapack_make_complex_double( 0.00000000000000000e+000,
00503                                        0.00000000000000000e+000 );
00504     u[16] = lapack_make_complex_double( 0.00000000000000000e+000,
00505                                         0.00000000000000000e+000 );
00506     u[1] = lapack_make_complex_double( 0.00000000000000000e+000,
00507                                        0.00000000000000000e+000 );
00508     u[9] = lapack_make_complex_double( -5.02026435338565060e-001,
00509                                        -7.57519577948184250e-001 );
00510     u[17] = lapack_make_complex_double( -3.59686703621296070e-001,
00511                                         2.11563282458238110e-001 );
00512     u[2] = lapack_make_complex_double( 0.00000000000000000e+000,
00513                                        0.00000000000000000e+000 );
00514     u[10] = lapack_make_complex_double( -6.32136648022973980e-004,
00515                                         4.17292640301403450e-001 );
00516     u[18] = lapack_make_complex_double( -9.07393061823706050e-001,
00517                                         -5.00428227395494780e-002 );
00518 }
00519 static void init_c( lapack_int size, lapack_complex_double *c ) {
00520     lapack_int i;
00521     for( i = 0; i < size; i++ ) {
00522         c[i] = lapack_make_complex_double( 0.0, 0.0 );
00523     }
00524 }
00525 static void init_work( lapack_int size, double *work ) {
00526     lapack_int i;
00527     for( i = 0; i < size; i++ ) {
00528         work[i] = 0;
00529     }
00530 }
00531 
00532 /* Auxiliary function: C interface to zbdsqr results check */
00533 /* Return value: 0 - test is passed, non-zero - test is failed */
00534 static int compare_zbdsqr( double *d, double *d_i, double *e, double *e_i,
00535                            lapack_complex_double *vt,
00536                            lapack_complex_double *vt_i,
00537                            lapack_complex_double *u, lapack_complex_double *u_i,
00538                            lapack_complex_double *c, lapack_complex_double *c_i,
00539                            lapack_int info, lapack_int info_i, lapack_int ldc,
00540                            lapack_int ldu, lapack_int ldvt, lapack_int n,
00541                            lapack_int ncc, lapack_int ncvt, lapack_int nru )
00542 {
00543     lapack_int i;
00544     int failed = 0;
00545     for( i = 0; i < n; i++ ) {
00546         failed += compare_doubles(d[i],d_i[i]);
00547     }
00548     for( i = 0; i < n; i++ ) {
00549         failed += compare_doubles(e[i],e_i[i]);
00550     }
00551     if( ncvt != 0 ) {
00552         for( i = 0; i < ldvt*ncvt; i++ ) {
00553             failed += compare_complex_doubles(vt[i],vt_i[i]);
00554         }
00555     }
00556     if( nru != 0 ) {
00557         for( i = 0; i < ldu*n; i++ ) {
00558             failed += compare_complex_doubles(u[i],u_i[i]);
00559         }
00560     }
00561     if( ncc != 0 ) {
00562         for( i = 0; i < ldc*ncc; i++ ) {
00563             failed += compare_complex_doubles(c[i],c_i[i]);
00564         }
00565     }
00566     failed += (info == info_i) ? 0 : 1;
00567     if( info != 0 || info_i != 0 ) {
00568         printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00569     }
00570 
00571     return failed;
00572 }


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