chsein_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 * chsein_1 is the test program for the C interface to LAPACK
00036 * routine chsein
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_chsein( char *job, char *eigsrc, char *initv,
00055                                  lapack_int *n, lapack_int *ldh,
00056                                  lapack_int *ldvl, lapack_int *ldvr,
00057                                  lapack_int *mm );
00058 static void init_select( lapack_int size, lapack_int *select );
00059 static void init_h( lapack_int size, lapack_complex_float *h );
00060 static void init_w( lapack_int size, lapack_complex_float *w );
00061 static void init_vl( lapack_int size, lapack_complex_float *vl );
00062 static void init_vr( lapack_int size, lapack_complex_float *vr );
00063 static void init_work( lapack_int size, lapack_complex_float *work );
00064 static void init_rwork( lapack_int size, float *rwork );
00065 static void init_ifaill( lapack_int size, lapack_int *ifaill );
00066 static void init_ifailr( lapack_int size, lapack_int *ifailr );
00067 static int compare_chsein( lapack_complex_float *w, lapack_complex_float *w_i,
00068                            lapack_complex_float *vl, lapack_complex_float *vl_i,
00069                            lapack_complex_float *vr, lapack_complex_float *vr_i,
00070                            lapack_int m, lapack_int m_i, lapack_int *ifaill,
00071                            lapack_int *ifaill_i, lapack_int *ifailr,
00072                            lapack_int *ifailr_i, lapack_int info,
00073                            lapack_int info_i, char job, lapack_int ldvl,
00074                            lapack_int ldvr, lapack_int mm, lapack_int n );
00075 
00076 int main(void)
00077 {
00078     /* Local scalars */
00079     char job, job_i;
00080     char eigsrc, eigsrc_i;
00081     char initv, initv_i;
00082     lapack_int n, n_i;
00083     lapack_int ldh, ldh_i;
00084     lapack_int ldh_r;
00085     lapack_int ldvl, ldvl_i;
00086     lapack_int ldvl_r;
00087     lapack_int ldvr, ldvr_i;
00088     lapack_int ldvr_r;
00089     lapack_int mm, mm_i;
00090     lapack_int m, m_i;
00091     lapack_int info, info_i;
00092     lapack_int i;
00093     int failed;
00094 
00095     /* Local arrays */
00096     lapack_int *select = NULL, *select_i = NULL;
00097     lapack_complex_float *h = NULL, *h_i = NULL;
00098     lapack_complex_float *w = NULL, *w_i = NULL;
00099     lapack_complex_float *vl = NULL, *vl_i = NULL;
00100     lapack_complex_float *vr = NULL, *vr_i = NULL;
00101     lapack_complex_float *work = NULL, *work_i = NULL;
00102     float *rwork = NULL, *rwork_i = NULL;
00103     lapack_int *ifaill = NULL, *ifaill_i = NULL;
00104     lapack_int *ifailr = NULL, *ifailr_i = NULL;
00105     lapack_complex_float *w_save = NULL;
00106     lapack_complex_float *vl_save = NULL;
00107     lapack_complex_float *vr_save = NULL;
00108     lapack_int *ifaill_save = NULL;
00109     lapack_int *ifailr_save = NULL;
00110     lapack_complex_float *h_r = NULL;
00111     lapack_complex_float *vl_r = NULL;
00112     lapack_complex_float *vr_r = NULL;
00113 
00114     /* Iniitialize the scalar parameters */
00115     init_scalars_chsein( &job, &eigsrc, &initv, &n, &ldh, &ldvl, &ldvr, &mm );
00116     ldh_r = n+2;
00117     ldvl_r = mm+2;
00118     ldvr_r = mm+2;
00119     job_i = job;
00120     eigsrc_i = eigsrc;
00121     initv_i = initv;
00122     n_i = n;
00123     ldh_i = ldh;
00124     ldvl_i = ldvl;
00125     ldvr_i = ldvr;
00126     mm_i = mm;
00127 
00128     /* Allocate memory for the LAPACK routine arrays */
00129     select = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
00130     h = (lapack_complex_float *)
00131         LAPACKE_malloc( ldh*n * sizeof(lapack_complex_float) );
00132     w = (lapack_complex_float *)
00133         LAPACKE_malloc( n * sizeof(lapack_complex_float) );
00134     vl = (lapack_complex_float *)
00135         LAPACKE_malloc( ldvl*mm * sizeof(lapack_complex_float) );
00136     vr = (lapack_complex_float *)
00137         LAPACKE_malloc( ldvr*mm * sizeof(lapack_complex_float) );
00138     work = (lapack_complex_float *)
00139         LAPACKE_malloc( n*n * sizeof(lapack_complex_float) );
00140     rwork = (float *)LAPACKE_malloc( n * sizeof(float) );
00141     ifaill = (lapack_int *)LAPACKE_malloc( mm * sizeof(lapack_int) );
00142     ifailr = (lapack_int *)LAPACKE_malloc( mm * sizeof(lapack_int) );
00143 
00144     /* Allocate memory for the C interface function arrays */
00145     select_i = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
00146     h_i = (lapack_complex_float *)
00147         LAPACKE_malloc( ldh*n * sizeof(lapack_complex_float) );
00148     w_i = (lapack_complex_float *)
00149         LAPACKE_malloc( n * sizeof(lapack_complex_float) );
00150     vl_i = (lapack_complex_float *)
00151         LAPACKE_malloc( ldvl*mm * sizeof(lapack_complex_float) );
00152     vr_i = (lapack_complex_float *)
00153         LAPACKE_malloc( ldvr*mm * sizeof(lapack_complex_float) );
00154     work_i = (lapack_complex_float *)
00155         LAPACKE_malloc( n*n * sizeof(lapack_complex_float) );
00156     rwork_i = (float *)LAPACKE_malloc( n * sizeof(float) );
00157     ifaill_i = (lapack_int *)LAPACKE_malloc( mm * sizeof(lapack_int) );
00158     ifailr_i = (lapack_int *)LAPACKE_malloc( mm * sizeof(lapack_int) );
00159 
00160     /* Allocate memory for the backup arrays */
00161     w_save = (lapack_complex_float *)
00162         LAPACKE_malloc( n * sizeof(lapack_complex_float) );
00163     vl_save = (lapack_complex_float *)
00164         LAPACKE_malloc( ldvl*mm * sizeof(lapack_complex_float) );
00165     vr_save = (lapack_complex_float *)
00166         LAPACKE_malloc( ldvr*mm * sizeof(lapack_complex_float) );
00167     ifaill_save = (lapack_int *)LAPACKE_malloc( mm * sizeof(lapack_int) );
00168     ifailr_save = (lapack_int *)LAPACKE_malloc( mm * sizeof(lapack_int) );
00169 
00170     /* Allocate memory for the row-major arrays */
00171     h_r = (lapack_complex_float *)
00172         LAPACKE_malloc( n*(n+2) * sizeof(lapack_complex_float) );
00173     vl_r = (lapack_complex_float *)
00174         LAPACKE_malloc( n*(mm+2) * sizeof(lapack_complex_float) );
00175     vr_r = (lapack_complex_float *)
00176         LAPACKE_malloc( n*(mm+2) * sizeof(lapack_complex_float) );
00177 
00178     /* Initialize input arrays */
00179     init_select( n, select );
00180     init_h( ldh*n, h );
00181     init_w( n, w );
00182     init_vl( ldvl*mm, vl );
00183     init_vr( ldvr*mm, vr );
00184     init_work( n*n, work );
00185     init_rwork( n, rwork );
00186     init_ifaill( mm, ifaill );
00187     init_ifailr( mm, ifailr );
00188 
00189     /* Backup the ouptut arrays */
00190     for( i = 0; i < n; i++ ) {
00191         w_save[i] = w[i];
00192     }
00193     for( i = 0; i < ldvl*mm; i++ ) {
00194         vl_save[i] = vl[i];
00195     }
00196     for( i = 0; i < ldvr*mm; i++ ) {
00197         vr_save[i] = vr[i];
00198     }
00199     for( i = 0; i < mm; i++ ) {
00200         ifaill_save[i] = ifaill[i];
00201     }
00202     for( i = 0; i < mm; i++ ) {
00203         ifailr_save[i] = ifailr[i];
00204     }
00205 
00206     /* Call the LAPACK routine */
00207     chsein_( &job, &eigsrc, &initv, select, &n, h, &ldh, w, vl, &ldvl, vr,
00208              &ldvr, &mm, &m, work, rwork, ifaill, ifailr, &info );
00209 
00210     /* Initialize input data, call the column-major middle-level
00211      * interface to LAPACK routine and check the results */
00212     for( i = 0; i < n; i++ ) {
00213         select_i[i] = select[i];
00214     }
00215     for( i = 0; i < ldh*n; i++ ) {
00216         h_i[i] = h[i];
00217     }
00218     for( i = 0; i < n; i++ ) {
00219         w_i[i] = w_save[i];
00220     }
00221     for( i = 0; i < ldvl*mm; i++ ) {
00222         vl_i[i] = vl_save[i];
00223     }
00224     for( i = 0; i < ldvr*mm; i++ ) {
00225         vr_i[i] = vr_save[i];
00226     }
00227     for( i = 0; i < n*n; i++ ) {
00228         work_i[i] = work[i];
00229     }
00230     for( i = 0; i < n; i++ ) {
00231         rwork_i[i] = rwork[i];
00232     }
00233     for( i = 0; i < mm; i++ ) {
00234         ifaill_i[i] = ifaill_save[i];
00235     }
00236     for( i = 0; i < mm; i++ ) {
00237         ifailr_i[i] = ifailr_save[i];
00238     }
00239     info_i = LAPACKE_chsein_work( LAPACK_COL_MAJOR, job_i, eigsrc_i, initv_i,
00240                                   select_i, n_i, h_i, ldh_i, w_i, vl_i, ldvl_i,
00241                                   vr_i, ldvr_i, mm_i, &m_i, work_i, rwork_i,
00242                                   ifaill_i, ifailr_i );
00243 
00244     failed = compare_chsein( w, w_i, vl, vl_i, vr, vr_i, m, m_i, ifaill,
00245                              ifaill_i, ifailr, ifailr_i, info, info_i, job,
00246                              ldvl, ldvr, mm, n );
00247     if( failed == 0 ) {
00248         printf( "PASSED: column-major middle-level interface to chsein\n" );
00249     } else {
00250         printf( "FAILED: column-major middle-level interface to chsein\n" );
00251     }
00252 
00253     /* Initialize input data, call the column-major high-level
00254      * interface to LAPACK routine and check the results */
00255     for( i = 0; i < n; i++ ) {
00256         select_i[i] = select[i];
00257     }
00258     for( i = 0; i < ldh*n; i++ ) {
00259         h_i[i] = h[i];
00260     }
00261     for( i = 0; i < n; i++ ) {
00262         w_i[i] = w_save[i];
00263     }
00264     for( i = 0; i < ldvl*mm; i++ ) {
00265         vl_i[i] = vl_save[i];
00266     }
00267     for( i = 0; i < ldvr*mm; i++ ) {
00268         vr_i[i] = vr_save[i];
00269     }
00270     for( i = 0; i < n*n; i++ ) {
00271         work_i[i] = work[i];
00272     }
00273     for( i = 0; i < n; i++ ) {
00274         rwork_i[i] = rwork[i];
00275     }
00276     for( i = 0; i < mm; i++ ) {
00277         ifaill_i[i] = ifaill_save[i];
00278     }
00279     for( i = 0; i < mm; i++ ) {
00280         ifailr_i[i] = ifailr_save[i];
00281     }
00282     info_i = LAPACKE_chsein( LAPACK_COL_MAJOR, job_i, eigsrc_i, initv_i,
00283                              select_i, n_i, h_i, ldh_i, w_i, vl_i, ldvl_i, vr_i,
00284                              ldvr_i, mm_i, &m_i, ifaill_i, ifailr_i );
00285 
00286     failed = compare_chsein( w, w_i, vl, vl_i, vr, vr_i, m, m_i, ifaill,
00287                              ifaill_i, ifailr, ifailr_i, info, info_i, job,
00288                              ldvl, ldvr, mm, n );
00289     if( failed == 0 ) {
00290         printf( "PASSED: column-major high-level interface to chsein\n" );
00291     } else {
00292         printf( "FAILED: column-major high-level interface to chsein\n" );
00293     }
00294 
00295     /* Initialize input data, call the row-major middle-level
00296      * interface to LAPACK routine and check the results */
00297     for( i = 0; i < n; i++ ) {
00298         select_i[i] = select[i];
00299     }
00300     for( i = 0; i < ldh*n; i++ ) {
00301         h_i[i] = h[i];
00302     }
00303     for( i = 0; i < n; i++ ) {
00304         w_i[i] = w_save[i];
00305     }
00306     for( i = 0; i < ldvl*mm; i++ ) {
00307         vl_i[i] = vl_save[i];
00308     }
00309     for( i = 0; i < ldvr*mm; i++ ) {
00310         vr_i[i] = vr_save[i];
00311     }
00312     for( i = 0; i < n*n; i++ ) {
00313         work_i[i] = work[i];
00314     }
00315     for( i = 0; i < n; i++ ) {
00316         rwork_i[i] = rwork[i];
00317     }
00318     for( i = 0; i < mm; i++ ) {
00319         ifaill_i[i] = ifaill_save[i];
00320     }
00321     for( i = 0; i < mm; i++ ) {
00322         ifailr_i[i] = ifailr_save[i];
00323     }
00324 
00325     LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, n, h_i, ldh, h_r, n+2 );
00326     if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'l' ) ) {
00327         LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, mm, vl_i, ldvl, vl_r, mm+2 );
00328     }
00329     if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'r' ) ) {
00330         LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, mm, vr_i, ldvr, vr_r, mm+2 );
00331     }
00332     info_i = LAPACKE_chsein_work( LAPACK_ROW_MAJOR, job_i, eigsrc_i, initv_i,
00333                                   select_i, n_i, h_r, ldh_r, w_i, vl_r, ldvl_r,
00334                                   vr_r, ldvr_r, mm_i, &m_i, work_i, rwork_i,
00335                                   ifaill_i, ifailr_i );
00336 
00337     if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'l' ) ) {
00338         LAPACKE_cge_trans( LAPACK_ROW_MAJOR, n, mm, vl_r, mm+2, vl_i, ldvl );
00339     }
00340     if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'r' ) ) {
00341         LAPACKE_cge_trans( LAPACK_ROW_MAJOR, n, mm, vr_r, mm+2, vr_i, ldvr );
00342     }
00343 
00344     failed = compare_chsein( w, w_i, vl, vl_i, vr, vr_i, m, m_i, ifaill,
00345                              ifaill_i, ifailr, ifailr_i, info, info_i, job,
00346                              ldvl, ldvr, mm, n );
00347     if( failed == 0 ) {
00348         printf( "PASSED: row-major middle-level interface to chsein\n" );
00349     } else {
00350         printf( "FAILED: row-major middle-level interface to chsein\n" );
00351     }
00352 
00353     /* Initialize input data, call the row-major high-level
00354      * interface to LAPACK routine and check the results */
00355     for( i = 0; i < n; i++ ) {
00356         select_i[i] = select[i];
00357     }
00358     for( i = 0; i < ldh*n; i++ ) {
00359         h_i[i] = h[i];
00360     }
00361     for( i = 0; i < n; i++ ) {
00362         w_i[i] = w_save[i];
00363     }
00364     for( i = 0; i < ldvl*mm; i++ ) {
00365         vl_i[i] = vl_save[i];
00366     }
00367     for( i = 0; i < ldvr*mm; i++ ) {
00368         vr_i[i] = vr_save[i];
00369     }
00370     for( i = 0; i < n*n; i++ ) {
00371         work_i[i] = work[i];
00372     }
00373     for( i = 0; i < n; i++ ) {
00374         rwork_i[i] = rwork[i];
00375     }
00376     for( i = 0; i < mm; i++ ) {
00377         ifaill_i[i] = ifaill_save[i];
00378     }
00379     for( i = 0; i < mm; i++ ) {
00380         ifailr_i[i] = ifailr_save[i];
00381     }
00382 
00383     /* Init row_major arrays */
00384     LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, n, h_i, ldh, h_r, n+2 );
00385     if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'l' ) ) {
00386         LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, mm, vl_i, ldvl, vl_r, mm+2 );
00387     }
00388     if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'r' ) ) {
00389         LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, mm, vr_i, ldvr, vr_r, mm+2 );
00390     }
00391     info_i = LAPACKE_chsein( LAPACK_ROW_MAJOR, job_i, eigsrc_i, initv_i,
00392                              select_i, n_i, h_r, ldh_r, w_i, vl_r, ldvl_r, vr_r,
00393                              ldvr_r, mm_i, &m_i, ifaill_i, ifailr_i );
00394 
00395     if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'l' ) ) {
00396         LAPACKE_cge_trans( LAPACK_ROW_MAJOR, n, mm, vl_r, mm+2, vl_i, ldvl );
00397     }
00398     if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'r' ) ) {
00399         LAPACKE_cge_trans( LAPACK_ROW_MAJOR, n, mm, vr_r, mm+2, vr_i, ldvr );
00400     }
00401 
00402     failed = compare_chsein( w, w_i, vl, vl_i, vr, vr_i, m, m_i, ifaill,
00403                              ifaill_i, ifailr, ifailr_i, info, info_i, job,
00404                              ldvl, ldvr, mm, n );
00405     if( failed == 0 ) {
00406         printf( "PASSED: row-major high-level interface to chsein\n" );
00407     } else {
00408         printf( "FAILED: row-major high-level interface to chsein\n" );
00409     }
00410 
00411     /* Release memory */
00412     if( select != NULL ) {
00413         LAPACKE_free( select );
00414     }
00415     if( select_i != NULL ) {
00416         LAPACKE_free( select_i );
00417     }
00418     if( h != NULL ) {
00419         LAPACKE_free( h );
00420     }
00421     if( h_i != NULL ) {
00422         LAPACKE_free( h_i );
00423     }
00424     if( h_r != NULL ) {
00425         LAPACKE_free( h_r );
00426     }
00427     if( w != NULL ) {
00428         LAPACKE_free( w );
00429     }
00430     if( w_i != NULL ) {
00431         LAPACKE_free( w_i );
00432     }
00433     if( w_save != NULL ) {
00434         LAPACKE_free( w_save );
00435     }
00436     if( vl != NULL ) {
00437         LAPACKE_free( vl );
00438     }
00439     if( vl_i != NULL ) {
00440         LAPACKE_free( vl_i );
00441     }
00442     if( vl_r != NULL ) {
00443         LAPACKE_free( vl_r );
00444     }
00445     if( vl_save != NULL ) {
00446         LAPACKE_free( vl_save );
00447     }
00448     if( vr != NULL ) {
00449         LAPACKE_free( vr );
00450     }
00451     if( vr_i != NULL ) {
00452         LAPACKE_free( vr_i );
00453     }
00454     if( vr_r != NULL ) {
00455         LAPACKE_free( vr_r );
00456     }
00457     if( vr_save != NULL ) {
00458         LAPACKE_free( vr_save );
00459     }
00460     if( work != NULL ) {
00461         LAPACKE_free( work );
00462     }
00463     if( work_i != NULL ) {
00464         LAPACKE_free( work_i );
00465     }
00466     if( rwork != NULL ) {
00467         LAPACKE_free( rwork );
00468     }
00469     if( rwork_i != NULL ) {
00470         LAPACKE_free( rwork_i );
00471     }
00472     if( ifaill != NULL ) {
00473         LAPACKE_free( ifaill );
00474     }
00475     if( ifaill_i != NULL ) {
00476         LAPACKE_free( ifaill_i );
00477     }
00478     if( ifaill_save != NULL ) {
00479         LAPACKE_free( ifaill_save );
00480     }
00481     if( ifailr != NULL ) {
00482         LAPACKE_free( ifailr );
00483     }
00484     if( ifailr_i != NULL ) {
00485         LAPACKE_free( ifailr_i );
00486     }
00487     if( ifailr_save != NULL ) {
00488         LAPACKE_free( ifailr_save );
00489     }
00490 
00491     return 0;
00492 }
00493 
00494 /* Auxiliary function: chsein scalar parameters initialization */
00495 static void init_scalars_chsein( char *job, char *eigsrc, char *initv,
00496                                  lapack_int *n, lapack_int *ldh,
00497                                  lapack_int *ldvl, lapack_int *ldvr,
00498                                  lapack_int *mm )
00499 {
00500     *job = 'R';
00501     *eigsrc = 'Q';
00502     *initv = 'N';
00503     *n = 4;
00504     *ldh = 8;
00505     *ldvl = 8;
00506     *ldvr = 8;
00507     *mm = 4;
00508 
00509     return;
00510 }
00511 
00512 /* Auxiliary functions: chsein array parameters initialization */
00513 static void init_select( lapack_int size, lapack_int *select ) {
00514     lapack_int i;
00515     for( i = 0; i < size; i++ ) {
00516         select[i] = 0;
00517     }
00518     select[0] = -1;
00519     select[1] = -1;
00520     select[2] = 0;
00521     select[3] = 0;
00522 }
00523 static void init_h( lapack_int size, lapack_complex_float *h ) {
00524     lapack_int i;
00525     for( i = 0; i < size; i++ ) {
00526         h[i] = lapack_make_complex_float( 0.0f, 0.0f );
00527     }
00528     h[0] = lapack_make_complex_float( -3.970000029e+000, -5.039999962e+000 );
00529     h[8] = lapack_make_complex_float( -1.131804943e+000, -2.569304705e+000 );
00530     h[16] = lapack_make_complex_float( -4.602741241e+000, -1.426316500e-001 );
00531     h[24] = lapack_make_complex_float( -1.424912333e+000, 1.732983828e+000 );
00532     h[1] = lapack_make_complex_float( -5.479653358e+000, 0.000000000e+000 );
00533     h[9] = lapack_make_complex_float( 1.858472466e+000, -1.550180435e+000 );
00534     h[17] = lapack_make_complex_float( 4.414464474e+000, -7.638237476e-001 );
00535     h[25] = lapack_make_complex_float( -4.805260897e-001, -1.197600603e+000 );
00536     h[2] = lapack_make_complex_float( 6.932221651e-001, -4.828752279e-001 );
00537     h[10] = lapack_make_complex_float( 6.267275810e+000, 0.000000000e+000 );
00538     h[18] = lapack_make_complex_float( -4.503800869e-001, -2.898204327e-002 );
00539     h[26] = lapack_make_complex_float( -1.346683741e+000, 1.657924891e+000 );
00540     h[3] = lapack_make_complex_float( -2.112946808e-001, 8.644121885e-002 );
00541     h[11] = lapack_make_complex_float( 1.242147088e-001, -2.289276123e-001 );
00542     h[19] = lapack_make_complex_float( -3.499985933e+000, 0.000000000e+000 );
00543     h[27] = lapack_make_complex_float( 2.561908484e+000, -3.370837450e+000 );
00544 }
00545 static void init_w( lapack_int size, lapack_complex_float *w ) {
00546     lapack_int i;
00547     for( i = 0; i < size; i++ ) {
00548         w[i] = lapack_make_complex_float( 0.0f, 0.0f );
00549     }
00550     w[0] = lapack_make_complex_float( -6.000423908e+000, -6.999841690e+000 );
00551     w[1] = lapack_make_complex_float( -5.000031471e+000, 2.006026745e+000 );
00552     w[2] = lapack_make_complex_float( 7.998193264e+000, -9.963648915e-001 );
00553     w[3] = lapack_make_complex_float( 3.002264738e+000, -3.999819279e+000 );
00554 }
00555 static void init_vl( lapack_int size, lapack_complex_float *vl ) {
00556     lapack_int i;
00557     for( i = 0; i < size; i++ ) {
00558         vl[i] = lapack_make_complex_float( 0.0f, 0.0f );
00559     }
00560     vl[0] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00561     vl[8] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00562     vl[16] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00563     vl[24] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00564     vl[1] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00565     vl[9] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00566     vl[17] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00567     vl[25] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00568     vl[2] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00569     vl[10] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00570     vl[18] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00571     vl[26] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00572     vl[3] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00573     vl[11] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00574     vl[19] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00575     vl[27] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00576 }
00577 static void init_vr( lapack_int size, lapack_complex_float *vr ) {
00578     lapack_int i;
00579     for( i = 0; i < size; i++ ) {
00580         vr[i] = lapack_make_complex_float( 0.0f, 0.0f );
00581     }
00582     vr[0] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00583     vr[8] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00584     vr[16] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00585     vr[24] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00586     vr[1] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00587     vr[9] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00588     vr[17] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00589     vr[25] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00590     vr[2] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00591     vr[10] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00592     vr[18] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00593     vr[26] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00594     vr[3] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00595     vr[11] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00596     vr[19] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00597     vr[27] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00598 }
00599 static void init_work( lapack_int size, lapack_complex_float *work ) {
00600     lapack_int i;
00601     for( i = 0; i < size; i++ ) {
00602         work[i] = lapack_make_complex_float( 0.0f, 0.0f );
00603     }
00604 }
00605 static void init_rwork( lapack_int size, float *rwork ) {
00606     lapack_int i;
00607     for( i = 0; i < size; i++ ) {
00608         rwork[i] = 0;
00609     }
00610 }
00611 static void init_ifaill( lapack_int size, lapack_int *ifaill ) {
00612     lapack_int i;
00613     for( i = 0; i < size; i++ ) {
00614         ifaill[i] = 0;
00615     }
00616 }
00617 static void init_ifailr( lapack_int size, lapack_int *ifailr ) {
00618     lapack_int i;
00619     for( i = 0; i < size; i++ ) {
00620         ifailr[i] = 0;
00621     }
00622 }
00623 
00624 /* Auxiliary function: C interface to chsein results check */
00625 /* Return value: 0 - test is passed, non-zero - test is failed */
00626 static int compare_chsein( lapack_complex_float *w, lapack_complex_float *w_i,
00627                            lapack_complex_float *vl, lapack_complex_float *vl_i,
00628                            lapack_complex_float *vr, lapack_complex_float *vr_i,
00629                            lapack_int m, lapack_int m_i, lapack_int *ifaill,
00630                            lapack_int *ifaill_i, lapack_int *ifailr,
00631                            lapack_int *ifailr_i, lapack_int info,
00632                            lapack_int info_i, char job, lapack_int ldvl,
00633                            lapack_int ldvr, lapack_int mm, lapack_int n )
00634 {
00635     lapack_int i;
00636     int failed = 0;
00637     for( i = 0; i < n; i++ ) {
00638         failed += compare_complex_floats(w[i],w_i[i]);
00639     }
00640     if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'l' ) ) {
00641         for( i = 0; i < ldvl*mm; i++ ) {
00642             failed += compare_complex_floats(vl[i],vl_i[i]);
00643         }
00644     }
00645     if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'r' ) ) {
00646         for( i = 0; i < ldvr*mm; i++ ) {
00647             failed += compare_complex_floats(vr[i],vr_i[i]);
00648         }
00649     }
00650     failed += (m == m_i) ? 0 : 1;
00651     if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'l' ) ) {
00652         for( i = 0; i < mm; i++ ) {
00653             failed += (ifaill[i] == ifaill_i[i]) ? 0 : 1;
00654         }
00655     }
00656     if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'r' ) ) {
00657         for( i = 0; i < mm; i++ ) {
00658             failed += (ifailr[i] == ifailr_i[i]) ? 0 : 1;
00659         }
00660     }
00661     failed += (info == info_i) ? 0 : 1;
00662     if( info != 0 || info_i != 0 ) {
00663         printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00664     }
00665 
00666     return failed;
00667 }


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