00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
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_zunmhr( char *side, char *trans, lapack_int *m,
00055 lapack_int *n, lapack_int *ilo,
00056 lapack_int *ihi, lapack_int *lda,
00057 lapack_int *ldc, lapack_int *lwork );
00058 static void init_a( lapack_int size, lapack_complex_double *a );
00059 static void init_tau( lapack_int size, lapack_complex_double *tau );
00060 static void init_c( lapack_int size, lapack_complex_double *c );
00061 static void init_work( lapack_int size, lapack_complex_double *work );
00062 static int compare_zunmhr( lapack_complex_double *c, lapack_complex_double *c_i,
00063 lapack_int info, lapack_int info_i, lapack_int ldc,
00064 lapack_int n );
00065
00066 int main(void)
00067 {
00068
00069 char side, side_i;
00070 char trans, trans_i;
00071 lapack_int m, m_i;
00072 lapack_int n, n_i;
00073 lapack_int ilo, ilo_i;
00074 lapack_int ihi, ihi_i;
00075 lapack_int lda, lda_i;
00076 lapack_int lda_r;
00077 lapack_int ldc, ldc_i;
00078 lapack_int ldc_r;
00079 lapack_int lwork, lwork_i;
00080 lapack_int info, info_i;
00081
00082 lapack_int r;
00083 lapack_int i;
00084 int failed;
00085
00086
00087 lapack_complex_double *a = NULL, *a_i = NULL;
00088 lapack_complex_double *tau = NULL, *tau_i = NULL;
00089 lapack_complex_double *c = NULL, *c_i = NULL;
00090 lapack_complex_double *work = NULL, *work_i = NULL;
00091 lapack_complex_double *c_save = NULL;
00092 lapack_complex_double *a_r = NULL;
00093 lapack_complex_double *c_r = NULL;
00094
00095
00096 init_scalars_zunmhr( &side, &trans, &m, &n, &ilo, &ihi, &lda, &ldc,
00097 &lwork );
00098 r = LAPACKE_lsame( side, 'l' ) ? m : n;
00099 lda_r = r+2;
00100 ldc_r = n+2;
00101 side_i = side;
00102 trans_i = trans;
00103 m_i = m;
00104 n_i = n;
00105 ilo_i = ilo;
00106 ihi_i = ihi;
00107 lda_i = lda;
00108 ldc_i = ldc;
00109 lwork_i = lwork;
00110
00111
00112 a = (lapack_complex_double *)
00113 LAPACKE_malloc( lda*m * sizeof(lapack_complex_double) );
00114 tau = (lapack_complex_double *)
00115 LAPACKE_malloc( (m-1) * sizeof(lapack_complex_double) );
00116 c = (lapack_complex_double *)
00117 LAPACKE_malloc( ldc*n * sizeof(lapack_complex_double) );
00118 work = (lapack_complex_double *)
00119 LAPACKE_malloc( lwork * sizeof(lapack_complex_double) );
00120
00121
00122 a_i = (lapack_complex_double *)
00123 LAPACKE_malloc( lda*m * sizeof(lapack_complex_double) );
00124 tau_i = (lapack_complex_double *)
00125 LAPACKE_malloc( (m-1) * sizeof(lapack_complex_double) );
00126 c_i = (lapack_complex_double *)
00127 LAPACKE_malloc( ldc*n * sizeof(lapack_complex_double) );
00128 work_i = (lapack_complex_double *)
00129 LAPACKE_malloc( lwork * sizeof(lapack_complex_double) );
00130
00131
00132 c_save = (lapack_complex_double *)
00133 LAPACKE_malloc( ldc*n * sizeof(lapack_complex_double) );
00134
00135
00136 a_r = (lapack_complex_double *)
00137 LAPACKE_malloc( r*(r+2) * sizeof(lapack_complex_double) );
00138 c_r = (lapack_complex_double *)
00139 LAPACKE_malloc( m*(n+2) * sizeof(lapack_complex_double) );
00140
00141
00142 init_a( lda*m, a );
00143 init_tau( (m-1), tau );
00144 init_c( ldc*n, c );
00145 init_work( lwork, work );
00146
00147
00148 for( i = 0; i < ldc*n; i++ ) {
00149 c_save[i] = c[i];
00150 }
00151
00152
00153 zunmhr_( &side, &trans, &m, &n, &ilo, &ihi, a, &lda, tau, c, &ldc, work,
00154 &lwork, &info );
00155
00156
00157
00158 for( i = 0; i < lda*m; i++ ) {
00159 a_i[i] = a[i];
00160 }
00161 for( i = 0; i < (m-1); i++ ) {
00162 tau_i[i] = tau[i];
00163 }
00164 for( i = 0; i < ldc*n; i++ ) {
00165 c_i[i] = c_save[i];
00166 }
00167 for( i = 0; i < lwork; i++ ) {
00168 work_i[i] = work[i];
00169 }
00170 info_i = LAPACKE_zunmhr_work( LAPACK_COL_MAJOR, side_i, trans_i, m_i, n_i,
00171 ilo_i, ihi_i, a_i, lda_i, tau_i, c_i, ldc_i,
00172 work_i, lwork_i );
00173
00174 failed = compare_zunmhr( c, c_i, info, info_i, ldc, n );
00175 if( failed == 0 ) {
00176 printf( "PASSED: column-major middle-level interface to zunmhr\n" );
00177 } else {
00178 printf( "FAILED: column-major middle-level interface to zunmhr\n" );
00179 }
00180
00181
00182
00183 for( i = 0; i < lda*m; i++ ) {
00184 a_i[i] = a[i];
00185 }
00186 for( i = 0; i < (m-1); i++ ) {
00187 tau_i[i] = tau[i];
00188 }
00189 for( i = 0; i < ldc*n; i++ ) {
00190 c_i[i] = c_save[i];
00191 }
00192 for( i = 0; i < lwork; i++ ) {
00193 work_i[i] = work[i];
00194 }
00195 info_i = LAPACKE_zunmhr( LAPACK_COL_MAJOR, side_i, trans_i, m_i, n_i, ilo_i,
00196 ihi_i, a_i, lda_i, tau_i, c_i, ldc_i );
00197
00198 failed = compare_zunmhr( c, c_i, info, info_i, ldc, n );
00199 if( failed == 0 ) {
00200 printf( "PASSED: column-major high-level interface to zunmhr\n" );
00201 } else {
00202 printf( "FAILED: column-major high-level interface to zunmhr\n" );
00203 }
00204
00205
00206
00207 for( i = 0; i < lda*m; i++ ) {
00208 a_i[i] = a[i];
00209 }
00210 for( i = 0; i < (m-1); i++ ) {
00211 tau_i[i] = tau[i];
00212 }
00213 for( i = 0; i < ldc*n; i++ ) {
00214 c_i[i] = c_save[i];
00215 }
00216 for( i = 0; i < lwork; i++ ) {
00217 work_i[i] = work[i];
00218 }
00219
00220 LAPACKE_zge_trans( LAPACK_COL_MAJOR, r, r, a_i, lda, a_r, r+2 );
00221 LAPACKE_zge_trans( LAPACK_COL_MAJOR, m, n, c_i, ldc, c_r, n+2 );
00222 info_i = LAPACKE_zunmhr_work( LAPACK_ROW_MAJOR, side_i, trans_i, m_i, n_i,
00223 ilo_i, ihi_i, a_r, lda_r, tau_i, c_r, ldc_r,
00224 work_i, lwork_i );
00225
00226 LAPACKE_zge_trans( LAPACK_ROW_MAJOR, m, n, c_r, n+2, c_i, ldc );
00227
00228 failed = compare_zunmhr( c, c_i, info, info_i, ldc, n );
00229 if( failed == 0 ) {
00230 printf( "PASSED: row-major middle-level interface to zunmhr\n" );
00231 } else {
00232 printf( "FAILED: row-major middle-level interface to zunmhr\n" );
00233 }
00234
00235
00236
00237 for( i = 0; i < lda*m; i++ ) {
00238 a_i[i] = a[i];
00239 }
00240 for( i = 0; i < (m-1); i++ ) {
00241 tau_i[i] = tau[i];
00242 }
00243 for( i = 0; i < ldc*n; i++ ) {
00244 c_i[i] = c_save[i];
00245 }
00246 for( i = 0; i < lwork; i++ ) {
00247 work_i[i] = work[i];
00248 }
00249
00250
00251 LAPACKE_zge_trans( LAPACK_COL_MAJOR, r, r, a_i, lda, a_r, r+2 );
00252 LAPACKE_zge_trans( LAPACK_COL_MAJOR, m, n, c_i, ldc, c_r, n+2 );
00253 info_i = LAPACKE_zunmhr( LAPACK_ROW_MAJOR, side_i, trans_i, m_i, n_i, ilo_i,
00254 ihi_i, a_r, lda_r, tau_i, c_r, ldc_r );
00255
00256 LAPACKE_zge_trans( LAPACK_ROW_MAJOR, m, n, c_r, n+2, c_i, ldc );
00257
00258 failed = compare_zunmhr( c, c_i, info, info_i, ldc, n );
00259 if( failed == 0 ) {
00260 printf( "PASSED: row-major high-level interface to zunmhr\n" );
00261 } else {
00262 printf( "FAILED: row-major high-level interface to zunmhr\n" );
00263 }
00264
00265
00266 if( a != NULL ) {
00267 LAPACKE_free( a );
00268 }
00269 if( a_i != NULL ) {
00270 LAPACKE_free( a_i );
00271 }
00272 if( a_r != NULL ) {
00273 LAPACKE_free( a_r );
00274 }
00275 if( tau != NULL ) {
00276 LAPACKE_free( tau );
00277 }
00278 if( tau_i != NULL ) {
00279 LAPACKE_free( tau_i );
00280 }
00281 if( c != NULL ) {
00282 LAPACKE_free( c );
00283 }
00284 if( c_i != NULL ) {
00285 LAPACKE_free( c_i );
00286 }
00287 if( c_r != NULL ) {
00288 LAPACKE_free( c_r );
00289 }
00290 if( c_save != NULL ) {
00291 LAPACKE_free( c_save );
00292 }
00293 if( work != NULL ) {
00294 LAPACKE_free( work );
00295 }
00296 if( work_i != NULL ) {
00297 LAPACKE_free( work_i );
00298 }
00299
00300 return 0;
00301 }
00302
00303
00304 static void init_scalars_zunmhr( char *side, char *trans, lapack_int *m,
00305 lapack_int *n, lapack_int *ilo,
00306 lapack_int *ihi, lapack_int *lda,
00307 lapack_int *ldc, lapack_int *lwork )
00308 {
00309 *side = 'L';
00310 *trans = 'N';
00311 *m = 4;
00312 *n = 2;
00313 *ilo = 1;
00314 *ihi = 4;
00315 *lda = 8;
00316 *ldc = 8;
00317 *lwork = 512;
00318
00319 return;
00320 }
00321
00322
00323 static void init_a( lapack_int size, lapack_complex_double *a ) {
00324 lapack_int i;
00325 for( i = 0; i < size; i++ ) {
00326 a[i] = lapack_make_complex_double( 0.0, 0.0 );
00327 }
00328 a[0] = lapack_make_complex_double( -3.97000000000000020e+000,
00329 -5.04000000000000000e+000 );
00330 a[8] = lapack_make_complex_double( -1.13180518733977030e+000,
00331 -2.56930489882743900e+000 );
00332 a[16] = lapack_make_complex_double( -4.60274243753355350e+000,
00333 -1.42631904083292180e-001 );
00334 a[24] = lapack_make_complex_double( -1.42491228936652710e+000,
00335 1.73298370334218620e+000 );
00336 a[1] = lapack_make_complex_double( -5.47965327370263560e+000,
00337 0.00000000000000000e+000 );
00338 a[9] = lapack_make_complex_double( 1.85847282076558700e+000,
00339 -1.55018070644028950e+000 );
00340 a[17] = lapack_make_complex_double( 4.41446552691701300e+000,
00341 -7.63823711555098320e-001 );
00342 a[25] = lapack_make_complex_double( -4.80526133699015420e-001,
00343 -1.19759999733274710e+000 );
00344 a[2] = lapack_make_complex_double( 6.93222211814628180e-001,
00345 -4.82875276260254950e-001 );
00346 a[10] = lapack_make_complex_double( 6.26727681806422240e+000,
00347 0.00000000000000000e+000 );
00348 a[18] = lapack_make_complex_double( -4.50380940334500930e-001,
00349 -2.89818325981801020e-002 );
00350 a[26] = lapack_make_complex_double( -1.34668445007873290e+000,
00351 1.65792489538873020e+000 );
00352 a[3] = lapack_make_complex_double( -2.11294690792069330e-001,
00353 8.64412259893682090e-002 );
00354 a[11] = lapack_make_complex_double( 1.24214618876649560e-001,
00355 -2.28927604979682810e-001 );
00356 a[19] = lapack_make_complex_double( -3.49998583739325890e+000,
00357 0.00000000000000000e+000 );
00358 a[27] = lapack_make_complex_double( 2.56190811956891370e+000,
00359 -3.37083746096152880e+000 );
00360 }
00361 static void init_tau( lapack_int size, lapack_complex_double *tau ) {
00362 lapack_int i;
00363 for( i = 0; i < size; i++ ) {
00364 tau[i] = lapack_make_complex_double( 0.0, 0.0 );
00365 }
00366 tau[0] = lapack_make_complex_double( 1.06204772145560590e+000,
00367 -2.73739947598261200e-001 );
00368 tau[1] = lapack_make_complex_double( 1.80592137164058510e+000,
00369 3.47906702984828510e-001 );
00370 tau[2] = lapack_make_complex_double( 1.18182347104100290e+000,
00371 9.83331188043276350e-001 );
00372 }
00373 static void init_c( lapack_int size, lapack_complex_double *c ) {
00374 lapack_int i;
00375 for( i = 0; i < size; i++ ) {
00376 c[i] = lapack_make_complex_double( 0.0, 0.0 );
00377 }
00378 c[0] = lapack_make_complex_double( 8.62714450677153350e-001,
00379 -1.37285549322846670e-001 );
00380 c[8] = lapack_make_complex_double( 5.25619328131155870e-002,
00381 -4.22234210317574240e-001 );
00382 c[1] = lapack_make_complex_double( 2.34431506369553070e-001,
00383 -3.82827125669270130e-001 );
00384 c[9] = lapack_make_complex_double( 4.78167649382766290e-001,
00385 6.43408030515105340e-002 );
00386 c[2] = lapack_make_complex_double( 1.21716778596275620e-001,
00387 2.73482983966257860e-001 );
00388 c[10] = lapack_make_complex_double( -6.02546117975637290e-001,
00389 -3.97453882024362770e-001 );
00390 c[3] = lapack_make_complex_double( 8.23425425661291760e-002,
00391 7.68908382119097980e-002 );
00392 c[11] = lapack_make_complex_double( -9.83549568790308970e-002,
00393 -2.53893028222614610e-001 );
00394 }
00395 static void init_work( lapack_int size, lapack_complex_double *work ) {
00396 lapack_int i;
00397 for( i = 0; i < size; i++ ) {
00398 work[i] = lapack_make_complex_double( 0.0, 0.0 );
00399 }
00400 }
00401
00402
00403
00404 static int compare_zunmhr( lapack_complex_double *c, lapack_complex_double *c_i,
00405 lapack_int info, lapack_int info_i, lapack_int ldc,
00406 lapack_int n )
00407 {
00408 lapack_int i;
00409 int failed = 0;
00410 for( i = 0; i < ldc*n; i++ ) {
00411 failed += compare_complex_doubles(c[i],c_i[i]);
00412 }
00413 failed += (info == info_i) ? 0 : 1;
00414 if( info != 0 || info_i != 0 ) {
00415 printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00416 }
00417
00418 return failed;
00419 }