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


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