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_zupmtr( 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, lapack_complex_double *ap );
00058 static void init_tau( lapack_int size, lapack_complex_double *tau );
00059 static void init_c( lapack_int size, lapack_complex_double *c );
00060 static void init_work( lapack_int size, lapack_complex_double *work );
00061 static int compare_zupmtr( lapack_complex_double *c, lapack_complex_double *c_i,
00062 lapack_int info, lapack_int info_i, lapack_int ldc,
00063 lapack_int n );
00064
00065 int main(void)
00066 {
00067
00068 char side, side_i;
00069 char uplo, uplo_i;
00070 char trans, trans_i;
00071 lapack_int m, m_i;
00072 lapack_int n, n_i;
00073 lapack_int ldc, ldc_i;
00074 lapack_int ldc_r;
00075 lapack_int info, info_i;
00076
00077 lapack_int lwork;
00078 lapack_int i;
00079 int failed;
00080
00081
00082 lapack_complex_double *ap = NULL, *ap_i = NULL;
00083 lapack_complex_double *tau = NULL, *tau_i = NULL;
00084 lapack_complex_double *c = NULL, *c_i = NULL;
00085 lapack_complex_double *work = NULL, *work_i = NULL;
00086 lapack_complex_double *c_save = NULL;
00087 lapack_complex_double *ap_r = NULL;
00088 lapack_complex_double *c_r = NULL;
00089
00090
00091 init_scalars_zupmtr( &side, &uplo, &trans, &m, &n, &ldc );
00092 lwork = MAX(m,n);
00093 ldc_r = n+2;
00094 side_i = side;
00095 uplo_i = uplo;
00096 trans_i = trans;
00097 m_i = m;
00098 n_i = n;
00099 ldc_i = ldc;
00100
00101
00102 ap = (lapack_complex_double *)
00103 LAPACKE_malloc( ((m*(m+1)/2)) * sizeof(lapack_complex_double) );
00104 tau = (lapack_complex_double *)
00105 LAPACKE_malloc( (m-1) * sizeof(lapack_complex_double) );
00106 c = (lapack_complex_double *)
00107 LAPACKE_malloc( ldc*n * sizeof(lapack_complex_double) );
00108 work = (lapack_complex_double *)
00109 LAPACKE_malloc( lwork * sizeof(lapack_complex_double) );
00110
00111
00112 ap_i = (lapack_complex_double *)
00113 LAPACKE_malloc( ((m*(m+1)/2)) * sizeof(lapack_complex_double) );
00114 tau_i = (lapack_complex_double *)
00115 LAPACKE_malloc( (m-1) * sizeof(lapack_complex_double) );
00116 c_i = (lapack_complex_double *)
00117 LAPACKE_malloc( ldc*n * sizeof(lapack_complex_double) );
00118 work_i = (lapack_complex_double *)
00119 LAPACKE_malloc( lwork * sizeof(lapack_complex_double) );
00120
00121
00122 c_save = (lapack_complex_double *)
00123 LAPACKE_malloc( ldc*n * sizeof(lapack_complex_double) );
00124
00125
00126 ap_r = (lapack_complex_double *)
00127 LAPACKE_malloc( m*(m+1)/2 * sizeof(lapack_complex_double) );
00128 c_r = (lapack_complex_double *)
00129 LAPACKE_malloc( m*(n+2) * sizeof(lapack_complex_double) );
00130
00131
00132 init_ap( (m*(m+1)/2), ap );
00133 init_tau( (m-1), tau );
00134 init_c( ldc*n, c );
00135 init_work( lwork, work );
00136
00137
00138 for( i = 0; i < ldc*n; i++ ) {
00139 c_save[i] = c[i];
00140 }
00141
00142
00143 zupmtr_( &side, &uplo, &trans, &m, &n, ap, tau, c, &ldc, work, &info );
00144
00145
00146
00147 for( i = 0; i < (m*(m+1)/2); i++ ) {
00148 ap_i[i] = ap[i];
00149 }
00150 for( i = 0; i < (m-1); 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_zupmtr_work( LAPACK_COL_MAJOR, side_i, uplo_i, trans_i,
00160 m_i, n_i, ap_i, tau_i, c_i, ldc_i, work_i );
00161
00162 failed = compare_zupmtr( c, c_i, info, info_i, ldc, n );
00163 if( failed == 0 ) {
00164 printf( "PASSED: column-major middle-level interface to zupmtr\n" );
00165 } else {
00166 printf( "FAILED: column-major middle-level interface to zupmtr\n" );
00167 }
00168
00169
00170
00171 for( i = 0; i < (m*(m+1)/2); i++ ) {
00172 ap_i[i] = ap[i];
00173 }
00174 for( i = 0; i < (m-1); i++ ) {
00175 tau_i[i] = tau[i];
00176 }
00177 for( i = 0; i < ldc*n; i++ ) {
00178 c_i[i] = c_save[i];
00179 }
00180 for( i = 0; i < lwork; i++ ) {
00181 work_i[i] = work[i];
00182 }
00183 info_i = LAPACKE_zupmtr( LAPACK_COL_MAJOR, side_i, uplo_i, trans_i, m_i,
00184 n_i, ap_i, tau_i, c_i, ldc_i );
00185
00186 failed = compare_zupmtr( c, c_i, info, info_i, ldc, n );
00187 if( failed == 0 ) {
00188 printf( "PASSED: column-major high-level interface to zupmtr\n" );
00189 } else {
00190 printf( "FAILED: column-major high-level interface to zupmtr\n" );
00191 }
00192
00193
00194
00195 for( i = 0; i < (m*(m+1)/2); i++ ) {
00196 ap_i[i] = ap[i];
00197 }
00198 for( i = 0; i < (m-1); i++ ) {
00199 tau_i[i] = tau[i];
00200 }
00201 for( i = 0; i < ldc*n; i++ ) {
00202 c_i[i] = c_save[i];
00203 }
00204 for( i = 0; i < lwork; i++ ) {
00205 work_i[i] = work[i];
00206 }
00207
00208 LAPACKE_zpp_trans( LAPACK_COL_MAJOR, uplo, m, ap_i, ap_r );
00209 LAPACKE_zge_trans( LAPACK_COL_MAJOR, m, n, c_i, ldc, c_r, n+2 );
00210 info_i = LAPACKE_zupmtr_work( LAPACK_ROW_MAJOR, side_i, uplo_i, trans_i,
00211 m_i, n_i, ap_r, tau_i, c_r, ldc_r, work_i );
00212
00213 LAPACKE_zge_trans( LAPACK_ROW_MAJOR, m, n, c_r, n+2, c_i, ldc );
00214
00215 failed = compare_zupmtr( c, c_i, info, info_i, ldc, n );
00216 if( failed == 0 ) {
00217 printf( "PASSED: row-major middle-level interface to zupmtr\n" );
00218 } else {
00219 printf( "FAILED: row-major middle-level interface to zupmtr\n" );
00220 }
00221
00222
00223
00224 for( i = 0; i < (m*(m+1)/2); i++ ) {
00225 ap_i[i] = ap[i];
00226 }
00227 for( i = 0; i < (m-1); i++ ) {
00228 tau_i[i] = tau[i];
00229 }
00230 for( i = 0; i < ldc*n; i++ ) {
00231 c_i[i] = c_save[i];
00232 }
00233 for( i = 0; i < lwork; i++ ) {
00234 work_i[i] = work[i];
00235 }
00236
00237
00238 LAPACKE_zpp_trans( LAPACK_COL_MAJOR, uplo, m, ap_i, ap_r );
00239 LAPACKE_zge_trans( LAPACK_COL_MAJOR, m, n, c_i, ldc, c_r, n+2 );
00240 info_i = LAPACKE_zupmtr( LAPACK_ROW_MAJOR, side_i, uplo_i, trans_i, m_i,
00241 n_i, ap_r, tau_i, c_r, ldc_r );
00242
00243 LAPACKE_zge_trans( LAPACK_ROW_MAJOR, m, n, c_r, n+2, c_i, ldc );
00244
00245 failed = compare_zupmtr( c, c_i, info, info_i, ldc, n );
00246 if( failed == 0 ) {
00247 printf( "PASSED: row-major high-level interface to zupmtr\n" );
00248 } else {
00249 printf( "FAILED: row-major high-level interface to zupmtr\n" );
00250 }
00251
00252
00253 if( ap != NULL ) {
00254 LAPACKE_free( ap );
00255 }
00256 if( ap_i != NULL ) {
00257 LAPACKE_free( ap_i );
00258 }
00259 if( ap_r != NULL ) {
00260 LAPACKE_free( ap_r );
00261 }
00262 if( tau != NULL ) {
00263 LAPACKE_free( tau );
00264 }
00265 if( tau_i != NULL ) {
00266 LAPACKE_free( tau_i );
00267 }
00268 if( c != NULL ) {
00269 LAPACKE_free( c );
00270 }
00271 if( c_i != NULL ) {
00272 LAPACKE_free( c_i );
00273 }
00274 if( c_r != NULL ) {
00275 LAPACKE_free( c_r );
00276 }
00277 if( c_save != NULL ) {
00278 LAPACKE_free( c_save );
00279 }
00280 if( work != NULL ) {
00281 LAPACKE_free( work );
00282 }
00283 if( work_i != NULL ) {
00284 LAPACKE_free( work_i );
00285 }
00286
00287 return 0;
00288 }
00289
00290
00291 static void init_scalars_zupmtr( char *side, char *uplo, char *trans,
00292 lapack_int *m, lapack_int *n, lapack_int *ldc )
00293 {
00294 *side = 'L';
00295 *uplo = 'L';
00296 *trans = 'N';
00297 *m = 4;
00298 *n = 2;
00299 *ldc = 8;
00300
00301 return;
00302 }
00303
00304
00305 static void init_ap( lapack_int size, lapack_complex_double *ap ) {
00306 lapack_int i;
00307 for( i = 0; i < size; i++ ) {
00308 ap[i] = lapack_make_complex_double( 0.0, 0.0 );
00309 }
00310 ap[0] = lapack_make_complex_double( -2.27999999999999980e+000,
00311 0.00000000000000000e+000 );
00312 ap[1] = lapack_make_complex_double( -4.33845594653212970e+000,
00313 0.00000000000000000e+000 );
00314 ap[2] = lapack_make_complex_double( 3.27860676092192380e-001,
00315 -1.25122609226443690e-001 );
00316 ap[3] = lapack_make_complex_double( -1.41256563750694670e-001,
00317 -3.66636483973957040e-001 );
00318 ap[4] = lapack_make_complex_double( -1.28456981649329280e-001,
00319 0.00000000000000000e+000 );
00320 ap[5] = lapack_make_complex_double( -2.02259457862261720e+000,
00321 0.00000000000000000e+000 );
00322 ap[6] = lapack_make_complex_double( -3.08321908008089010e-001,
00323 1.76322636472677850e-001 );
00324 ap[7] = lapack_make_complex_double( -1.66593253752407190e-001,
00325 0.00000000000000000e+000 );
00326 ap[8] = lapack_make_complex_double( -1.80232297833873440e+000,
00327 0.00000000000000000e+000 );
00328 ap[9] = lapack_make_complex_double( -1.92494976459826360e+000,
00329 0.00000000000000000e+000 );
00330 }
00331 static void init_tau( lapack_int size, lapack_complex_double *tau ) {
00332 lapack_int i;
00333 for( i = 0; i < size; i++ ) {
00334 tau[i] = lapack_make_complex_double( 0.0, 0.0 );
00335 }
00336 tau[0] = lapack_make_complex_double( 1.41028421676675380e+000,
00337 4.67908404514893240e-001 );
00338 tau[1] = lapack_make_complex_double( 1.30242036943477490e+000,
00339 7.85332074252958030e-001 );
00340 tau[2] = lapack_make_complex_double( 1.09397371592308160e+000,
00341 -9.95574678623159850e-001 );
00342 }
00343 static void init_c( lapack_int size, lapack_complex_double *c ) {
00344 lapack_int i;
00345 for( i = 0; i < size; i++ ) {
00346 c[i] = lapack_make_complex_double( 0.0, 0.0 );
00347 }
00348 c[0] = lapack_make_complex_double( 7.29894574391705130e-001,
00349 0.00000000000000000e+000 );
00350 c[8] = lapack_make_complex_double( -2.59544973387760720e-001,
00351 0.00000000000000000e+000 );
00352 c[1] = lapack_make_complex_double( 6.25877780555793130e-001,
00353 0.00000000000000000e+000 );
00354 c[9] = lapack_make_complex_double( -4.32549625865536950e-002,
00355 0.00000000000000000e+000 );
00356 c[2] = lapack_make_complex_double( 2.51344947364408430e-001,
00357 0.00000000000000000e+000 );
00358 c[10] = lapack_make_complex_double( 4.95247410182067920e-001,
00359 0.00000000000000000e+000 );
00360 c[3] = lapack_make_complex_double( 1.11160386444491490e-001,
00361 0.00000000000000000e+000 );
00362 c[11] = lapack_make_complex_double( 8.27946506550234270e-001,
00363 0.00000000000000000e+000 );
00364 }
00365 static void init_work( lapack_int size, lapack_complex_double *work ) {
00366 lapack_int i;
00367 for( i = 0; i < size; i++ ) {
00368 work[i] = lapack_make_complex_double( 0.0, 0.0 );
00369 }
00370 }
00371
00372
00373
00374 static int compare_zupmtr( lapack_complex_double *c, lapack_complex_double *c_i,
00375 lapack_int info, lapack_int info_i, lapack_int ldc,
00376 lapack_int n )
00377 {
00378 lapack_int i;
00379 int failed = 0;
00380 for( i = 0; i < ldc*n; i++ ) {
00381 failed += compare_complex_doubles(c[i],c_i[i]);
00382 }
00383 failed += (info == info_i) ? 0 : 1;
00384 if( info != 0 || info_i != 0 ) {
00385 printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00386 }
00387
00388 return failed;
00389 }