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_sormlq( 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, float *a );
00058 static void init_tau( lapack_int size, float *tau );
00059 static void init_c( lapack_int size, float *c );
00060 static void init_work( lapack_int size, float *work );
00061 static int compare_sormlq( float *c, float *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 float *a = NULL, *a_i = NULL;
00083 float *tau = NULL, *tau_i = NULL;
00084 float *c = NULL, *c_i = NULL;
00085 float *work = NULL, *work_i = NULL;
00086 float *c_save = NULL;
00087 float *a_r = NULL;
00088 float *c_r = NULL;
00089
00090
00091 init_scalars_sormlq( &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 = (float *)LAPACKE_malloc( lda*m * sizeof(float) );
00105 tau = (float *)LAPACKE_malloc( k * sizeof(float) );
00106 c = (float *)LAPACKE_malloc( ldc*n * sizeof(float) );
00107 work = (float *)LAPACKE_malloc( lwork * sizeof(float) );
00108
00109
00110 a_i = (float *)LAPACKE_malloc( lda*m * sizeof(float) );
00111 tau_i = (float *)LAPACKE_malloc( k * sizeof(float) );
00112 c_i = (float *)LAPACKE_malloc( ldc*n * sizeof(float) );
00113 work_i = (float *)LAPACKE_malloc( lwork * sizeof(float) );
00114
00115
00116 c_save = (float *)LAPACKE_malloc( ldc*n * sizeof(float) );
00117
00118
00119 a_r = (float *)LAPACKE_malloc( k*(m+2) * sizeof(float) );
00120 c_r = (float *)LAPACKE_malloc( m*(n+2) * sizeof(float) );
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 sormlq_( &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_sormlq_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_sormlq( c, c_i, info, info_i, ldc, n );
00156 if( failed == 0 ) {
00157 printf( "PASSED: column-major middle-level interface to sormlq\n" );
00158 } else {
00159 printf( "FAILED: column-major middle-level interface to sormlq\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_sormlq( 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_sormlq( c, c_i, info, info_i, ldc, n );
00180 if( failed == 0 ) {
00181 printf( "PASSED: column-major high-level interface to sormlq\n" );
00182 } else {
00183 printf( "FAILED: column-major high-level interface to sormlq\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_sge_trans( LAPACK_COL_MAJOR, k, m, a_i, lda, a_r, m+2 );
00202 LAPACKE_sge_trans( LAPACK_COL_MAJOR, m, n, c_i, ldc, c_r, n+2 );
00203 info_i = LAPACKE_sormlq_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_sge_trans( LAPACK_ROW_MAJOR, m, n, c_r, n+2, c_i, ldc );
00208
00209 failed = compare_sormlq( c, c_i, info, info_i, ldc, n );
00210 if( failed == 0 ) {
00211 printf( "PASSED: row-major middle-level interface to sormlq\n" );
00212 } else {
00213 printf( "FAILED: row-major middle-level interface to sormlq\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_sge_trans( LAPACK_COL_MAJOR, k, m, a_i, lda, a_r, m+2 );
00233 LAPACKE_sge_trans( LAPACK_COL_MAJOR, m, n, c_i, ldc, c_r, n+2 );
00234 info_i = LAPACKE_sormlq( 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_sge_trans( LAPACK_ROW_MAJOR, m, n, c_r, n+2, c_i, ldc );
00238
00239 failed = compare_sormlq( c, c_i, info, info_i, ldc, n );
00240 if( failed == 0 ) {
00241 printf( "PASSED: row-major high-level interface to sormlq\n" );
00242 } else {
00243 printf( "FAILED: row-major high-level interface to sormlq\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_sormlq( 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, float *a ) {
00303 lapack_int i;
00304 for( i = 0; i < size; i++ ) {
00305 a[i] = 0;
00306 }
00307 a[0] = 7.629240036e+000;
00308 a[8] = -2.513556182e-001;
00309 a[16] = 2.820087671e-001;
00310 a[24] = -2.069086023e-002;
00311 a[32] = -1.578635871e-001;
00312 a[40] = -3.525109589e-002;
00313 a[1] = 1.206805706e-001;
00314 a[9] = 6.484792709e+000;
00315 a[17] = 2.614412904e-001;
00316 a[25] = 1.032576039e-001;
00317 a[33] = 4.200951755e-001;
00318 a[41] = 7.010589354e-003;
00319 a[2] = 1.021463647e-001;
00320 a[10] = -1.661861420e+000;
00321 a[18] = -5.426580906e+000;
00322 a[26] = 6.051375270e-001;
00323 a[34] = -5.386683345e-001;
00324 a[42] = 1.685937792e-001;
00325 a[3] = 1.476634502e+000;
00326 a[11] = 1.088234186e-001;
00327 a[19] = 4.222885072e-001;
00328 a[27] = 6.255532265e+000;
00329 a[35] = -1.704478860e-001;
00330 a[43] = -3.498629630e-001;
00331 }
00332 static void init_tau( lapack_int size, float *tau ) {
00333 lapack_int i;
00334 for( i = 0; i < size; i++ ) {
00335 tau[i] = 0;
00336 }
00337 tau[0] = 1.710424662e+000;
00338 tau[1] = 1.592936516e+000;
00339 tau[2] = 1.187099457e+000;
00340 tau[3] = 1.736930490e+000;
00341 }
00342 static void init_c( lapack_int size, float *c ) {
00343 lapack_int i;
00344 for( i = 0; i < size; i++ ) {
00345 c[i] = 0;
00346 }
00347 c[0] = -3.761842251e-001;
00348 c[8] = -6.855204105e-001;
00349 c[1] = 2.583580017e-001;
00350 c[9] = 5.747739598e-002;
00351 c[2] = 5.624570847e-001;
00352 c[10] = -9.076697826e-001;
00353 c[3] = 1.182716414e-001;
00354 c[11] = -1.122317433e+000;
00355 c[4] = 0.000000000e+000;
00356 c[12] = 0.000000000e+000;
00357 c[5] = 0.000000000e+000;
00358 c[13] = 0.000000000e+000;
00359 }
00360 static void init_work( lapack_int size, float *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_sormlq( float *c, float *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_floats(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 }