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_cunmbr( 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_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_cunmbr( 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 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_float *a = NULL, *a_i = NULL;
00089 lapack_complex_float *tau = NULL, *tau_i = NULL;
00090 lapack_complex_float *c = NULL, *c_i = NULL;
00091 lapack_complex_float *work = NULL, *work_i = NULL;
00092 lapack_complex_float *c_save = NULL;
00093 lapack_complex_float *a_r = NULL;
00094 lapack_complex_float *c_r = NULL;
00095
00096
00097 init_scalars_cunmbr( &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_float *)
00114 LAPACKE_malloc( (lda*(MIN(nq,k))) * sizeof(lapack_complex_float) );
00115 tau = (lapack_complex_float *)
00116 LAPACKE_malloc( MIN(nq,k) * sizeof(lapack_complex_float) );
00117 c = (lapack_complex_float *)
00118 LAPACKE_malloc( ldc*n * sizeof(lapack_complex_float) );
00119 work = (lapack_complex_float *)
00120 LAPACKE_malloc( lwork * sizeof(lapack_complex_float) );
00121
00122
00123 a_i = (lapack_complex_float *)
00124 LAPACKE_malloc( (lda*(MIN(nq,k))) * sizeof(lapack_complex_float) );
00125 tau_i = (lapack_complex_float *)
00126 LAPACKE_malloc( MIN(nq,k) * sizeof(lapack_complex_float) );
00127 c_i = (lapack_complex_float *)
00128 LAPACKE_malloc( ldc*n * sizeof(lapack_complex_float) );
00129 work_i = (lapack_complex_float *)
00130 LAPACKE_malloc( lwork * sizeof(lapack_complex_float) );
00131
00132
00133 c_save = (lapack_complex_float *)
00134 LAPACKE_malloc( ldc*n * sizeof(lapack_complex_float) );
00135
00136
00137 a_r = (lapack_complex_float *)
00138 LAPACKE_malloc( (r*(MIN(nq,k)+2)) * sizeof(lapack_complex_float) );
00139 c_r = (lapack_complex_float *)
00140 LAPACKE_malloc( m*(n+2) * sizeof(lapack_complex_float) );
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 cunmbr_( &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_cunmbr_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_cunmbr( c, c_i, info, info_i, ldc, n );
00176 if( failed == 0 ) {
00177 printf( "PASSED: column-major middle-level interface to cunmbr\n" );
00178 } else {
00179 printf( "FAILED: column-major middle-level interface to cunmbr\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_cunmbr( 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_cunmbr( c, c_i, info, info_i, ldc, n );
00200 if( failed == 0 ) {
00201 printf( "PASSED: column-major high-level interface to cunmbr\n" );
00202 } else {
00203 printf( "FAILED: column-major high-level interface to cunmbr\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_cge_trans( LAPACK_COL_MAJOR, r, MIN(nq, k ), a_i, lda, a_r, MIN(nq,
00222 k)+2);
00223 LAPACKE_cge_trans( LAPACK_COL_MAJOR, m, n, c_i, ldc, c_r, n+2 );
00224 info_i = LAPACKE_cunmbr_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_cge_trans( LAPACK_ROW_MAJOR, m, n, c_r, n+2, c_i, ldc );
00229
00230 failed = compare_cunmbr( c, c_i, info, info_i, ldc, n );
00231 if( failed == 0 ) {
00232 printf( "PASSED: row-major middle-level interface to cunmbr\n" );
00233 } else {
00234 printf( "FAILED: row-major middle-level interface to cunmbr\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_cge_trans( LAPACK_COL_MAJOR, r, MIN(nq, k ), a_i, lda, a_r, MIN(nq,
00254 k)+2);
00255 LAPACKE_cge_trans( LAPACK_COL_MAJOR, m, n, c_i, ldc, c_r, n+2 );
00256 info_i = LAPACKE_cunmbr( 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_cge_trans( LAPACK_ROW_MAJOR, m, n, c_r, n+2, c_i, ldc );
00260
00261 failed = compare_cunmbr( c, c_i, info, info_i, ldc, n );
00262 if( failed == 0 ) {
00263 printf( "PASSED: row-major high-level interface to cunmbr\n" );
00264 } else {
00265 printf( "FAILED: row-major high-level interface to cunmbr\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_cunmbr( 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 = 'Q';
00313 *side = 'R';
00314 *trans = 'N';
00315 *m = 6;
00316 *n = 4;
00317 *k = 4;
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_float *a ) {
00327 lapack_int i;
00328 for( i = 0; i < size; i++ ) {
00329 a[i] = lapack_make_complex_float( 0.0f, 0.0f );
00330 }
00331 a[0] = lapack_make_complex_float( -3.087005138e+000, 0.000000000e+000 );
00332 a[8] = lapack_make_complex_float( 2.112571001e+000, 0.000000000e+000 );
00333 a[16] = lapack_make_complex_float( 5.433412641e-002, 4.543118775e-001 );
00334 a[24] = lapack_make_complex_float( 3.757437766e-001, 1.070087403e-001 );
00335 a[1] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00336 a[9] = lapack_make_complex_float( -2.066039324e+000, 0.000000000e+000 );
00337 a[17] = lapack_make_complex_float( -1.262809873e+000, 0.000000000e+000 );
00338 a[25] = lapack_make_complex_float( 2.827708796e-002, 1.650057137e-001 );
00339 a[2] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00340 a[10] = lapack_make_complex_float( -2.804788351e-001, -4.124460816e-001 );
00341 a[18] = lapack_make_complex_float( -1.873129010e+000, 0.000000000e+000 );
00342 a[26] = lapack_make_complex_float( 1.612633705e+000, 0.000000000e+000 );
00343 a[3] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00344 a[11] = lapack_make_complex_float( 2.103471309e-001, -4.460760355e-001 );
00345 a[19] = lapack_make_complex_float( -5.708419085e-001, 6.437424570e-002 );
00346 a[27] = lapack_make_complex_float( -2.002182961e+000, 0.000000000e+000 );
00347 }
00348 static void init_tau( lapack_int size, lapack_complex_float *tau ) {
00349 lapack_int i;
00350 for( i = 0; i < size; i++ ) {
00351 tau[i] = lapack_make_complex_float( 0.0f, 0.0f );
00352 }
00353 tau[0] = lapack_make_complex_float( 0.000000000e+000, 0.000000000e+000 );
00354 tau[1] = lapack_make_complex_float( 1.098198175e+000, 5.158162713e-001 );
00355 tau[2] = lapack_make_complex_float( 1.455158114e+000, -2.659229040e-001 );
00356 tau[3] = lapack_make_complex_float( 1.989879847e+000, -1.419081986e-001 );
00357 }
00358 static void init_c( lapack_int size, lapack_complex_float *c ) {
00359 lapack_int i;
00360 for( i = 0; i < size; i++ ) {
00361 c[i] = lapack_make_complex_float( 0.0f, 0.0f );
00362 }
00363 c[0] = lapack_make_complex_float( -3.109810352e-001, 2.623902261e-001 );
00364 c[8] = lapack_make_complex_float( -3.175341487e-001, 4.834966362e-001 );
00365 c[16] = lapack_make_complex_float( 4.966142774e-001, -2.996833324e-001 );
00366 c[24] = lapack_make_complex_float( -7.195726037e-003, -3.717893958e-001 );
00367 c[1] = lapack_make_complex_float( 3.174597919e-001, -6.413983703e-001 );
00368 c[9] = lapack_make_complex_float( -2.061862350e-001, 1.576964855e-001 );
00369 c[17] = lapack_make_complex_float( -7.925905287e-002, -3.093748689e-001 );
00370 c[25] = lapack_make_complex_float( -2.816170454e-002, -1.491467953e-001 );
00371 c[2] = lapack_make_complex_float( -2.008419037e-001, 1.490117311e-001 );
00372 c[10] = lapack_make_complex_float( 4.891880453e-001, -9.002533555e-002 );
00373 c[18] = lapack_make_complex_float( 3.574561328e-002, -2.190383524e-002 );
00374 c[26] = lapack_make_complex_float( 5.624615550e-001, -7.099355757e-002 );
00375 c[3] = lapack_make_complex_float( 1.198572665e-001, -1.230966449e-001 );
00376 c[11] = lapack_make_complex_float( 2.566010356e-001, -3.055384755e-001 );
00377 c[19] = lapack_make_complex_float( 4.488646090e-001, -2.140825540e-001 );
00378 c[27] = lapack_make_complex_float( -1.651300937e-001, 1.799761951e-001 );
00379 c[4] = lapack_make_complex_float( -2.688689828e-001, -1.652086675e-001 );
00380 c[12] = lapack_make_complex_float( 1.696708202e-001, -2.490701973e-001 );
00381 c[20] = lapack_make_complex_float( -4.956100881e-002, 1.157544106e-001 );
00382 c[28] = lapack_make_complex_float( -4.885202348e-001, -4.540378153e-001 );
00383 c[5] = lapack_make_complex_float( -3.498536646e-001, 9.070278704e-002 );
00384 c[13] = lapack_make_complex_float( -4.910433292e-002, -3.133355975e-001 );
00385 c[21] = lapack_make_complex_float( -1.256479472e-001, -5.299605131e-001 );
00386 c[29] = lapack_make_complex_float( 1.039065570e-001, 4.496295750e-002 );
00387 }
00388 static void init_work( lapack_int size, lapack_complex_float *work ) {
00389 lapack_int i;
00390 for( i = 0; i < size; i++ ) {
00391 work[i] = lapack_make_complex_float( 0.0f, 0.0f );
00392 }
00393 }
00394
00395
00396
00397 static int compare_cunmbr( lapack_complex_float *c, lapack_complex_float *c_i,
00398 lapack_int info, lapack_int info_i, lapack_int ldc,
00399 lapack_int n )
00400 {
00401 lapack_int i;
00402 int failed = 0;
00403 for( i = 0; i < ldc*n; i++ ) {
00404 failed += compare_complex_floats(c[i],c_i[i]);
00405 }
00406 failed += (info == info_i) ? 0 : 1;
00407 if( info != 0 || info_i != 0 ) {
00408 printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00409 }
00410
00411 return failed;
00412 }