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_dormlq( char *side, char *trans, lapack_int *m,
00055 lapack_int *n, lapack_int *k, lapack_int *lda,
00056 lapack_int *ldc, lapack_int *lwork );
00057 static void init_a( lapack_int size, double *a );
00058 static void init_tau( lapack_int size, double *tau );
00059 static void init_c( lapack_int size, double *c );
00060 static void init_work( lapack_int size, double *work );
00061 static int compare_dormlq( double *c, double *c_i, lapack_int info,
00062 lapack_int info_i, lapack_int ldc, lapack_int n );
00063
00064 int main(void)
00065 {
00066
00067 char side, side_i;
00068 char trans, trans_i;
00069 lapack_int m, m_i;
00070 lapack_int n, n_i;
00071 lapack_int k, k_i;
00072 lapack_int lda, lda_i;
00073 lapack_int lda_r;
00074 lapack_int ldc, ldc_i;
00075 lapack_int ldc_r;
00076 lapack_int lwork, lwork_i;
00077 lapack_int info, info_i;
00078 lapack_int i;
00079 int failed;
00080
00081
00082 double *a = NULL, *a_i = NULL;
00083 double *tau = NULL, *tau_i = NULL;
00084 double *c = NULL, *c_i = NULL;
00085 double *work = NULL, *work_i = NULL;
00086 double *c_save = NULL;
00087 double *a_r = NULL;
00088 double *c_r = NULL;
00089
00090
00091 init_scalars_dormlq( &side, &trans, &m, &n, &k, &lda, &ldc, &lwork );
00092 lda_r = m+2;
00093 ldc_r = n+2;
00094 side_i = side;
00095 trans_i = trans;
00096 m_i = m;
00097 n_i = n;
00098 k_i = k;
00099 lda_i = lda;
00100 ldc_i = ldc;
00101 lwork_i = lwork;
00102
00103
00104 a = (double *)LAPACKE_malloc( lda*m * sizeof(double) );
00105 tau = (double *)LAPACKE_malloc( k * sizeof(double) );
00106 c = (double *)LAPACKE_malloc( ldc*n * sizeof(double) );
00107 work = (double *)LAPACKE_malloc( lwork * sizeof(double) );
00108
00109
00110 a_i = (double *)LAPACKE_malloc( lda*m * sizeof(double) );
00111 tau_i = (double *)LAPACKE_malloc( k * sizeof(double) );
00112 c_i = (double *)LAPACKE_malloc( ldc*n * sizeof(double) );
00113 work_i = (double *)LAPACKE_malloc( lwork * sizeof(double) );
00114
00115
00116 c_save = (double *)LAPACKE_malloc( ldc*n * sizeof(double) );
00117
00118
00119 a_r = (double *)LAPACKE_malloc( k*(m+2) * sizeof(double) );
00120 c_r = (double *)LAPACKE_malloc( m*(n+2) * sizeof(double) );
00121
00122
00123 init_a( lda*m, a );
00124 init_tau( k, tau );
00125 init_c( ldc*n, c );
00126 init_work( lwork, work );
00127
00128
00129 for( i = 0; i < ldc*n; i++ ) {
00130 c_save[i] = c[i];
00131 }
00132
00133
00134 dormlq_( &side, &trans, &m, &n, &k, a, &lda, tau, c, &ldc, work, &lwork,
00135 &info );
00136
00137
00138
00139 for( i = 0; i < lda*m; i++ ) {
00140 a_i[i] = a[i];
00141 }
00142 for( i = 0; i < k; i++ ) {
00143 tau_i[i] = tau[i];
00144 }
00145 for( i = 0; i < ldc*n; i++ ) {
00146 c_i[i] = c_save[i];
00147 }
00148 for( i = 0; i < lwork; i++ ) {
00149 work_i[i] = work[i];
00150 }
00151 info_i = LAPACKE_dormlq_work( LAPACK_COL_MAJOR, side_i, trans_i, m_i, n_i,
00152 k_i, a_i, lda_i, tau_i, c_i, ldc_i, work_i,
00153 lwork_i );
00154
00155 failed = compare_dormlq( c, c_i, info, info_i, ldc, n );
00156 if( failed == 0 ) {
00157 printf( "PASSED: column-major middle-level interface to dormlq\n" );
00158 } else {
00159 printf( "FAILED: column-major middle-level interface to dormlq\n" );
00160 }
00161
00162
00163
00164 for( i = 0; i < lda*m; i++ ) {
00165 a_i[i] = a[i];
00166 }
00167 for( i = 0; i < k; i++ ) {
00168 tau_i[i] = tau[i];
00169 }
00170 for( i = 0; i < ldc*n; i++ ) {
00171 c_i[i] = c_save[i];
00172 }
00173 for( i = 0; i < lwork; i++ ) {
00174 work_i[i] = work[i];
00175 }
00176 info_i = LAPACKE_dormlq( LAPACK_COL_MAJOR, side_i, trans_i, m_i, n_i, k_i,
00177 a_i, lda_i, tau_i, c_i, ldc_i );
00178
00179 failed = compare_dormlq( c, c_i, info, info_i, ldc, n );
00180 if( failed == 0 ) {
00181 printf( "PASSED: column-major high-level interface to dormlq\n" );
00182 } else {
00183 printf( "FAILED: column-major high-level interface to dormlq\n" );
00184 }
00185
00186
00187
00188 for( i = 0; i < lda*m; i++ ) {
00189 a_i[i] = a[i];
00190 }
00191 for( i = 0; i < k; i++ ) {
00192 tau_i[i] = tau[i];
00193 }
00194 for( i = 0; i < ldc*n; i++ ) {
00195 c_i[i] = c_save[i];
00196 }
00197 for( i = 0; i < lwork; i++ ) {
00198 work_i[i] = work[i];
00199 }
00200
00201 LAPACKE_dge_trans( LAPACK_COL_MAJOR, k, m, a_i, lda, a_r, m+2 );
00202 LAPACKE_dge_trans( LAPACK_COL_MAJOR, m, n, c_i, ldc, c_r, n+2 );
00203 info_i = LAPACKE_dormlq_work( LAPACK_ROW_MAJOR, side_i, trans_i, m_i, n_i,
00204 k_i, a_r, lda_r, tau_i, c_r, ldc_r, work_i,
00205 lwork_i );
00206
00207 LAPACKE_dge_trans( LAPACK_ROW_MAJOR, m, n, c_r, n+2, c_i, ldc );
00208
00209 failed = compare_dormlq( c, c_i, info, info_i, ldc, n );
00210 if( failed == 0 ) {
00211 printf( "PASSED: row-major middle-level interface to dormlq\n" );
00212 } else {
00213 printf( "FAILED: row-major middle-level interface to dormlq\n" );
00214 }
00215
00216
00217
00218 for( i = 0; i < lda*m; i++ ) {
00219 a_i[i] = a[i];
00220 }
00221 for( i = 0; i < k; i++ ) {
00222 tau_i[i] = tau[i];
00223 }
00224 for( i = 0; i < ldc*n; i++ ) {
00225 c_i[i] = c_save[i];
00226 }
00227 for( i = 0; i < lwork; i++ ) {
00228 work_i[i] = work[i];
00229 }
00230
00231
00232 LAPACKE_dge_trans( LAPACK_COL_MAJOR, k, m, a_i, lda, a_r, m+2 );
00233 LAPACKE_dge_trans( LAPACK_COL_MAJOR, m, n, c_i, ldc, c_r, n+2 );
00234 info_i = LAPACKE_dormlq( LAPACK_ROW_MAJOR, side_i, trans_i, m_i, n_i, k_i,
00235 a_r, lda_r, tau_i, c_r, ldc_r );
00236
00237 LAPACKE_dge_trans( LAPACK_ROW_MAJOR, m, n, c_r, n+2, c_i, ldc );
00238
00239 failed = compare_dormlq( c, c_i, info, info_i, ldc, n );
00240 if( failed == 0 ) {
00241 printf( "PASSED: row-major high-level interface to dormlq\n" );
00242 } else {
00243 printf( "FAILED: row-major high-level interface to dormlq\n" );
00244 }
00245
00246
00247 if( a != NULL ) {
00248 LAPACKE_free( a );
00249 }
00250 if( a_i != NULL ) {
00251 LAPACKE_free( a_i );
00252 }
00253 if( a_r != NULL ) {
00254 LAPACKE_free( a_r );
00255 }
00256 if( tau != NULL ) {
00257 LAPACKE_free( tau );
00258 }
00259 if( tau_i != NULL ) {
00260 LAPACKE_free( tau_i );
00261 }
00262 if( c != NULL ) {
00263 LAPACKE_free( c );
00264 }
00265 if( c_i != NULL ) {
00266 LAPACKE_free( c_i );
00267 }
00268 if( c_r != NULL ) {
00269 LAPACKE_free( c_r );
00270 }
00271 if( c_save != NULL ) {
00272 LAPACKE_free( c_save );
00273 }
00274 if( work != NULL ) {
00275 LAPACKE_free( work );
00276 }
00277 if( work_i != NULL ) {
00278 LAPACKE_free( work_i );
00279 }
00280
00281 return 0;
00282 }
00283
00284
00285 static void init_scalars_dormlq( char *side, char *trans, lapack_int *m,
00286 lapack_int *n, lapack_int *k, lapack_int *lda,
00287 lapack_int *ldc, lapack_int *lwork )
00288 {
00289 *side = 'L';
00290 *trans = 'T';
00291 *m = 6;
00292 *n = 2;
00293 *k = 4;
00294 *lda = 8;
00295 *ldc = 8;
00296 *lwork = 512;
00297
00298 return;
00299 }
00300
00301
00302 static void init_a( lapack_int size, double *a ) {
00303 lapack_int i;
00304 for( i = 0; i < size; i++ ) {
00305 a[i] = 0;
00306 }
00307 a[0] = 7.62923980485605120e+000;
00308 a[8] = -2.51355638263265290e-001;
00309 a[16] = 2.82008764880736670e-001;
00310 a[24] = -2.06908604667931820e-002;
00311 a[32] = -1.57863602079977600e-001;
00312 a[40] = -3.52510956100920840e-002;
00313 a[1] = 1.20680437835230640e-001;
00314 a[9] = 6.48479268997273990e+000;
00315 a[17] = 2.61441274102564740e-001;
00316 a[25] = 1.03257601872874400e-001;
00317 a[33] = 4.20095204298865380e-001;
00318 a[41] = 7.01058900740689300e-003;
00319 a[2] = 1.02146481161068170e-001;
00320 a[10] = -1.66186146532236250e+000;
00321 a[18] = -5.42658111212419050e+000;
00322 a[26] = 6.05137487741764240e-001;
00323 a[34] = -5.38668351256243130e-001;
00324 a[42] = 1.68593777638160250e-001;
00325 a[3] = 1.47663466979100420e+000;
00326 a[11] = 1.08823691868845880e-001;
00327 a[19] = 4.22288562190424880e-001;
00328 a[27] = 6.25553193791722250e+000;
00329 a[35] = -1.70447905668462570e-001;
00330 a[43] = -3.49862972443161500e-001;
00331 }
00332 static void init_tau( lapack_int size, double *tau ) {
00333 lapack_int i;
00334 for( i = 0; i < size; i++ ) {
00335 tau[i] = 0;
00336 }
00337 tau[0] = 1.71042464762349460e+000;
00338 tau[1] = 1.59293653559008600e+000;
00339 tau[2] = 1.18709943414798150e+000;
00340 tau[3] = 1.73693044165531460e+000;
00341 }
00342 static void init_c( lapack_int size, double *c ) {
00343 lapack_int i;
00344 for( i = 0; i < size; i++ ) {
00345 c[i] = 0;
00346 }
00347 c[0] = -3.76184269129046120e-001;
00348 c[8] = -6.85520462559202510e-001;
00349 c[1] = 2.58358001929011930e-001;
00350 c[9] = 5.74773824524868820e-002;
00351 c[2] = 5.62457066412861200e-001;
00352 c[10] = -9.07669644711465610e-001;
00353 c[3] = 1.18271648823068400e-001;
00354 c[11] = -1.12231752304341880e+000;
00355 c[4] = 0.00000000000000000e+000;
00356 c[12] = 0.00000000000000000e+000;
00357 c[5] = 0.00000000000000000e+000;
00358 c[13] = 0.00000000000000000e+000;
00359 }
00360 static void init_work( lapack_int size, double *work ) {
00361 lapack_int i;
00362 for( i = 0; i < size; i++ ) {
00363 work[i] = 0;
00364 }
00365 }
00366
00367
00368
00369 static int compare_dormlq( double *c, double *c_i, lapack_int info,
00370 lapack_int info_i, lapack_int ldc, lapack_int n )
00371 {
00372 lapack_int i;
00373 int failed = 0;
00374 for( i = 0; i < ldc*n; i++ ) {
00375 failed += compare_doubles(c[i],c_i[i]);
00376 }
00377 failed += (info == info_i) ? 0 : 1;
00378 if( info != 0 || info_i != 0 ) {
00379 printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00380 }
00381
00382 return failed;
00383 }