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_cunmhr( 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_float *a );
00059 static void init_tau( lapack_int size, lapack_complex_float *tau );
00060 static void init_c( lapack_int size, lapack_complex_float *c );
00061 static void init_work( lapack_int size, lapack_complex_float *work );
00062 static int compare_cunmhr( lapack_complex_float *c, lapack_complex_float *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_float *a = NULL, *a_i = NULL;
00088 lapack_complex_float *tau = NULL, *tau_i = NULL;
00089 lapack_complex_float *c = NULL, *c_i = NULL;
00090 lapack_complex_float *work = NULL, *work_i = NULL;
00091 lapack_complex_float *c_save = NULL;
00092 lapack_complex_float *a_r = NULL;
00093 lapack_complex_float *c_r = NULL;
00094
00095
00096 init_scalars_cunmhr( &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_float *)
00113 LAPACKE_malloc( lda*m * sizeof(lapack_complex_float) );
00114 tau = (lapack_complex_float *)
00115 LAPACKE_malloc( (m-1) * sizeof(lapack_complex_float) );
00116 c = (lapack_complex_float *)
00117 LAPACKE_malloc( ldc*n * sizeof(lapack_complex_float) );
00118 work = (lapack_complex_float *)
00119 LAPACKE_malloc( lwork * sizeof(lapack_complex_float) );
00120
00121
00122 a_i = (lapack_complex_float *)
00123 LAPACKE_malloc( lda*m * sizeof(lapack_complex_float) );
00124 tau_i = (lapack_complex_float *)
00125 LAPACKE_malloc( (m-1) * sizeof(lapack_complex_float) );
00126 c_i = (lapack_complex_float *)
00127 LAPACKE_malloc( ldc*n * sizeof(lapack_complex_float) );
00128 work_i = (lapack_complex_float *)
00129 LAPACKE_malloc( lwork * sizeof(lapack_complex_float) );
00130
00131
00132 c_save = (lapack_complex_float *)
00133 LAPACKE_malloc( ldc*n * sizeof(lapack_complex_float) );
00134
00135
00136 a_r = (lapack_complex_float *)
00137 LAPACKE_malloc( r*(r+2) * sizeof(lapack_complex_float) );
00138 c_r = (lapack_complex_float *)
00139 LAPACKE_malloc( m*(n+2) * sizeof(lapack_complex_float) );
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 cunmhr_( &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_cunmhr_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_cunmhr( c, c_i, info, info_i, ldc, n );
00175 if( failed == 0 ) {
00176 printf( "PASSED: column-major middle-level interface to cunmhr\n" );
00177 } else {
00178 printf( "FAILED: column-major middle-level interface to cunmhr\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_cunmhr( 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_cunmhr( c, c_i, info, info_i, ldc, n );
00199 if( failed == 0 ) {
00200 printf( "PASSED: column-major high-level interface to cunmhr\n" );
00201 } else {
00202 printf( "FAILED: column-major high-level interface to cunmhr\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_cge_trans( LAPACK_COL_MAJOR, r, r, a_i, lda, a_r, r+2 );
00221 LAPACKE_cge_trans( LAPACK_COL_MAJOR, m, n, c_i, ldc, c_r, n+2 );
00222 info_i = LAPACKE_cunmhr_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_cge_trans( LAPACK_ROW_MAJOR, m, n, c_r, n+2, c_i, ldc );
00227
00228 failed = compare_cunmhr( c, c_i, info, info_i, ldc, n );
00229 if( failed == 0 ) {
00230 printf( "PASSED: row-major middle-level interface to cunmhr\n" );
00231 } else {
00232 printf( "FAILED: row-major middle-level interface to cunmhr\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_cge_trans( LAPACK_COL_MAJOR, r, r, a_i, lda, a_r, r+2 );
00252 LAPACKE_cge_trans( LAPACK_COL_MAJOR, m, n, c_i, ldc, c_r, n+2 );
00253 info_i = LAPACKE_cunmhr( 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_cge_trans( LAPACK_ROW_MAJOR, m, n, c_r, n+2, c_i, ldc );
00257
00258 failed = compare_cunmhr( c, c_i, info, info_i, ldc, n );
00259 if( failed == 0 ) {
00260 printf( "PASSED: row-major high-level interface to cunmhr\n" );
00261 } else {
00262 printf( "FAILED: row-major high-level interface to cunmhr\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_cunmhr( 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_float *a ) {
00324 lapack_int i;
00325 for( i = 0; i < size; i++ ) {
00326 a[i] = lapack_make_complex_float( 0.0f, 0.0f );
00327 }
00328 a[0] = lapack_make_complex_float( -3.970000029e+000, -5.039999962e+000 );
00329 a[8] = lapack_make_complex_float( -1.131804943e+000, -2.569304705e+000 );
00330 a[16] = lapack_make_complex_float( -4.602741241e+000, -1.426316500e-001 );
00331 a[24] = lapack_make_complex_float( -1.424912333e+000, 1.732983828e+000 );
00332 a[1] = lapack_make_complex_float( -5.479653358e+000, 0.000000000e+000 );
00333 a[9] = lapack_make_complex_float( 1.858472466e+000, -1.550180435e+000 );
00334 a[17] = lapack_make_complex_float( 4.414464474e+000, -7.638237476e-001 );
00335 a[25] = lapack_make_complex_float( -4.805260897e-001, -1.197600603e+000 );
00336 a[2] = lapack_make_complex_float( 6.932221651e-001, -4.828752279e-001 );
00337 a[10] = lapack_make_complex_float( 6.267275810e+000, 0.000000000e+000 );
00338 a[18] = lapack_make_complex_float( -4.503800869e-001, -2.898204327e-002 );
00339 a[26] = lapack_make_complex_float( -1.346683741e+000, 1.657924891e+000 );
00340 a[3] = lapack_make_complex_float( -2.112946808e-001, 8.644121885e-002 );
00341 a[11] = lapack_make_complex_float( 1.242147088e-001, -2.289276123e-001 );
00342 a[19] = lapack_make_complex_float( -3.499985933e+000, 0.000000000e+000 );
00343 a[27] = lapack_make_complex_float( 2.561908484e+000, -3.370837450e+000 );
00344 }
00345 static void init_tau( lapack_int size, lapack_complex_float *tau ) {
00346 lapack_int i;
00347 for( i = 0; i < size; i++ ) {
00348 tau[i] = lapack_make_complex_float( 0.0f, 0.0f );
00349 }
00350 tau[0] = lapack_make_complex_float( 1.062047720e+000, -2.737399340e-001 );
00351 tau[1] = lapack_make_complex_float( 1.805921316e+000, 3.479066789e-001 );
00352 tau[2] = lapack_make_complex_float( 1.181823134e+000, 9.833312631e-001 );
00353 }
00354 static void init_c( lapack_int size, lapack_complex_float *c ) {
00355 lapack_int i;
00356 for( i = 0; i < size; i++ ) {
00357 c[i] = lapack_make_complex_float( 0.0f, 0.0f );
00358 }
00359 c[0] = lapack_make_complex_float( -4.676087201e-001, 5.323912501e-001 );
00360 c[8] = lapack_make_complex_float( -8.885198832e-002, -4.700618982e-001 );
00361 c[1] = lapack_make_complex_float( 5.182668939e-002, 3.604178131e-001 );
00362 c[9] = lapack_make_complex_float( 5.339868665e-001, -9.546674788e-002 );
00363 c[2] = lapack_make_complex_float( -2.175965160e-001, -1.077471673e-001 );
00364 c[10] = lapack_make_complex_float( -7.816210389e-001, -2.183789909e-001 );
00365 c[3] = lapack_make_complex_float( -9.122548252e-002, -5.378896836e-003 );
00366 c[11] = lapack_make_complex_float( -1.925490350e-001, -2.379856855e-001 );
00367 }
00368 static void init_work( lapack_int size, lapack_complex_float *work ) {
00369 lapack_int i;
00370 for( i = 0; i < size; i++ ) {
00371 work[i] = lapack_make_complex_float( 0.0f, 0.0f );
00372 }
00373 }
00374
00375
00376
00377 static int compare_cunmhr( lapack_complex_float *c, lapack_complex_float *c_i,
00378 lapack_int info, lapack_int info_i, lapack_int ldc,
00379 lapack_int n )
00380 {
00381 lapack_int i;
00382 int failed = 0;
00383 for( i = 0; i < ldc*n; i++ ) {
00384 failed += compare_complex_floats(c[i],c_i[i]);
00385 }
00386 failed += (info == info_i) ? 0 : 1;
00387 if( info != 0 || info_i != 0 ) {
00388 printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00389 }
00390
00391 return failed;
00392 }