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_dormbr( 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, double *a );
00059 static void init_tau( lapack_int size, double *tau );
00060 static void init_c( lapack_int size, double *c );
00061 static void init_work( lapack_int size, double *work );
00062 static int compare_dormbr( double *c, double *c_i, lapack_int info,
00063 lapack_int info_i, lapack_int ldc, lapack_int n );
00064
00065 int main(void)
00066 {
00067
00068 char vect, vect_i;
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 k, k_i;
00074 lapack_int lda, lda_i;
00075 lapack_int lda_r;
00076 lapack_int ldc, ldc_i;
00077 lapack_int ldc_r;
00078 lapack_int lwork, lwork_i;
00079 lapack_int info, info_i;
00080
00081 lapack_int nq;
00082 lapack_int r;
00083 lapack_int i;
00084 int failed;
00085
00086
00087 double *a = NULL, *a_i = NULL;
00088 double *tau = NULL, *tau_i = NULL;
00089 double *c = NULL, *c_i = NULL;
00090 double *work = NULL, *work_i = NULL;
00091 double *c_save = NULL;
00092 double *a_r = NULL;
00093 double *c_r = NULL;
00094
00095
00096 init_scalars_dormbr( &vect, &side, &trans, &m, &n, &k, &lda, &ldc, &lwork );
00097 nq = LAPACKE_lsame( side, 'l' ) ? m : n;
00098 r = LAPACKE_lsame( vect, 'q' ) ? nq : MIN(nq,k);
00099 lda_r = MIN(nq,k)+2;
00100 ldc_r = n+2;
00101 vect_i = vect;
00102 side_i = side;
00103 trans_i = trans;
00104 m_i = m;
00105 n_i = n;
00106 k_i = k;
00107 lda_i = lda;
00108 ldc_i = ldc;
00109 lwork_i = lwork;
00110
00111
00112 a = (double *)LAPACKE_malloc( (lda*(MIN(nq,k))) * sizeof(double) );
00113 tau = (double *)LAPACKE_malloc( MIN(nq,k) * sizeof(double) );
00114 c = (double *)LAPACKE_malloc( ldc*n * sizeof(double) );
00115 work = (double *)LAPACKE_malloc( lwork * sizeof(double) );
00116
00117
00118 a_i = (double *)LAPACKE_malloc( (lda*(MIN(nq,k))) * sizeof(double) );
00119 tau_i = (double *)LAPACKE_malloc( MIN(nq,k) * sizeof(double) );
00120 c_i = (double *)LAPACKE_malloc( ldc*n * sizeof(double) );
00121 work_i = (double *)LAPACKE_malloc( lwork * sizeof(double) );
00122
00123
00124 c_save = (double *)LAPACKE_malloc( ldc*n * sizeof(double) );
00125
00126
00127 a_r = (double *)LAPACKE_malloc( (r*(MIN(nq,k)+2)) * sizeof(double) );
00128 c_r = (double *)LAPACKE_malloc( m*(n+2) * sizeof(double) );
00129
00130
00131 init_a( lda*(MIN(nq,k)), a );
00132 init_tau( (MIN(nq,k)), tau );
00133 init_c( ldc*n, c );
00134 init_work( lwork, work );
00135
00136
00137 for( i = 0; i < ldc*n; i++ ) {
00138 c_save[i] = c[i];
00139 }
00140
00141
00142 dormbr_( &vect, &side, &trans, &m, &n, &k, a, &lda, tau, c, &ldc, work,
00143 &lwork, &info );
00144
00145
00146
00147 for( i = 0; i < lda*(MIN(nq,k)); i++ ) {
00148 a_i[i] = a[i];
00149 }
00150 for( i = 0; i < (MIN(nq,k)); i++ ) {
00151 tau_i[i] = tau[i];
00152 }
00153 for( i = 0; i < ldc*n; i++ ) {
00154 c_i[i] = c_save[i];
00155 }
00156 for( i = 0; i < lwork; i++ ) {
00157 work_i[i] = work[i];
00158 }
00159 info_i = LAPACKE_dormbr_work( LAPACK_COL_MAJOR, vect_i, side_i, trans_i,
00160 m_i, n_i, k_i, a_i, lda_i, tau_i, c_i, ldc_i,
00161 work_i, lwork_i );
00162
00163 failed = compare_dormbr( c, c_i, info, info_i, ldc, n );
00164 if( failed == 0 ) {
00165 printf( "PASSED: column-major middle-level interface to dormbr\n" );
00166 } else {
00167 printf( "FAILED: column-major middle-level interface to dormbr\n" );
00168 }
00169
00170
00171
00172 for( i = 0; i < lda*(MIN(nq,k)); i++ ) {
00173 a_i[i] = a[i];
00174 }
00175 for( i = 0; i < (MIN(nq,k)); i++ ) {
00176 tau_i[i] = tau[i];
00177 }
00178 for( i = 0; i < ldc*n; i++ ) {
00179 c_i[i] = c_save[i];
00180 }
00181 for( i = 0; i < lwork; i++ ) {
00182 work_i[i] = work[i];
00183 }
00184 info_i = LAPACKE_dormbr( LAPACK_COL_MAJOR, vect_i, side_i, trans_i, m_i,
00185 n_i, k_i, a_i, lda_i, tau_i, c_i, ldc_i );
00186
00187 failed = compare_dormbr( c, c_i, info, info_i, ldc, n );
00188 if( failed == 0 ) {
00189 printf( "PASSED: column-major high-level interface to dormbr\n" );
00190 } else {
00191 printf( "FAILED: column-major high-level interface to dormbr\n" );
00192 }
00193
00194
00195
00196 for( i = 0; i < lda*(MIN(nq,k)); i++ ) {
00197 a_i[i] = a[i];
00198 }
00199 for( i = 0; i < (MIN(nq,k)); i++ ) {
00200 tau_i[i] = tau[i];
00201 }
00202 for( i = 0; i < ldc*n; i++ ) {
00203 c_i[i] = c_save[i];
00204 }
00205 for( i = 0; i < lwork; i++ ) {
00206 work_i[i] = work[i];
00207 }
00208
00209 LAPACKE_dge_trans( LAPACK_COL_MAJOR, r, MIN(nq, k ), a_i, lda, a_r, MIN(nq,
00210 k)+2);
00211 LAPACKE_dge_trans( LAPACK_COL_MAJOR, m, n, c_i, ldc, c_r, n+2 );
00212 info_i = LAPACKE_dormbr_work( LAPACK_ROW_MAJOR, vect_i, side_i, trans_i,
00213 m_i, n_i, k_i, a_r, lda_r, tau_i, c_r, ldc_r,
00214 work_i, lwork_i );
00215
00216 LAPACKE_dge_trans( LAPACK_ROW_MAJOR, m, n, c_r, n+2, c_i, ldc );
00217
00218 failed = compare_dormbr( c, c_i, info, info_i, ldc, n );
00219 if( failed == 0 ) {
00220 printf( "PASSED: row-major middle-level interface to dormbr\n" );
00221 } else {
00222 printf( "FAILED: row-major middle-level interface to dormbr\n" );
00223 }
00224
00225
00226
00227 for( i = 0; i < lda*(MIN(nq,k)); i++ ) {
00228 a_i[i] = a[i];
00229 }
00230 for( i = 0; i < (MIN(nq,k)); i++ ) {
00231 tau_i[i] = tau[i];
00232 }
00233 for( i = 0; i < ldc*n; i++ ) {
00234 c_i[i] = c_save[i];
00235 }
00236 for( i = 0; i < lwork; i++ ) {
00237 work_i[i] = work[i];
00238 }
00239
00240
00241 LAPACKE_dge_trans( LAPACK_COL_MAJOR, r, MIN(nq, k ), a_i, lda, a_r, MIN(nq,
00242 k)+2);
00243 LAPACKE_dge_trans( LAPACK_COL_MAJOR, m, n, c_i, ldc, c_r, n+2 );
00244 info_i = LAPACKE_dormbr( LAPACK_ROW_MAJOR, vect_i, side_i, trans_i, m_i,
00245 n_i, k_i, a_r, lda_r, tau_i, c_r, ldc_r );
00246
00247 LAPACKE_dge_trans( LAPACK_ROW_MAJOR, m, n, c_r, n+2, c_i, ldc );
00248
00249 failed = compare_dormbr( c, c_i, info, info_i, ldc, n );
00250 if( failed == 0 ) {
00251 printf( "PASSED: row-major high-level interface to dormbr\n" );
00252 } else {
00253 printf( "FAILED: row-major high-level interface to dormbr\n" );
00254 }
00255
00256
00257 if( a != NULL ) {
00258 LAPACKE_free( a );
00259 }
00260 if( a_i != NULL ) {
00261 LAPACKE_free( a_i );
00262 }
00263 if( a_r != NULL ) {
00264 LAPACKE_free( a_r );
00265 }
00266 if( tau != NULL ) {
00267 LAPACKE_free( tau );
00268 }
00269 if( tau_i != NULL ) {
00270 LAPACKE_free( tau_i );
00271 }
00272 if( c != NULL ) {
00273 LAPACKE_free( c );
00274 }
00275 if( c_i != NULL ) {
00276 LAPACKE_free( c_i );
00277 }
00278 if( c_r != NULL ) {
00279 LAPACKE_free( c_r );
00280 }
00281 if( c_save != NULL ) {
00282 LAPACKE_free( c_save );
00283 }
00284 if( work != NULL ) {
00285 LAPACKE_free( work );
00286 }
00287 if( work_i != NULL ) {
00288 LAPACKE_free( work_i );
00289 }
00290
00291 return 0;
00292 }
00293
00294
00295 static void init_scalars_dormbr( char *vect, char *side, char *trans,
00296 lapack_int *m, lapack_int *n, lapack_int *k,
00297 lapack_int *lda, lapack_int *ldc,
00298 lapack_int *lwork )
00299 {
00300 *vect = 'P';
00301 *side = 'L';
00302 *trans = 'T';
00303 *m = 4;
00304 *n = 6;
00305 *k = 4;
00306 *lda = 8;
00307 *ldc = 8;
00308 *lwork = 1024;
00309
00310 return;
00311 }
00312
00313
00314 static void init_a( lapack_int size, double *a ) {
00315 lapack_int i;
00316 for( i = 0; i < size; i++ ) {
00317 a[i] = 0;
00318 }
00319 a[0] = -7.77243511518227410e+000;
00320 a[8] = 1.19264108863209950e+000;
00321 a[16] = 6.89614896433047000e-003;
00322 a[24] = 9.19735435766610760e-001;
00323 a[1] = 7.83553986574664870e-003;
00324 a[9] = 6.15729328849950530e+000;
00325 a[17] = 5.73359547833418470e-001;
00326 a[25] = -1.80365480391148000e-001;
00327 a[2] = 6.63216706568521640e-003;
00328 a[10] = -2.79757050086544630e-002;
00329 a[18] = -6.05756976707502390e+000;
00330 a[26] = -1.91431961001422880e+000;
00331 a[3] = 9.58749407098464930e-002;
00332 a[11] = 9.16632580174005060e-001;
00333 a[19] = 2.01159941790179490e-001;
00334 a[27] = 5.79325355478497880e+000;
00335 }
00336 static void init_tau( lapack_int size, double *tau ) {
00337 lapack_int i;
00338 for( i = 0; i < size; i++ ) {
00339 tau[i] = 0;
00340 }
00341 tau[0] = 1.08344660890513220e+000;
00342 tau[1] = 1.93698652290983660e+000;
00343 tau[2] = 0.00000000000000000e+000;
00344 tau[3] = 0.00000000000000000e+000;
00345 }
00346 static void init_c( lapack_int size, double *c ) {
00347 lapack_int i;
00348 for( i = 0; i < size; i++ ) {
00349 c[i] = 0;
00350 }
00351 c[0] = -7.10424647623494550e-001;
00352 c[8] = 4.29924879004624120e-001;
00353 c[16] = -4.82354742297870950e-001;
00354 c[24] = 3.53901577229416220e-002;
00355 c[32] = 2.70013795960221240e-001;
00356 c[40] = 6.02943427872338690e-002;
00357 c[1] = -2.41220609086646300e-001;
00358 c[9] = -5.32304375430858400e-001;
00359 c[17] = -4.84485683461501670e-001;
00360 c[25] = -1.59491744636390260e-001;
00361 c[33] = -6.31105045107499870e-001;
00362 c[41] = -2.66413261186665940e-003;
00363 c[2] = 1.28682837788544220e-001;
00364 c[10] = -2.61945510022723260e-001;
00365 c[18] = -2.10836754876070700e-001;
00366 c[26] = -7.44728909781405380e-001;
00367 c[34] = 5.22684551387214700e-001;
00368 c[42] = -2.06283422765611180e-001;
00369 c[3] = -3.40347252557806620e-001;
00370 c[11] = -9.21261480768250930e-002;
00371 c[19] = 4.54640665997055160e-001;
00372 c[27] = -3.86923346707710390e-001;
00373 c[35] = -4.64798616714194040e-002;
00374 c[43] = 7.19102448591398160e-001;
00375 }
00376 static void init_work( lapack_int size, double *work ) {
00377 lapack_int i;
00378 for( i = 0; i < size; i++ ) {
00379 work[i] = 0;
00380 }
00381 }
00382
00383
00384
00385 static int compare_dormbr( double *c, double *c_i, lapack_int info,
00386 lapack_int info_i, lapack_int ldc, lapack_int n )
00387 {
00388 lapack_int i;
00389 int failed = 0;
00390 for( i = 0; i < ldc*n; i++ ) {
00391 failed += compare_doubles(c[i],c_i[i]);
00392 }
00393 failed += (info == info_i) ? 0 : 1;
00394 if( info != 0 || info_i != 0 ) {
00395 printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00396 }
00397
00398 return failed;
00399 }