cgbbrd_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 * cgbbrd_1 is the test program for the C interface to LAPACK
00036 * routine cgbbrd
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_cgbbrd( char *vect, lapack_int *m, lapack_int *n,
00055                                  lapack_int *ncc, lapack_int *kl,
00056                                  lapack_int *ku, lapack_int *ldab,
00057                                  lapack_int *ldq, lapack_int *ldpt,
00058                                  lapack_int *ldc );
00059 static void init_ab( lapack_int size, lapack_complex_float *ab );
00060 static void init_d( lapack_int size, float *d );
00061 static void init_e( lapack_int size, float *e );
00062 static void init_q( lapack_int size, lapack_complex_float *q );
00063 static void init_pt( lapack_int size, lapack_complex_float *pt );
00064 static void init_c( lapack_int size, lapack_complex_float *c );
00065 static void init_work( lapack_int size, lapack_complex_float *work );
00066 static void init_rwork( lapack_int size, float *rwork );
00067 static int compare_cgbbrd( lapack_complex_float *ab, lapack_complex_float *ab_i,
00068                            float *d, float *d_i, float *e, float *e_i,
00069                            lapack_complex_float *q, lapack_complex_float *q_i,
00070                            lapack_complex_float *pt, lapack_complex_float *pt_i,
00071                            lapack_complex_float *c, lapack_complex_float *c_i,
00072                            lapack_int info, lapack_int info_i, lapack_int ldab,
00073                            lapack_int ldc, lapack_int ldpt, lapack_int ldq,
00074                            lapack_int m, lapack_int n, lapack_int ncc,
00075                            char vect );
00076 
00077 int main(void)
00078 {
00079     /* Local scalars */
00080     char vect, vect_i;
00081     lapack_int m, m_i;
00082     lapack_int n, n_i;
00083     lapack_int ncc, ncc_i;
00084     lapack_int kl, kl_i;
00085     lapack_int ku, ku_i;
00086     lapack_int ldab, ldab_i;
00087     lapack_int ldab_r;
00088     lapack_int ldq, ldq_i;
00089     lapack_int ldq_r;
00090     lapack_int ldpt, ldpt_i;
00091     lapack_int ldpt_r;
00092     lapack_int ldc, ldc_i;
00093     lapack_int ldc_r;
00094     lapack_int info, info_i;
00095     lapack_int i;
00096     int failed;
00097 
00098     /* Local arrays */
00099     lapack_complex_float *ab = NULL, *ab_i = NULL;
00100     float *d = NULL, *d_i = NULL;
00101     float *e = NULL, *e_i = NULL;
00102     lapack_complex_float *q = NULL, *q_i = NULL;
00103     lapack_complex_float *pt = NULL, *pt_i = NULL;
00104     lapack_complex_float *c = NULL, *c_i = NULL;
00105     lapack_complex_float *work = NULL, *work_i = NULL;
00106     float *rwork = NULL, *rwork_i = NULL;
00107     lapack_complex_float *ab_save = NULL;
00108     float *d_save = NULL;
00109     float *e_save = NULL;
00110     lapack_complex_float *q_save = NULL;
00111     lapack_complex_float *pt_save = NULL;
00112     lapack_complex_float *c_save = NULL;
00113     lapack_complex_float *ab_r = NULL;
00114     lapack_complex_float *q_r = NULL;
00115     lapack_complex_float *pt_r = NULL;
00116     lapack_complex_float *c_r = NULL;
00117 
00118     /* Iniitialize the scalar parameters */
00119     init_scalars_cgbbrd( &vect, &m, &n, &ncc, &kl, &ku, &ldab, &ldq, &ldpt,
00120                          &ldc );
00121     ldab_r = n+2;
00122     ldq_r = m+2;
00123     ldpt_r = n+2;
00124     ldc_r = ncc+2;
00125     vect_i = vect;
00126     m_i = m;
00127     n_i = n;
00128     ncc_i = ncc;
00129     kl_i = kl;
00130     ku_i = ku;
00131     ldab_i = ldab;
00132     ldq_i = ldq;
00133     ldpt_i = ldpt;
00134     ldc_i = ldc;
00135 
00136     /* Allocate memory for the LAPACK routine arrays */
00137     ab = (lapack_complex_float *)
00138         LAPACKE_malloc( ldab*n * sizeof(lapack_complex_float) );
00139     d = (float *)LAPACKE_malloc( MIN(m,n) * sizeof(float) );
00140     e = (float *)LAPACKE_malloc( ((MIN(m,n)-1)) * sizeof(float) );
00141     q = (lapack_complex_float *)
00142         LAPACKE_malloc( ldq*m * sizeof(lapack_complex_float) );
00143     pt = (lapack_complex_float *)
00144         LAPACKE_malloc( ldpt*n * sizeof(lapack_complex_float) );
00145     c = (lapack_complex_float *)
00146         LAPACKE_malloc( ldc*ncc * sizeof(lapack_complex_float) );
00147     work = (lapack_complex_float *)
00148         LAPACKE_malloc( MAX(m,n) * sizeof(lapack_complex_float) );
00149     rwork = (float *)LAPACKE_malloc( MAX(m,n) * sizeof(float) );
00150 
00151     /* Allocate memory for the C interface function arrays */
00152     ab_i = (lapack_complex_float *)
00153         LAPACKE_malloc( ldab*n * sizeof(lapack_complex_float) );
00154     d_i = (float *)LAPACKE_malloc( MIN(m,n) * sizeof(float) );
00155     e_i = (float *)LAPACKE_malloc( ((MIN(m,n)-1)) * sizeof(float) );
00156     q_i = (lapack_complex_float *)
00157         LAPACKE_malloc( ldq*m * sizeof(lapack_complex_float) );
00158     pt_i = (lapack_complex_float *)
00159         LAPACKE_malloc( ldpt*n * sizeof(lapack_complex_float) );
00160     c_i = (lapack_complex_float *)
00161         LAPACKE_malloc( ldc*ncc * sizeof(lapack_complex_float) );
00162     work_i = (lapack_complex_float *)
00163         LAPACKE_malloc( MAX(m,n) * sizeof(lapack_complex_float) );
00164     rwork_i = (float *)LAPACKE_malloc( MAX(m,n) * sizeof(float) );
00165 
00166     /* Allocate memory for the backup arrays */
00167     ab_save = (lapack_complex_float *)
00168         LAPACKE_malloc( ldab*n * sizeof(lapack_complex_float) );
00169     d_save = (float *)LAPACKE_malloc( MIN(m,n) * sizeof(float) );
00170     e_save = (float *)LAPACKE_malloc( ((MIN(m,n)-1)) * sizeof(float) );
00171     q_save = (lapack_complex_float *)
00172         LAPACKE_malloc( ldq*m * sizeof(lapack_complex_float) );
00173     pt_save = (lapack_complex_float *)
00174         LAPACKE_malloc( ldpt*n * sizeof(lapack_complex_float) );
00175     c_save = (lapack_complex_float *)
00176         LAPACKE_malloc( ldc*ncc * sizeof(lapack_complex_float) );
00177 
00178     /* Allocate memory for the row-major arrays */
00179     ab_r = (lapack_complex_float *)
00180         LAPACKE_malloc( (kl+ku+1)*(n+2) * sizeof(lapack_complex_float) );
00181     q_r = (lapack_complex_float *)
00182         LAPACKE_malloc( m*(m+2) * sizeof(lapack_complex_float) );
00183     pt_r = (lapack_complex_float *)
00184         LAPACKE_malloc( n*(n+2) * sizeof(lapack_complex_float) );
00185     c_r = (lapack_complex_float *)
00186         LAPACKE_malloc( m*(ncc+2) * sizeof(lapack_complex_float) );
00187 
00188     /* Initialize input arrays */
00189     init_ab( ldab*n, ab );
00190     init_d( (MIN(m,n)), d );
00191     init_e( (MIN(m,n)-1), e );
00192     init_q( ldq*m, q );
00193     init_pt( ldpt*n, pt );
00194     init_c( ldc*ncc, c );
00195     init_work( (MAX(m,n)), work );
00196     init_rwork( (MAX(m,n)), rwork );
00197 
00198     /* Backup the ouptut arrays */
00199     for( i = 0; i < ldab*n; i++ ) {
00200         ab_save[i] = ab[i];
00201     }
00202     for( i = 0; i < (MIN(m,n)); i++ ) {
00203         d_save[i] = d[i];
00204     }
00205     for( i = 0; i < (MIN(m,n)-1); i++ ) {
00206         e_save[i] = e[i];
00207     }
00208     for( i = 0; i < ldq*m; i++ ) {
00209         q_save[i] = q[i];
00210     }
00211     for( i = 0; i < ldpt*n; i++ ) {
00212         pt_save[i] = pt[i];
00213     }
00214     for( i = 0; i < ldc*ncc; i++ ) {
00215         c_save[i] = c[i];
00216     }
00217 
00218     /* Call the LAPACK routine */
00219     cgbbrd_( &vect, &m, &n, &ncc, &kl, &ku, ab, &ldab, d, e, q, &ldq, pt, &ldpt,
00220              c, &ldc, work, rwork, &info );
00221 
00222     /* Initialize input data, call the column-major middle-level
00223      * interface to LAPACK routine and check the results */
00224     for( i = 0; i < ldab*n; i++ ) {
00225         ab_i[i] = ab_save[i];
00226     }
00227     for( i = 0; i < (MIN(m,n)); i++ ) {
00228         d_i[i] = d_save[i];
00229     }
00230     for( i = 0; i < (MIN(m,n)-1); i++ ) {
00231         e_i[i] = e_save[i];
00232     }
00233     for( i = 0; i < ldq*m; i++ ) {
00234         q_i[i] = q_save[i];
00235     }
00236     for( i = 0; i < ldpt*n; i++ ) {
00237         pt_i[i] = pt_save[i];
00238     }
00239     for( i = 0; i < ldc*ncc; i++ ) {
00240         c_i[i] = c_save[i];
00241     }
00242     for( i = 0; i < (MAX(m,n)); i++ ) {
00243         work_i[i] = work[i];
00244     }
00245     for( i = 0; i < (MAX(m,n)); i++ ) {
00246         rwork_i[i] = rwork[i];
00247     }
00248     info_i = LAPACKE_cgbbrd_work( LAPACK_COL_MAJOR, vect_i, m_i, n_i, ncc_i,
00249                                   kl_i, ku_i, ab_i, ldab_i, d_i, e_i, q_i,
00250                                   ldq_i, pt_i, ldpt_i, c_i, ldc_i, work_i,
00251                                   rwork_i );
00252 
00253     failed = compare_cgbbrd( ab, ab_i, d, d_i, e, e_i, q, q_i, pt, pt_i, c, c_i,
00254                              info, info_i, ldab, ldc, ldpt, ldq, m, n, ncc,
00255                              vect );
00256     if( failed == 0 ) {
00257         printf( "PASSED: column-major middle-level interface to cgbbrd\n" );
00258     } else {
00259         printf( "FAILED: column-major middle-level interface to cgbbrd\n" );
00260     }
00261 
00262     /* Initialize input data, call the column-major high-level
00263      * interface to LAPACK routine and check the results */
00264     for( i = 0; i < ldab*n; i++ ) {
00265         ab_i[i] = ab_save[i];
00266     }
00267     for( i = 0; i < (MIN(m,n)); i++ ) {
00268         d_i[i] = d_save[i];
00269     }
00270     for( i = 0; i < (MIN(m,n)-1); i++ ) {
00271         e_i[i] = e_save[i];
00272     }
00273     for( i = 0; i < ldq*m; i++ ) {
00274         q_i[i] = q_save[i];
00275     }
00276     for( i = 0; i < ldpt*n; i++ ) {
00277         pt_i[i] = pt_save[i];
00278     }
00279     for( i = 0; i < ldc*ncc; i++ ) {
00280         c_i[i] = c_save[i];
00281     }
00282     for( i = 0; i < (MAX(m,n)); i++ ) {
00283         work_i[i] = work[i];
00284     }
00285     for( i = 0; i < (MAX(m,n)); i++ ) {
00286         rwork_i[i] = rwork[i];
00287     }
00288     info_i = LAPACKE_cgbbrd( LAPACK_COL_MAJOR, vect_i, m_i, n_i, ncc_i, kl_i,
00289                              ku_i, ab_i, ldab_i, d_i, e_i, q_i, ldq_i, pt_i,
00290                              ldpt_i, c_i, ldc_i );
00291 
00292     failed = compare_cgbbrd( ab, ab_i, d, d_i, e, e_i, q, q_i, pt, pt_i, c, c_i,
00293                              info, info_i, ldab, ldc, ldpt, ldq, m, n, ncc,
00294                              vect );
00295     if( failed == 0 ) {
00296         printf( "PASSED: column-major high-level interface to cgbbrd\n" );
00297     } else {
00298         printf( "FAILED: column-major high-level interface to cgbbrd\n" );
00299     }
00300 
00301     /* Initialize input data, call the row-major middle-level
00302      * interface to LAPACK routine and check the results */
00303     for( i = 0; i < ldab*n; i++ ) {
00304         ab_i[i] = ab_save[i];
00305     }
00306     for( i = 0; i < (MIN(m,n)); i++ ) {
00307         d_i[i] = d_save[i];
00308     }
00309     for( i = 0; i < (MIN(m,n)-1); i++ ) {
00310         e_i[i] = e_save[i];
00311     }
00312     for( i = 0; i < ldq*m; i++ ) {
00313         q_i[i] = q_save[i];
00314     }
00315     for( i = 0; i < ldpt*n; i++ ) {
00316         pt_i[i] = pt_save[i];
00317     }
00318     for( i = 0; i < ldc*ncc; i++ ) {
00319         c_i[i] = c_save[i];
00320     }
00321     for( i = 0; i < (MAX(m,n)); i++ ) {
00322         work_i[i] = work[i];
00323     }
00324     for( i = 0; i < (MAX(m,n)); i++ ) {
00325         rwork_i[i] = rwork[i];
00326     }
00327 
00328     LAPACKE_cge_trans( LAPACK_COL_MAJOR, kl+ku+1, n, ab_i, ldab, ab_r, n+2 );
00329     if( LAPACKE_lsame( vect, 'b' ) || LAPACKE_lsame( vect, 'q' ) ) {
00330         LAPACKE_cge_trans( LAPACK_COL_MAJOR, m, m, q_i, ldq, q_r, m+2 );
00331     }
00332     if( LAPACKE_lsame( vect, 'b' ) || LAPACKE_lsame( vect, 'p' ) ) {
00333         LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, n, pt_i, ldpt, pt_r, n+2 );
00334     }
00335     if( ncc != 0 ) {
00336         LAPACKE_cge_trans( LAPACK_COL_MAJOR, m, ncc, c_i, ldc, c_r, ncc+2 );
00337     }
00338     info_i = LAPACKE_cgbbrd_work( LAPACK_ROW_MAJOR, vect_i, m_i, n_i, ncc_i,
00339                                   kl_i, ku_i, ab_r, ldab_r, d_i, e_i, q_r,
00340                                   ldq_r, pt_r, ldpt_r, c_r, ldc_r, work_i,
00341                                   rwork_i );
00342 
00343     LAPACKE_cge_trans( LAPACK_ROW_MAJOR, kl+ku+1, n, ab_r, n+2, ab_i, ldab );
00344     if( LAPACKE_lsame( vect, 'b' ) || LAPACKE_lsame( vect, 'q' ) ) {
00345         LAPACKE_cge_trans( LAPACK_ROW_MAJOR, m, m, q_r, m+2, q_i, ldq );
00346     }
00347     if( LAPACKE_lsame( vect, 'b' ) || LAPACKE_lsame( vect, 'p' ) ) {
00348         LAPACKE_cge_trans( LAPACK_ROW_MAJOR, n, n, pt_r, n+2, pt_i, ldpt );
00349     }
00350     if( ncc != 0 ) {
00351         LAPACKE_cge_trans( LAPACK_ROW_MAJOR, m, ncc, c_r, ncc+2, c_i, ldc );
00352     }
00353 
00354     failed = compare_cgbbrd( ab, ab_i, d, d_i, e, e_i, q, q_i, pt, pt_i, c, c_i,
00355                              info, info_i, ldab, ldc, ldpt, ldq, m, n, ncc,
00356                              vect );
00357     if( failed == 0 ) {
00358         printf( "PASSED: row-major middle-level interface to cgbbrd\n" );
00359     } else {
00360         printf( "FAILED: row-major middle-level interface to cgbbrd\n" );
00361     }
00362 
00363     /* Initialize input data, call the row-major high-level
00364      * interface to LAPACK routine and check the results */
00365     for( i = 0; i < ldab*n; i++ ) {
00366         ab_i[i] = ab_save[i];
00367     }
00368     for( i = 0; i < (MIN(m,n)); i++ ) {
00369         d_i[i] = d_save[i];
00370     }
00371     for( i = 0; i < (MIN(m,n)-1); i++ ) {
00372         e_i[i] = e_save[i];
00373     }
00374     for( i = 0; i < ldq*m; i++ ) {
00375         q_i[i] = q_save[i];
00376     }
00377     for( i = 0; i < ldpt*n; i++ ) {
00378         pt_i[i] = pt_save[i];
00379     }
00380     for( i = 0; i < ldc*ncc; i++ ) {
00381         c_i[i] = c_save[i];
00382     }
00383     for( i = 0; i < (MAX(m,n)); i++ ) {
00384         work_i[i] = work[i];
00385     }
00386     for( i = 0; i < (MAX(m,n)); i++ ) {
00387         rwork_i[i] = rwork[i];
00388     }
00389 
00390     /* Init row_major arrays */
00391     LAPACKE_cge_trans( LAPACK_COL_MAJOR, kl+ku+1, n, ab_i, ldab, ab_r, n+2 );
00392     if( LAPACKE_lsame( vect, 'b' ) || LAPACKE_lsame( vect, 'q' ) ) {
00393         LAPACKE_cge_trans( LAPACK_COL_MAJOR, m, m, q_i, ldq, q_r, m+2 );
00394     }
00395     if( LAPACKE_lsame( vect, 'b' ) || LAPACKE_lsame( vect, 'p' ) ) {
00396         LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, n, pt_i, ldpt, pt_r, n+2 );
00397     }
00398     if( ncc != 0 ) {
00399         LAPACKE_cge_trans( LAPACK_COL_MAJOR, m, ncc, c_i, ldc, c_r, ncc+2 );
00400     }
00401     info_i = LAPACKE_cgbbrd( LAPACK_ROW_MAJOR, vect_i, m_i, n_i, ncc_i, kl_i,
00402                              ku_i, ab_r, ldab_r, d_i, e_i, q_r, ldq_r, pt_r,
00403                              ldpt_r, c_r, ldc_r );
00404 
00405     LAPACKE_cge_trans( LAPACK_ROW_MAJOR, kl+ku+1, n, ab_r, n+2, ab_i, ldab );
00406     if( LAPACKE_lsame( vect, 'b' ) || LAPACKE_lsame( vect, 'q' ) ) {
00407         LAPACKE_cge_trans( LAPACK_ROW_MAJOR, m, m, q_r, m+2, q_i, ldq );
00408     }
00409     if( LAPACKE_lsame( vect, 'b' ) || LAPACKE_lsame( vect, 'p' ) ) {
00410         LAPACKE_cge_trans( LAPACK_ROW_MAJOR, n, n, pt_r, n+2, pt_i, ldpt );
00411     }
00412     if( ncc != 0 ) {
00413         LAPACKE_cge_trans( LAPACK_ROW_MAJOR, m, ncc, c_r, ncc+2, c_i, ldc );
00414     }
00415 
00416     failed = compare_cgbbrd( ab, ab_i, d, d_i, e, e_i, q, q_i, pt, pt_i, c, c_i,
00417                              info, info_i, ldab, ldc, ldpt, ldq, m, n, ncc,
00418                              vect );
00419     if( failed == 0 ) {
00420         printf( "PASSED: row-major high-level interface to cgbbrd\n" );
00421     } else {
00422         printf( "FAILED: row-major high-level interface to cgbbrd\n" );
00423     }
00424 
00425     /* Release memory */
00426     if( ab != NULL ) {
00427         LAPACKE_free( ab );
00428     }
00429     if( ab_i != NULL ) {
00430         LAPACKE_free( ab_i );
00431     }
00432     if( ab_r != NULL ) {
00433         LAPACKE_free( ab_r );
00434     }
00435     if( ab_save != NULL ) {
00436         LAPACKE_free( ab_save );
00437     }
00438     if( d != NULL ) {
00439         LAPACKE_free( d );
00440     }
00441     if( d_i != NULL ) {
00442         LAPACKE_free( d_i );
00443     }
00444     if( d_save != NULL ) {
00445         LAPACKE_free( d_save );
00446     }
00447     if( e != NULL ) {
00448         LAPACKE_free( e );
00449     }
00450     if( e_i != NULL ) {
00451         LAPACKE_free( e_i );
00452     }
00453     if( e_save != NULL ) {
00454         LAPACKE_free( e_save );
00455     }
00456     if( q != NULL ) {
00457         LAPACKE_free( q );
00458     }
00459     if( q_i != NULL ) {
00460         LAPACKE_free( q_i );
00461     }
00462     if( q_r != NULL ) {
00463         LAPACKE_free( q_r );
00464     }
00465     if( q_save != NULL ) {
00466         LAPACKE_free( q_save );
00467     }
00468     if( pt != NULL ) {
00469         LAPACKE_free( pt );
00470     }
00471     if( pt_i != NULL ) {
00472         LAPACKE_free( pt_i );
00473     }
00474     if( pt_r != NULL ) {
00475         LAPACKE_free( pt_r );
00476     }
00477     if( pt_save != NULL ) {
00478         LAPACKE_free( pt_save );
00479     }
00480     if( c != NULL ) {
00481         LAPACKE_free( c );
00482     }
00483     if( c_i != NULL ) {
00484         LAPACKE_free( c_i );
00485     }
00486     if( c_r != NULL ) {
00487         LAPACKE_free( c_r );
00488     }
00489     if( c_save != NULL ) {
00490         LAPACKE_free( c_save );
00491     }
00492     if( work != NULL ) {
00493         LAPACKE_free( work );
00494     }
00495     if( work_i != NULL ) {
00496         LAPACKE_free( work_i );
00497     }
00498     if( rwork != NULL ) {
00499         LAPACKE_free( rwork );
00500     }
00501     if( rwork_i != NULL ) {
00502         LAPACKE_free( rwork_i );
00503     }
00504 
00505     return 0;
00506 }
00507 
00508 /* Auxiliary function: cgbbrd scalar parameters initialization */
00509 static void init_scalars_cgbbrd( char *vect, lapack_int *m, lapack_int *n,
00510                                  lapack_int *ncc, lapack_int *kl,
00511                                  lapack_int *ku, lapack_int *ldab,
00512                                  lapack_int *ldq, lapack_int *ldpt,
00513                                  lapack_int *ldc )
00514 {
00515     *vect = 'N';
00516     *m = 6;
00517     *n = 4;
00518     *ncc = 0;
00519     *kl = 2;
00520     *ku = 1;
00521     *ldab = 17;
00522     *ldq = 8;
00523     *ldpt = 8;
00524     *ldc = 8;
00525 
00526     return;
00527 }
00528 
00529 /* Auxiliary functions: cgbbrd array parameters initialization */
00530 static void init_ab( lapack_int size, lapack_complex_float *ab ) {
00531     lapack_int i;
00532     for( i = 0; i < size; i++ ) {
00533         ab[i] = lapack_make_complex_float( 0.0f, 0.0f );
00534     }
00535     ab[0] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00536     ab[17] = lapack_make_complex_float( -2.999999933e-002, 9.599999785e-001 );
00537     ab[34] = lapack_make_complex_float( -6.600000262e-001, 4.199999869e-001 );
00538     ab[51] = lapack_make_complex_float( -1.110000014e+000, 6.000000238e-001 );
00539     ab[1] = lapack_make_complex_float( 9.599999785e-001, -8.100000024e-001 );
00540     ab[18] = lapack_make_complex_float( -1.200000048e+000, 1.899999976e-001 );
00541     ab[35] = lapack_make_complex_float( 6.299999952e-001, -1.700000018e-001 );
00542     ab[52] = lapack_make_complex_float( 2.199999988e-001, -2.000000030e-001 );
00543     ab[2] = lapack_make_complex_float( -9.800000191e-001, 1.980000019e+000 );
00544     ab[19] = lapack_make_complex_float( 1.009999990e+000, 1.999999955e-002 );
00545     ab[36] = lapack_make_complex_float( -9.800000191e-001, -3.600000143e-001 );
00546     ab[53] = lapack_make_complex_float( 1.470000029e+000, 1.590000033e+000 );
00547     ab[3] = lapack_make_complex_float( 6.200000048e-001, -4.600000083e-001 );
00548     ab[20] = lapack_make_complex_float( 1.899999976e-001, -5.400000215e-001 );
00549     ab[37] = lapack_make_complex_float( -1.700000018e-001, -4.600000083e-001 );
00550     ab[54] = lapack_make_complex_float( 2.599999905e-001, 2.599999905e-001 );
00551 }
00552 static void init_d( lapack_int size, float *d ) {
00553     lapack_int i;
00554     for( i = 0; i < size; i++ ) {
00555         d[i] = 0;
00556     }
00557 }
00558 static void init_e( lapack_int size, float *e ) {
00559     lapack_int i;
00560     for( i = 0; i < size; i++ ) {
00561         e[i] = 0;
00562     }
00563 }
00564 static void init_q( lapack_int size, lapack_complex_float *q ) {
00565     lapack_int i;
00566     for( i = 0; i < size; i++ ) {
00567         q[i] = lapack_make_complex_float( 0.0f, 0.0f );
00568     }
00569 }
00570 static void init_pt( lapack_int size, lapack_complex_float *pt ) {
00571     lapack_int i;
00572     for( i = 0; i < size; i++ ) {
00573         pt[i] = lapack_make_complex_float( 0.0f, 0.0f );
00574     }
00575 }
00576 static void init_c( lapack_int size, lapack_complex_float *c ) {
00577     lapack_int i;
00578     for( i = 0; i < size; i++ ) {
00579         c[i] = lapack_make_complex_float( 0.0f, 0.0f );
00580     }
00581 }
00582 static void init_work( lapack_int size, lapack_complex_float *work ) {
00583     lapack_int i;
00584     for( i = 0; i < size; i++ ) {
00585         work[i] = lapack_make_complex_float( 0.0f, 0.0f );
00586     }
00587 }
00588 static void init_rwork( lapack_int size, float *rwork ) {
00589     lapack_int i;
00590     for( i = 0; i < size; i++ ) {
00591         rwork[i] = 0;
00592     }
00593 }
00594 
00595 /* Auxiliary function: C interface to cgbbrd results check */
00596 /* Return value: 0 - test is passed, non-zero - test is failed */
00597 static int compare_cgbbrd( lapack_complex_float *ab, lapack_complex_float *ab_i,
00598                            float *d, float *d_i, float *e, float *e_i,
00599                            lapack_complex_float *q, lapack_complex_float *q_i,
00600                            lapack_complex_float *pt, lapack_complex_float *pt_i,
00601                            lapack_complex_float *c, lapack_complex_float *c_i,
00602                            lapack_int info, lapack_int info_i, lapack_int ldab,
00603                            lapack_int ldc, lapack_int ldpt, lapack_int ldq,
00604                            lapack_int m, lapack_int n, lapack_int ncc,
00605                            char vect )
00606 {
00607     lapack_int i;
00608     int failed = 0;
00609     for( i = 0; i < ldab*n; i++ ) {
00610         failed += compare_complex_floats(ab[i],ab_i[i]);
00611     }
00612     for( i = 0; i < (MIN(m,n)); i++ ) {
00613         failed += compare_floats(d[i],d_i[i]);
00614     }
00615     for( i = 0; i < (MIN(m,n)-1); i++ ) {
00616         failed += compare_floats(e[i],e_i[i]);
00617     }
00618     if( LAPACKE_lsame( vect, 'b' ) || LAPACKE_lsame( vect, 'q' ) ) {
00619         for( i = 0; i < ldq*m; i++ ) {
00620             failed += compare_complex_floats(q[i],q_i[i]);
00621         }
00622     }
00623     if( LAPACKE_lsame( vect, 'b' ) || LAPACKE_lsame( vect, 'p' ) ) {
00624         for( i = 0; i < ldpt*n; i++ ) {
00625             failed += compare_complex_floats(pt[i],pt_i[i]);
00626         }
00627     }
00628     if( ncc != 0 ) {
00629         for( i = 0; i < ldc*ncc; i++ ) {
00630             failed += compare_complex_floats(c[i],c_i[i]);
00631         }
00632     }
00633     failed += (info == info_i) ? 0 : 1;
00634     if( info != 0 || info_i != 0 ) {
00635         printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00636     }
00637 
00638     return failed;
00639 }


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