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_cupmtr( 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_float *ap );
00058 static void init_tau( lapack_int size, lapack_complex_float *tau );
00059 static void init_c( lapack_int size, lapack_complex_float *c );
00060 static void init_work( lapack_int size, lapack_complex_float *work );
00061 static int compare_cupmtr( lapack_complex_float *c, lapack_complex_float *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_float *ap = NULL, *ap_i = NULL;
00083 lapack_complex_float *tau = NULL, *tau_i = NULL;
00084 lapack_complex_float *c = NULL, *c_i = NULL;
00085 lapack_complex_float *work = NULL, *work_i = NULL;
00086 lapack_complex_float *c_save = NULL;
00087 lapack_complex_float *ap_r = NULL;
00088 lapack_complex_float *c_r = NULL;
00089
00090
00091 init_scalars_cupmtr( &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_float *)
00103 LAPACKE_malloc( ((m*(m+1)/2)) * sizeof(lapack_complex_float) );
00104 tau = (lapack_complex_float *)
00105 LAPACKE_malloc( (m-1) * sizeof(lapack_complex_float) );
00106 c = (lapack_complex_float *)
00107 LAPACKE_malloc( ldc*n * sizeof(lapack_complex_float) );
00108 work = (lapack_complex_float *)
00109 LAPACKE_malloc( lwork * sizeof(lapack_complex_float) );
00110
00111
00112 ap_i = (lapack_complex_float *)
00113 LAPACKE_malloc( ((m*(m+1)/2)) * sizeof(lapack_complex_float) );
00114 tau_i = (lapack_complex_float *)
00115 LAPACKE_malloc( (m-1) * sizeof(lapack_complex_float) );
00116 c_i = (lapack_complex_float *)
00117 LAPACKE_malloc( ldc*n * sizeof(lapack_complex_float) );
00118 work_i = (lapack_complex_float *)
00119 LAPACKE_malloc( lwork * sizeof(lapack_complex_float) );
00120
00121
00122 c_save = (lapack_complex_float *)
00123 LAPACKE_malloc( ldc*n * sizeof(lapack_complex_float) );
00124
00125
00126 ap_r = (lapack_complex_float *)
00127 LAPACKE_malloc( m*(m+1)/2 * sizeof(lapack_complex_float) );
00128 c_r = (lapack_complex_float *)
00129 LAPACKE_malloc( m*(n+2) * sizeof(lapack_complex_float) );
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 cupmtr_( &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_cupmtr_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_cupmtr( c, c_i, info, info_i, ldc, n );
00163 if( failed == 0 ) {
00164 printf( "PASSED: column-major middle-level interface to cupmtr\n" );
00165 } else {
00166 printf( "FAILED: column-major middle-level interface to cupmtr\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_cupmtr( 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_cupmtr( c, c_i, info, info_i, ldc, n );
00187 if( failed == 0 ) {
00188 printf( "PASSED: column-major high-level interface to cupmtr\n" );
00189 } else {
00190 printf( "FAILED: column-major high-level interface to cupmtr\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_cpp_trans( LAPACK_COL_MAJOR, uplo, m, ap_i, ap_r );
00209 LAPACKE_cge_trans( LAPACK_COL_MAJOR, m, n, c_i, ldc, c_r, n+2 );
00210 info_i = LAPACKE_cupmtr_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_cge_trans( LAPACK_ROW_MAJOR, m, n, c_r, n+2, c_i, ldc );
00214
00215 failed = compare_cupmtr( c, c_i, info, info_i, ldc, n );
00216 if( failed == 0 ) {
00217 printf( "PASSED: row-major middle-level interface to cupmtr\n" );
00218 } else {
00219 printf( "FAILED: row-major middle-level interface to cupmtr\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_cpp_trans( LAPACK_COL_MAJOR, uplo, m, ap_i, ap_r );
00239 LAPACKE_cge_trans( LAPACK_COL_MAJOR, m, n, c_i, ldc, c_r, n+2 );
00240 info_i = LAPACKE_cupmtr( 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_cge_trans( LAPACK_ROW_MAJOR, m, n, c_r, n+2, c_i, ldc );
00244
00245 failed = compare_cupmtr( c, c_i, info, info_i, ldc, n );
00246 if( failed == 0 ) {
00247 printf( "PASSED: row-major high-level interface to cupmtr\n" );
00248 } else {
00249 printf( "FAILED: row-major high-level interface to cupmtr\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_cupmtr( 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_float *ap ) {
00306 lapack_int i;
00307 for( i = 0; i < size; i++ ) {
00308 ap[i] = lapack_make_complex_float( 0.0f, 0.0f );
00309 }
00310 ap[0] = lapack_make_complex_float( -2.279999971e+000, 0.000000000e+000 );
00311 ap[1] = lapack_make_complex_float( -4.338455677e+000, 0.000000000e+000 );
00312 ap[2] = lapack_make_complex_float( 3.278606534e-001, -1.251226068e-001 );
00313 ap[3] = lapack_make_complex_float( -1.412565559e-001, -3.666364849e-001 );
00314 ap[4] = lapack_make_complex_float( -1.284568310e-001, 0.000000000e+000 );
00315 ap[5] = lapack_make_complex_float( -2.022594690e+000, 0.000000000e+000 );
00316 ap[6] = lapack_make_complex_float( -3.083218634e-001, 1.763225943e-001 );
00317 ap[7] = lapack_make_complex_float( -1.665935516e-001, 0.000000000e+000 );
00318 ap[8] = lapack_make_complex_float( -1.802322745e+000, 0.000000000e+000 );
00319 ap[9] = lapack_make_complex_float( -1.924949646e+000, 0.000000000e+000 );
00320 }
00321 static void init_tau( lapack_int size, lapack_complex_float *tau ) {
00322 lapack_int i;
00323 for( i = 0; i < size; i++ ) {
00324 tau[i] = lapack_make_complex_float( 0.0f, 0.0f );
00325 }
00326 tau[0] = lapack_make_complex_float( 1.410284281e+000, 4.679084122e-001 );
00327 tau[1] = lapack_make_complex_float( 1.302420378e+000, 7.853320837e-001 );
00328 tau[2] = lapack_make_complex_float( 1.093973756e+000, -9.955747128e-001 );
00329 }
00330 static void init_c( lapack_int size, lapack_complex_float *c ) {
00331 lapack_int i;
00332 for( i = 0; i < size; i++ ) {
00333 c[i] = lapack_make_complex_float( 0.0f, 0.0f );
00334 }
00335 c[0] = lapack_make_complex_float( 7.298945785e-001, 0.000000000e+000 );
00336 c[8] = lapack_make_complex_float( -2.595449984e-001, 0.000000000e+000 );
00337 c[1] = lapack_make_complex_float( 6.258777976e-001, 0.000000000e+000 );
00338 c[9] = lapack_make_complex_float( -4.325495660e-002, 0.000000000e+000 );
00339 c[2] = lapack_make_complex_float( 2.513449788e-001, 0.000000000e+000 );
00340 c[10] = lapack_make_complex_float( 4.952474236e-001, 0.000000000e+000 );
00341 c[3] = lapack_make_complex_float( 1.111603901e-001, 0.000000000e+000 );
00342 c[11] = lapack_make_complex_float( 8.279464841e-001, 0.000000000e+000 );
00343 }
00344 static void init_work( lapack_int size, lapack_complex_float *work ) {
00345 lapack_int i;
00346 for( i = 0; i < size; i++ ) {
00347 work[i] = lapack_make_complex_float( 0.0f, 0.0f );
00348 }
00349 }
00350
00351
00352
00353 static int compare_cupmtr( lapack_complex_float *c, lapack_complex_float *c_i,
00354 lapack_int info, lapack_int info_i, lapack_int ldc,
00355 lapack_int n )
00356 {
00357 lapack_int i;
00358 int failed = 0;
00359 for( i = 0; i < ldc*n; i++ ) {
00360 failed += compare_complex_floats(c[i],c_i[i]);
00361 }
00362 failed += (info == info_i) ? 0 : 1;
00363 if( info != 0 || info_i != 0 ) {
00364 printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00365 }
00366
00367 return failed;
00368 }