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_dopmtr( char *side, char *uplo, char *trans,
00055 lapack_int *m, lapack_int *n,
00056 lapack_int *ldc );
00057 static void init_ap( lapack_int size, double *ap );
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_dopmtr( 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 uplo, uplo_i;
00069 char trans, trans_i;
00070 lapack_int m, m_i;
00071 lapack_int n, n_i;
00072 lapack_int ldc, ldc_i;
00073 lapack_int ldc_r;
00074 lapack_int info, info_i;
00075
00076 lapack_int lwork;
00077 lapack_int i;
00078 int failed;
00079
00080
00081 double *ap = NULL, *ap_i = NULL;
00082 double *tau = NULL, *tau_i = NULL;
00083 double *c = NULL, *c_i = NULL;
00084 double *work = NULL, *work_i = NULL;
00085 double *c_save = NULL;
00086 double *ap_r = NULL;
00087 double *c_r = NULL;
00088
00089
00090 init_scalars_dopmtr( &side, &uplo, &trans, &m, &n, &ldc );
00091 lwork = MAX(m,n);
00092 ldc_r = n+2;
00093 side_i = side;
00094 uplo_i = uplo;
00095 trans_i = trans;
00096 m_i = m;
00097 n_i = n;
00098 ldc_i = ldc;
00099
00100
00101 ap = (double *)LAPACKE_malloc( ((m*(m+1)/2)) * sizeof(double) );
00102 tau = (double *)LAPACKE_malloc( (m-1) * sizeof(double) );
00103 c = (double *)LAPACKE_malloc( ldc*n * sizeof(double) );
00104 work = (double *)LAPACKE_malloc( lwork * sizeof(double) );
00105
00106
00107 ap_i = (double *)LAPACKE_malloc( ((m*(m+1)/2)) * sizeof(double) );
00108 tau_i = (double *)LAPACKE_malloc( (m-1) * sizeof(double) );
00109 c_i = (double *)LAPACKE_malloc( ldc*n * sizeof(double) );
00110 work_i = (double *)LAPACKE_malloc( lwork * sizeof(double) );
00111
00112
00113 c_save = (double *)LAPACKE_malloc( ldc*n * sizeof(double) );
00114
00115
00116 ap_r = (double *)LAPACKE_malloc( m*(m+1)/2 * sizeof(double) );
00117 c_r = (double *)LAPACKE_malloc( m*(n+2) * sizeof(double) );
00118
00119
00120 init_ap( (m*(m+1)/2), ap );
00121 init_tau( (m-1), tau );
00122 init_c( ldc*n, c );
00123 init_work( lwork, work );
00124
00125
00126 for( i = 0; i < ldc*n; i++ ) {
00127 c_save[i] = c[i];
00128 }
00129
00130
00131 dopmtr_( &side, &uplo, &trans, &m, &n, ap, tau, c, &ldc, work, &info );
00132
00133
00134
00135 for( i = 0; i < (m*(m+1)/2); i++ ) {
00136 ap_i[i] = ap[i];
00137 }
00138 for( i = 0; i < (m-1); i++ ) {
00139 tau_i[i] = tau[i];
00140 }
00141 for( i = 0; i < ldc*n; i++ ) {
00142 c_i[i] = c_save[i];
00143 }
00144 for( i = 0; i < lwork; i++ ) {
00145 work_i[i] = work[i];
00146 }
00147 info_i = LAPACKE_dopmtr_work( LAPACK_COL_MAJOR, side_i, uplo_i, trans_i,
00148 m_i, n_i, ap_i, tau_i, c_i, ldc_i, work_i );
00149
00150 failed = compare_dopmtr( c, c_i, info, info_i, ldc, n );
00151 if( failed == 0 ) {
00152 printf( "PASSED: column-major middle-level interface to dopmtr\n" );
00153 } else {
00154 printf( "FAILED: column-major middle-level interface to dopmtr\n" );
00155 }
00156
00157
00158
00159 for( i = 0; i < (m*(m+1)/2); i++ ) {
00160 ap_i[i] = ap[i];
00161 }
00162 for( i = 0; i < (m-1); 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_dopmtr( LAPACK_COL_MAJOR, side_i, uplo_i, trans_i, m_i,
00172 n_i, ap_i, tau_i, c_i, ldc_i );
00173
00174 failed = compare_dopmtr( c, c_i, info, info_i, ldc, n );
00175 if( failed == 0 ) {
00176 printf( "PASSED: column-major high-level interface to dopmtr\n" );
00177 } else {
00178 printf( "FAILED: column-major high-level interface to dopmtr\n" );
00179 }
00180
00181
00182
00183 for( i = 0; i < (m*(m+1)/2); i++ ) {
00184 ap_i[i] = ap[i];
00185 }
00186 for( i = 0; i < (m-1); i++ ) {
00187 tau_i[i] = tau[i];
00188 }
00189 for( i = 0; i < ldc*n; i++ ) {
00190 c_i[i] = c_save[i];
00191 }
00192 for( i = 0; i < lwork; i++ ) {
00193 work_i[i] = work[i];
00194 }
00195
00196 LAPACKE_dpp_trans( LAPACK_COL_MAJOR, uplo, m, ap_i, ap_r );
00197 LAPACKE_dge_trans( LAPACK_COL_MAJOR, m, n, c_i, ldc, c_r, n+2 );
00198 info_i = LAPACKE_dopmtr_work( LAPACK_ROW_MAJOR, side_i, uplo_i, trans_i,
00199 m_i, n_i, ap_r, tau_i, c_r, ldc_r, work_i );
00200
00201 LAPACKE_dge_trans( LAPACK_ROW_MAJOR, m, n, c_r, n+2, c_i, ldc );
00202
00203 failed = compare_dopmtr( c, c_i, info, info_i, ldc, n );
00204 if( failed == 0 ) {
00205 printf( "PASSED: row-major middle-level interface to dopmtr\n" );
00206 } else {
00207 printf( "FAILED: row-major middle-level interface to dopmtr\n" );
00208 }
00209
00210
00211
00212 for( i = 0; i < (m*(m+1)/2); i++ ) {
00213 ap_i[i] = ap[i];
00214 }
00215 for( i = 0; i < (m-1); i++ ) {
00216 tau_i[i] = tau[i];
00217 }
00218 for( i = 0; i < ldc*n; i++ ) {
00219 c_i[i] = c_save[i];
00220 }
00221 for( i = 0; i < lwork; i++ ) {
00222 work_i[i] = work[i];
00223 }
00224
00225
00226 LAPACKE_dpp_trans( LAPACK_COL_MAJOR, uplo, m, ap_i, ap_r );
00227 LAPACKE_dge_trans( LAPACK_COL_MAJOR, m, n, c_i, ldc, c_r, n+2 );
00228 info_i = LAPACKE_dopmtr( LAPACK_ROW_MAJOR, side_i, uplo_i, trans_i, m_i,
00229 n_i, ap_r, tau_i, c_r, ldc_r );
00230
00231 LAPACKE_dge_trans( LAPACK_ROW_MAJOR, m, n, c_r, n+2, c_i, ldc );
00232
00233 failed = compare_dopmtr( c, c_i, info, info_i, ldc, n );
00234 if( failed == 0 ) {
00235 printf( "PASSED: row-major high-level interface to dopmtr\n" );
00236 } else {
00237 printf( "FAILED: row-major high-level interface to dopmtr\n" );
00238 }
00239
00240
00241 if( ap != NULL ) {
00242 LAPACKE_free( ap );
00243 }
00244 if( ap_i != NULL ) {
00245 LAPACKE_free( ap_i );
00246 }
00247 if( ap_r != NULL ) {
00248 LAPACKE_free( ap_r );
00249 }
00250 if( tau != NULL ) {
00251 LAPACKE_free( tau );
00252 }
00253 if( tau_i != NULL ) {
00254 LAPACKE_free( tau_i );
00255 }
00256 if( c != NULL ) {
00257 LAPACKE_free( c );
00258 }
00259 if( c_i != NULL ) {
00260 LAPACKE_free( c_i );
00261 }
00262 if( c_r != NULL ) {
00263 LAPACKE_free( c_r );
00264 }
00265 if( c_save != NULL ) {
00266 LAPACKE_free( c_save );
00267 }
00268 if( work != NULL ) {
00269 LAPACKE_free( work );
00270 }
00271 if( work_i != NULL ) {
00272 LAPACKE_free( work_i );
00273 }
00274
00275 return 0;
00276 }
00277
00278
00279 static void init_scalars_dopmtr( char *side, char *uplo, char *trans,
00280 lapack_int *m, lapack_int *n, lapack_int *ldc )
00281 {
00282 *side = 'L';
00283 *uplo = 'L';
00284 *trans = 'N';
00285 *m = 4;
00286 *n = 2;
00287 *ldc = 8;
00288
00289 return;
00290 }
00291
00292
00293 static void init_ap( lapack_int size, double *ap ) {
00294 lapack_int i;
00295 for( i = 0; i < size; i++ ) {
00296 ap[i] = 0;
00297 }
00298 ap[0] = 2.06999999999999980e+000;
00299 ap[1] = -5.82575317019181590e+000;
00300 ap[2] = 4.33179344221786720e-001;
00301 ap[3] = -1.18608629965489210e-001;
00302 ap[4] = 1.47409370819755310e+000;
00303 ap[5] = 2.62404517879558740e+000;
00304 ap[6] = 8.06288153277579080e-001;
00305 ap[7] = -6.49159507545784330e-001;
00306 ap[8] = 9.16272756321918620e-001;
00307 ap[9] = -1.69493420065176800e+000;
00308 }
00309 static void init_tau( lapack_int size, double *tau ) {
00310 lapack_int i;
00311 for( i = 0; i < size; i++ ) {
00312 tau[i] = 0;
00313 }
00314 tau[0] = 1.66429178973824920e+000;
00315 tau[1] = 1.21204732416214210e+000;
00316 tau[2] = 0.00000000000000000e+000;
00317 }
00318 static void init_c( lapack_int size, double *c ) {
00319 lapack_int i;
00320 for( i = 0; i < size; i++ ) {
00321 c[i] = 0;
00322 }
00323 c[0] = 5.65759178822387240e-001;
00324 c[8] = -2.32842430803157250e-001;
00325 c[1] = 6.86917957250591790e-001;
00326 c[9] = -1.62617096149163560e-001;
00327 c[2] = -4.39588937213165000e-001;
00328 c[10] = -3.01727334388271980e-001;
00329 c[3] = 1.21744970593008300e-001;
00330 c[11] = 9.10110267022979150e-001;
00331 }
00332 static void init_work( lapack_int size, double *work ) {
00333 lapack_int i;
00334 for( i = 0; i < size; i++ ) {
00335 work[i] = 0;
00336 }
00337 }
00338
00339
00340
00341 static int compare_dopmtr( double *c, double *c_i, lapack_int info,
00342 lapack_int info_i, lapack_int ldc, lapack_int n )
00343 {
00344 lapack_int i;
00345 int failed = 0;
00346 for( i = 0; i < ldc*n; i++ ) {
00347 failed += compare_doubles(c[i],c_i[i]);
00348 }
00349 failed += (info == info_i) ? 0 : 1;
00350 if( info != 0 || info_i != 0 ) {
00351 printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00352 }
00353
00354 return failed;
00355 }