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_ztptrs( char *uplo, char *trans, char *diag,
00055 lapack_int *n, lapack_int *nrhs,
00056 lapack_int *ldb );
00057 static void init_ap( lapack_int size, lapack_complex_double *ap );
00058 static void init_b( lapack_int size, lapack_complex_double *b );
00059 static int compare_ztptrs( lapack_complex_double *b, lapack_complex_double *b_i,
00060 lapack_int info, lapack_int info_i, lapack_int ldb,
00061 lapack_int nrhs );
00062
00063 int main(void)
00064 {
00065
00066 char uplo, uplo_i;
00067 char trans, trans_i;
00068 char diag, diag_i;
00069 lapack_int n, n_i;
00070 lapack_int nrhs, nrhs_i;
00071 lapack_int ldb, ldb_i;
00072 lapack_int ldb_r;
00073 lapack_int info, info_i;
00074 lapack_int i;
00075 int failed;
00076
00077
00078 lapack_complex_double *ap = NULL, *ap_i = NULL;
00079 lapack_complex_double *b = NULL, *b_i = NULL;
00080 lapack_complex_double *b_save = NULL;
00081 lapack_complex_double *ap_r = NULL;
00082 lapack_complex_double *b_r = NULL;
00083
00084
00085 init_scalars_ztptrs( &uplo, &trans, &diag, &n, &nrhs, &ldb );
00086 ldb_r = nrhs+2;
00087 uplo_i = uplo;
00088 trans_i = trans;
00089 diag_i = diag;
00090 n_i = n;
00091 nrhs_i = nrhs;
00092 ldb_i = ldb;
00093
00094
00095 ap = (lapack_complex_double *)
00096 LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(lapack_complex_double) );
00097 b = (lapack_complex_double *)
00098 LAPACKE_malloc( ldb*nrhs * sizeof(lapack_complex_double) );
00099
00100
00101 ap_i = (lapack_complex_double *)
00102 LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(lapack_complex_double) );
00103 b_i = (lapack_complex_double *)
00104 LAPACKE_malloc( ldb*nrhs * sizeof(lapack_complex_double) );
00105
00106
00107 b_save = (lapack_complex_double *)
00108 LAPACKE_malloc( ldb*nrhs * sizeof(lapack_complex_double) );
00109
00110
00111 ap_r = (lapack_complex_double *)
00112 LAPACKE_malloc( n*(n+1)/2 * sizeof(lapack_complex_double) );
00113 b_r = (lapack_complex_double *)
00114 LAPACKE_malloc( n*(nrhs+2) * sizeof(lapack_complex_double) );
00115
00116
00117 init_ap( (n*(n+1)/2), ap );
00118 init_b( ldb*nrhs, b );
00119
00120
00121 for( i = 0; i < ldb*nrhs; i++ ) {
00122 b_save[i] = b[i];
00123 }
00124
00125
00126 ztptrs_( &uplo, &trans, &diag, &n, &nrhs, ap, b, &ldb, &info );
00127
00128
00129
00130 for( i = 0; i < (n*(n+1)/2); i++ ) {
00131 ap_i[i] = ap[i];
00132 }
00133 for( i = 0; i < ldb*nrhs; i++ ) {
00134 b_i[i] = b_save[i];
00135 }
00136 info_i = LAPACKE_ztptrs_work( LAPACK_COL_MAJOR, uplo_i, trans_i, diag_i,
00137 n_i, nrhs_i, ap_i, b_i, ldb_i );
00138
00139 failed = compare_ztptrs( b, b_i, info, info_i, ldb, nrhs );
00140 if( failed == 0 ) {
00141 printf( "PASSED: column-major middle-level interface to ztptrs\n" );
00142 } else {
00143 printf( "FAILED: column-major middle-level interface to ztptrs\n" );
00144 }
00145
00146
00147
00148 for( i = 0; i < (n*(n+1)/2); i++ ) {
00149 ap_i[i] = ap[i];
00150 }
00151 for( i = 0; i < ldb*nrhs; i++ ) {
00152 b_i[i] = b_save[i];
00153 }
00154 info_i = LAPACKE_ztptrs( LAPACK_COL_MAJOR, uplo_i, trans_i, diag_i, n_i,
00155 nrhs_i, ap_i, b_i, ldb_i );
00156
00157 failed = compare_ztptrs( b, b_i, info, info_i, ldb, nrhs );
00158 if( failed == 0 ) {
00159 printf( "PASSED: column-major high-level interface to ztptrs\n" );
00160 } else {
00161 printf( "FAILED: column-major high-level interface to ztptrs\n" );
00162 }
00163
00164
00165
00166 for( i = 0; i < (n*(n+1)/2); i++ ) {
00167 ap_i[i] = ap[i];
00168 }
00169 for( i = 0; i < ldb*nrhs; i++ ) {
00170 b_i[i] = b_save[i];
00171 }
00172
00173 LAPACKE_zpp_trans( LAPACK_COL_MAJOR, uplo, n, ap_i, ap_r );
00174 LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, nrhs, b_i, ldb, b_r, nrhs+2 );
00175 info_i = LAPACKE_ztptrs_work( LAPACK_ROW_MAJOR, uplo_i, trans_i, diag_i,
00176 n_i, nrhs_i, ap_r, b_r, ldb_r );
00177
00178 LAPACKE_zge_trans( LAPACK_ROW_MAJOR, n, nrhs, b_r, nrhs+2, b_i, ldb );
00179
00180 failed = compare_ztptrs( b, b_i, info, info_i, ldb, nrhs );
00181 if( failed == 0 ) {
00182 printf( "PASSED: row-major middle-level interface to ztptrs\n" );
00183 } else {
00184 printf( "FAILED: row-major middle-level interface to ztptrs\n" );
00185 }
00186
00187
00188
00189 for( i = 0; i < (n*(n+1)/2); i++ ) {
00190 ap_i[i] = ap[i];
00191 }
00192 for( i = 0; i < ldb*nrhs; i++ ) {
00193 b_i[i] = b_save[i];
00194 }
00195
00196
00197 LAPACKE_zpp_trans( LAPACK_COL_MAJOR, uplo, n, ap_i, ap_r );
00198 LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, nrhs, b_i, ldb, b_r, nrhs+2 );
00199 info_i = LAPACKE_ztptrs( LAPACK_ROW_MAJOR, uplo_i, trans_i, diag_i, n_i,
00200 nrhs_i, ap_r, b_r, ldb_r );
00201
00202 LAPACKE_zge_trans( LAPACK_ROW_MAJOR, n, nrhs, b_r, nrhs+2, b_i, ldb );
00203
00204 failed = compare_ztptrs( b, b_i, info, info_i, ldb, nrhs );
00205 if( failed == 0 ) {
00206 printf( "PASSED: row-major high-level interface to ztptrs\n" );
00207 } else {
00208 printf( "FAILED: row-major high-level interface to ztptrs\n" );
00209 }
00210
00211
00212 if( ap != NULL ) {
00213 LAPACKE_free( ap );
00214 }
00215 if( ap_i != NULL ) {
00216 LAPACKE_free( ap_i );
00217 }
00218 if( ap_r != NULL ) {
00219 LAPACKE_free( ap_r );
00220 }
00221 if( b != NULL ) {
00222 LAPACKE_free( b );
00223 }
00224 if( b_i != NULL ) {
00225 LAPACKE_free( b_i );
00226 }
00227 if( b_r != NULL ) {
00228 LAPACKE_free( b_r );
00229 }
00230 if( b_save != NULL ) {
00231 LAPACKE_free( b_save );
00232 }
00233
00234 return 0;
00235 }
00236
00237
00238 static void init_scalars_ztptrs( char *uplo, char *trans, char *diag,
00239 lapack_int *n, lapack_int *nrhs,
00240 lapack_int *ldb )
00241 {
00242 *uplo = 'L';
00243 *trans = 'N';
00244 *diag = 'N';
00245 *n = 4;
00246 *nrhs = 2;
00247 *ldb = 8;
00248
00249 return;
00250 }
00251
00252
00253 static void init_ap( lapack_int size, lapack_complex_double *ap ) {
00254 lapack_int i;
00255 for( i = 0; i < size; i++ ) {
00256 ap[i] = lapack_make_complex_double( 0.0, 0.0 );
00257 }
00258 ap[0] = lapack_make_complex_double( 4.78000000000000020e+000,
00259 4.55999999999999960e+000 );
00260 ap[1] = lapack_make_complex_double( 2.00000000000000000e+000,
00261 -2.99999999999999990e-001 );
00262 ap[2] = lapack_make_complex_double( 2.89000000000000010e+000,
00263 -1.34000000000000010e+000 );
00264 ap[3] = lapack_make_complex_double( -1.88999999999999990e+000,
00265 1.14999999999999990e+000 );
00266 ap[4] = lapack_make_complex_double( -4.11000000000000030e+000,
00267 1.25000000000000000e+000 );
00268 ap[5] = lapack_make_complex_double( 2.35999999999999990e+000,
00269 -4.25000000000000000e+000 );
00270 ap[6] = lapack_make_complex_double( 4.00000000000000010e-002,
00271 -3.68999999999999990e+000 );
00272 ap[7] = lapack_make_complex_double( 4.15000000000000040e+000,
00273 8.00000000000000040e-001 );
00274 ap[8] = lapack_make_complex_double( -2.00000000000000000e-002,
00275 4.60000000000000020e-001 );
00276 ap[9] = lapack_make_complex_double( 3.30000000000000020e-001,
00277 -2.60000000000000010e-001 );
00278 }
00279 static void init_b( lapack_int size, lapack_complex_double *b ) {
00280 lapack_int i;
00281 for( i = 0; i < size; i++ ) {
00282 b[i] = lapack_make_complex_double( 0.0, 0.0 );
00283 }
00284 b[0] = lapack_make_complex_double( -1.47799999999999990e+001,
00285 -3.23599999999999990e+001 );
00286 b[8] = lapack_make_complex_double( -1.80200000000000000e+001,
00287 2.84600000000000010e+001 );
00288 b[1] = lapack_make_complex_double( 2.98000000000000000e+000,
00289 -2.14000000000000010e+000 );
00290 b[9] = lapack_make_complex_double( 1.42200000000000010e+001,
00291 1.54200000000000000e+001 );
00292 b[2] = lapack_make_complex_double( -2.09600000000000010e+001,
00293 1.70599999999999990e+001 );
00294 b[10] = lapack_make_complex_double( 5.62000000000000010e+000,
00295 3.58900000000000010e+001 );
00296 b[3] = lapack_make_complex_double( 9.53999999999999910e+000,
00297 9.91000000000000010e+000 );
00298 b[11] = lapack_make_complex_double( -1.64600000000000010e+001,
00299 -1.73000000000000000e+000 );
00300 }
00301
00302
00303
00304 static int compare_ztptrs( lapack_complex_double *b, lapack_complex_double *b_i,
00305 lapack_int info, lapack_int info_i, lapack_int ldb,
00306 lapack_int nrhs )
00307 {
00308 lapack_int i;
00309 int failed = 0;
00310 for( i = 0; i < ldb*nrhs; i++ ) {
00311 failed += compare_complex_doubles(b[i],b_i[i]);
00312 }
00313 failed += (info == info_i) ? 0 : 1;
00314 if( info != 0 || info_i != 0 ) {
00315 printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00316 }
00317
00318 return failed;
00319 }