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_zunmbr( char *vect, char *side, char *trans,
00055 lapack_int *m, lapack_int *n, lapack_int *k,
00056 lapack_int *lda, lapack_int *ldc,
00057 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_zunmbr( 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 vect, vect_i;
00070 char side, side_i;
00071 char trans, trans_i;
00072 lapack_int m, m_i;
00073 lapack_int n, n_i;
00074 lapack_int k, k_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 nq;
00083 lapack_int r;
00084 lapack_int i;
00085 int failed;
00086
00087
00088 lapack_complex_double *a = NULL, *a_i = NULL;
00089 lapack_complex_double *tau = NULL, *tau_i = NULL;
00090 lapack_complex_double *c = NULL, *c_i = NULL;
00091 lapack_complex_double *work = NULL, *work_i = NULL;
00092 lapack_complex_double *c_save = NULL;
00093 lapack_complex_double *a_r = NULL;
00094 lapack_complex_double *c_r = NULL;
00095
00096
00097 init_scalars_zunmbr( &vect, &side, &trans, &m, &n, &k, &lda, &ldc, &lwork );
00098 nq = LAPACKE_lsame( side, 'l' ) ? m : n;
00099 r = LAPACKE_lsame( vect, 'q' ) ? nq : MIN(nq,k);
00100 lda_r = MIN(nq,k)+2;
00101 ldc_r = n+2;
00102 vect_i = vect;
00103 side_i = side;
00104 trans_i = trans;
00105 m_i = m;
00106 n_i = n;
00107 k_i = k;
00108 lda_i = lda;
00109 ldc_i = ldc;
00110 lwork_i = lwork;
00111
00112
00113 a = (lapack_complex_double *)
00114 LAPACKE_malloc( (lda*(MIN(nq,k))) * sizeof(lapack_complex_double) );
00115 tau = (lapack_complex_double *)
00116 LAPACKE_malloc( MIN(nq,k) * sizeof(lapack_complex_double) );
00117 c = (lapack_complex_double *)
00118 LAPACKE_malloc( ldc*n * sizeof(lapack_complex_double) );
00119 work = (lapack_complex_double *)
00120 LAPACKE_malloc( lwork * sizeof(lapack_complex_double) );
00121
00122
00123 a_i = (lapack_complex_double *)
00124 LAPACKE_malloc( (lda*(MIN(nq,k))) * sizeof(lapack_complex_double) );
00125 tau_i = (lapack_complex_double *)
00126 LAPACKE_malloc( MIN(nq,k) * sizeof(lapack_complex_double) );
00127 c_i = (lapack_complex_double *)
00128 LAPACKE_malloc( ldc*n * sizeof(lapack_complex_double) );
00129 work_i = (lapack_complex_double *)
00130 LAPACKE_malloc( lwork * sizeof(lapack_complex_double) );
00131
00132
00133 c_save = (lapack_complex_double *)
00134 LAPACKE_malloc( ldc*n * sizeof(lapack_complex_double) );
00135
00136
00137 a_r = (lapack_complex_double *)
00138 LAPACKE_malloc( (r*(MIN(nq,k)+2)) * sizeof(lapack_complex_double) );
00139 c_r = (lapack_complex_double *)
00140 LAPACKE_malloc( m*(n+2) * sizeof(lapack_complex_double) );
00141
00142
00143 init_a( lda*(MIN(nq,k)), a );
00144 init_tau( (MIN(nq,k)), tau );
00145 init_c( ldc*n, c );
00146 init_work( lwork, work );
00147
00148
00149 for( i = 0; i < ldc*n; i++ ) {
00150 c_save[i] = c[i];
00151 }
00152
00153
00154 zunmbr_( &vect, &side, &trans, &m, &n, &k, a, &lda, tau, c, &ldc, work,
00155 &lwork, &info );
00156
00157
00158
00159 for( i = 0; i < lda*(MIN(nq,k)); i++ ) {
00160 a_i[i] = a[i];
00161 }
00162 for( i = 0; i < (MIN(nq,k)); i++ ) {
00163 tau_i[i] = tau[i];
00164 }
00165 for( i = 0; i < ldc*n; i++ ) {
00166 c_i[i] = c_save[i];
00167 }
00168 for( i = 0; i < lwork; i++ ) {
00169 work_i[i] = work[i];
00170 }
00171 info_i = LAPACKE_zunmbr_work( LAPACK_COL_MAJOR, vect_i, side_i, trans_i,
00172 m_i, n_i, k_i, a_i, lda_i, tau_i, c_i, ldc_i,
00173 work_i, lwork_i );
00174
00175 failed = compare_zunmbr( c, c_i, info, info_i, ldc, n );
00176 if( failed == 0 ) {
00177 printf( "PASSED: column-major middle-level interface to zunmbr\n" );
00178 } else {
00179 printf( "FAILED: column-major middle-level interface to zunmbr\n" );
00180 }
00181
00182
00183
00184 for( i = 0; i < lda*(MIN(nq,k)); i++ ) {
00185 a_i[i] = a[i];
00186 }
00187 for( i = 0; i < (MIN(nq,k)); i++ ) {
00188 tau_i[i] = tau[i];
00189 }
00190 for( i = 0; i < ldc*n; i++ ) {
00191 c_i[i] = c_save[i];
00192 }
00193 for( i = 0; i < lwork; i++ ) {
00194 work_i[i] = work[i];
00195 }
00196 info_i = LAPACKE_zunmbr( LAPACK_COL_MAJOR, vect_i, side_i, trans_i, m_i,
00197 n_i, k_i, a_i, lda_i, tau_i, c_i, ldc_i );
00198
00199 failed = compare_zunmbr( c, c_i, info, info_i, ldc, n );
00200 if( failed == 0 ) {
00201 printf( "PASSED: column-major high-level interface to zunmbr\n" );
00202 } else {
00203 printf( "FAILED: column-major high-level interface to zunmbr\n" );
00204 }
00205
00206
00207
00208 for( i = 0; i < lda*(MIN(nq,k)); i++ ) {
00209 a_i[i] = a[i];
00210 }
00211 for( i = 0; i < (MIN(nq,k)); i++ ) {
00212 tau_i[i] = tau[i];
00213 }
00214 for( i = 0; i < ldc*n; i++ ) {
00215 c_i[i] = c_save[i];
00216 }
00217 for( i = 0; i < lwork; i++ ) {
00218 work_i[i] = work[i];
00219 }
00220
00221 LAPACKE_zge_trans( LAPACK_COL_MAJOR, r, MIN(nq, k ), a_i, lda, a_r, MIN(nq,
00222 k)+2);
00223 LAPACKE_zge_trans( LAPACK_COL_MAJOR, m, n, c_i, ldc, c_r, n+2 );
00224 info_i = LAPACKE_zunmbr_work( LAPACK_ROW_MAJOR, vect_i, side_i, trans_i,
00225 m_i, n_i, k_i, a_r, lda_r, tau_i, c_r, ldc_r,
00226 work_i, lwork_i );
00227
00228 LAPACKE_zge_trans( LAPACK_ROW_MAJOR, m, n, c_r, n+2, c_i, ldc );
00229
00230 failed = compare_zunmbr( c, c_i, info, info_i, ldc, n );
00231 if( failed == 0 ) {
00232 printf( "PASSED: row-major middle-level interface to zunmbr\n" );
00233 } else {
00234 printf( "FAILED: row-major middle-level interface to zunmbr\n" );
00235 }
00236
00237
00238
00239 for( i = 0; i < lda*(MIN(nq,k)); i++ ) {
00240 a_i[i] = a[i];
00241 }
00242 for( i = 0; i < (MIN(nq,k)); i++ ) {
00243 tau_i[i] = tau[i];
00244 }
00245 for( i = 0; i < ldc*n; i++ ) {
00246 c_i[i] = c_save[i];
00247 }
00248 for( i = 0; i < lwork; i++ ) {
00249 work_i[i] = work[i];
00250 }
00251
00252
00253 LAPACKE_zge_trans( LAPACK_COL_MAJOR, r, MIN(nq, k ), a_i, lda, a_r, MIN(nq,
00254 k)+2);
00255 LAPACKE_zge_trans( LAPACK_COL_MAJOR, m, n, c_i, ldc, c_r, n+2 );
00256 info_i = LAPACKE_zunmbr( LAPACK_ROW_MAJOR, vect_i, side_i, trans_i, m_i,
00257 n_i, k_i, a_r, lda_r, tau_i, c_r, ldc_r );
00258
00259 LAPACKE_zge_trans( LAPACK_ROW_MAJOR, m, n, c_r, n+2, c_i, ldc );
00260
00261 failed = compare_zunmbr( c, c_i, info, info_i, ldc, n );
00262 if( failed == 0 ) {
00263 printf( "PASSED: row-major high-level interface to zunmbr\n" );
00264 } else {
00265 printf( "FAILED: row-major high-level interface to zunmbr\n" );
00266 }
00267
00268
00269 if( a != NULL ) {
00270 LAPACKE_free( a );
00271 }
00272 if( a_i != NULL ) {
00273 LAPACKE_free( a_i );
00274 }
00275 if( a_r != NULL ) {
00276 LAPACKE_free( a_r );
00277 }
00278 if( tau != NULL ) {
00279 LAPACKE_free( tau );
00280 }
00281 if( tau_i != NULL ) {
00282 LAPACKE_free( tau_i );
00283 }
00284 if( c != NULL ) {
00285 LAPACKE_free( c );
00286 }
00287 if( c_i != NULL ) {
00288 LAPACKE_free( c_i );
00289 }
00290 if( c_r != NULL ) {
00291 LAPACKE_free( c_r );
00292 }
00293 if( c_save != NULL ) {
00294 LAPACKE_free( c_save );
00295 }
00296 if( work != NULL ) {
00297 LAPACKE_free( work );
00298 }
00299 if( work_i != NULL ) {
00300 LAPACKE_free( work_i );
00301 }
00302
00303 return 0;
00304 }
00305
00306
00307 static void init_scalars_zunmbr( char *vect, char *side, char *trans,
00308 lapack_int *m, lapack_int *n, lapack_int *k,
00309 lapack_int *lda, lapack_int *ldc,
00310 lapack_int *lwork )
00311 {
00312 *vect = 'P';
00313 *side = 'L';
00314 *trans = 'C';
00315 *m = 3;
00316 *n = 4;
00317 *k = 3;
00318 *lda = 8;
00319 *ldc = 8;
00320 *lwork = 1024;
00321
00322 return;
00323 }
00324
00325
00326 static void init_a( lapack_int size, lapack_complex_double *a ) {
00327 lapack_int i;
00328 for( i = 0; i < size; i++ ) {
00329 a[i] = lapack_make_complex_double( 0.0, 0.0 );
00330 }
00331 a[0] = lapack_make_complex_double( 2.76147559450819460e+000,
00332 0.00000000000000000e+000 );
00333 a[8] = lapack_make_complex_double( -9.49951456547741380e-001,
00334 0.00000000000000000e+000 );
00335 a[16] = lapack_make_complex_double( 7.65166949226434580e-002,
00336 -2.17935443626822770e-001 );
00337 a[1] = lapack_make_complex_double( -1.64579393401745320e-001,
00338 -2.48337744494629700e-001 );
00339 a[9] = lapack_make_complex_double( 1.62976302139712790e+000,
00340 0.00000000000000000e+000 );
00341 a[17] = lapack_make_complex_double( -1.01828100869306870e+000,
00342 0.00000000000000000e+000 );
00343 a[2] = lapack_make_complex_double( -2.07233441817599270e-004,
00344 1.36801102048543760e-001 );
00345 a[10] = lapack_make_complex_double( 2.64916983670861250e-001,
00346 -2.63261863195891070e-001 );
00347 a[18] = lapack_make_complex_double( -1.32748674289424410e+000,
00348 0.00000000000000000e+000 );
00349 }
00350 static void init_tau( lapack_int size, lapack_complex_double *tau ) {
00351 lapack_int i;
00352 for( i = 0; i < size; i++ ) {
00353 tau[i] = lapack_make_complex_double( 0.0, 0.0 );
00354 }
00355 tau[0] = lapack_make_complex_double( 1.68853417115046050e+000,
00356 5.95715661427263620e-001 );
00357 tau[1] = lapack_make_complex_double( 1.93508854618282510e+000,
00358 3.54414179735646040e-001 );
00359 tau[2] = lapack_make_complex_double( 0.00000000000000000e+000,
00360 0.00000000000000000e+000 );
00361 }
00362 static void init_c( lapack_int size, lapack_complex_double *c ) {
00363 lapack_int i;
00364 for( i = 0; i < size; i++ ) {
00365 c[i] = lapack_make_complex_double( 0.0, 0.0 );
00366 }
00367 c[0] = lapack_make_complex_double( -1.25813791844360030e-001,
00368 1.61760589514177240e-001 );
00369 c[8] = lapack_make_complex_double( -2.24667485436357280e-001,
00370 3.86428074950534490e-001 );
00371 c[16] = lapack_make_complex_double( 3.45987927571990260e-001,
00372 2.15680786018902980e-001 );
00373 c[24] = lapack_make_complex_double( -7.09949253978889080e-001,
00374 -2.96561080775991640e-001 );
00375 c[1] = lapack_make_complex_double( -1.16346194993491530e-001,
00376 -6.37965906104356220e-001 );
00377 c[9] = lapack_make_complex_double( -3.24049574671177840e-001,
00378 4.27153446850967900e-001 );
00379 c[17] = lapack_make_complex_double( -1.99549685432087120e-001,
00380 -5.00865962077012170e-001 );
00381 c[25] = lapack_make_complex_double( -3.23343079843185220e-002,
00382 -1.62041711157860920e-002 );
00383 c[2] = lapack_make_complex_double( -4.60656524382329850e-001,
00384 1.09003364172517100e-001 );
00385 c[10] = lapack_make_complex_double( 2.17098241596208270e-001,
00386 -4.06189010702446400e-001 );
00387 c[18] = lapack_make_complex_double( 2.73307644197749500e-001,
00388 -6.10622832142254660e-001 );
00389 c[26] = lapack_make_complex_double( -9.94048941884518870e-002,
00390 -3.26119655532288610e-001 );
00391 }
00392 static void init_work( lapack_int size, lapack_complex_double *work ) {
00393 lapack_int i;
00394 for( i = 0; i < size; i++ ) {
00395 work[i] = lapack_make_complex_double( 0.0, 0.0 );
00396 }
00397 }
00398
00399
00400
00401 static int compare_zunmbr( lapack_complex_double *c, lapack_complex_double *c_i,
00402 lapack_int info, lapack_int info_i, lapack_int ldc,
00403 lapack_int n )
00404 {
00405 lapack_int i;
00406 int failed = 0;
00407 for( i = 0; i < ldc*n; i++ ) {
00408 failed += compare_complex_doubles(c[i],c_i[i]);
00409 }
00410 failed += (info == info_i) ? 0 : 1;
00411 if( info != 0 || info_i != 0 ) {
00412 printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00413 }
00414
00415 return failed;
00416 }