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_dpptrs( char *uplo, lapack_int *n, lapack_int *nrhs,
00055 lapack_int *ldb );
00056 static void init_ap( lapack_int size, double *ap );
00057 static void init_b( lapack_int size, double *b );
00058 static int compare_dpptrs( double *b, double *b_i, lapack_int info,
00059 lapack_int info_i, lapack_int ldb, lapack_int nrhs );
00060
00061 int main(void)
00062 {
00063
00064 char uplo, uplo_i;
00065 lapack_int n, n_i;
00066 lapack_int nrhs, nrhs_i;
00067 lapack_int ldb, ldb_i;
00068 lapack_int ldb_r;
00069 lapack_int info, info_i;
00070 lapack_int i;
00071 int failed;
00072
00073
00074 double *ap = NULL, *ap_i = NULL;
00075 double *b = NULL, *b_i = NULL;
00076 double *b_save = NULL;
00077 double *ap_r = NULL;
00078 double *b_r = NULL;
00079
00080
00081 init_scalars_dpptrs( &uplo, &n, &nrhs, &ldb );
00082 ldb_r = nrhs+2;
00083 uplo_i = uplo;
00084 n_i = n;
00085 nrhs_i = nrhs;
00086 ldb_i = ldb;
00087
00088
00089 ap = (double *)LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(double) );
00090 b = (double *)LAPACKE_malloc( ldb*nrhs * sizeof(double) );
00091
00092
00093 ap_i = (double *)LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(double) );
00094 b_i = (double *)LAPACKE_malloc( ldb*nrhs * sizeof(double) );
00095
00096
00097 b_save = (double *)LAPACKE_malloc( ldb*nrhs * sizeof(double) );
00098
00099
00100 ap_r = (double *)LAPACKE_malloc( n*(n+1)/2 * sizeof(double) );
00101 b_r = (double *)LAPACKE_malloc( n*(nrhs+2) * sizeof(double) );
00102
00103
00104 init_ap( (n*(n+1)/2), ap );
00105 init_b( ldb*nrhs, b );
00106
00107
00108 for( i = 0; i < ldb*nrhs; i++ ) {
00109 b_save[i] = b[i];
00110 }
00111
00112
00113 dpptrs_( &uplo, &n, &nrhs, ap, b, &ldb, &info );
00114
00115
00116
00117 for( i = 0; i < (n*(n+1)/2); i++ ) {
00118 ap_i[i] = ap[i];
00119 }
00120 for( i = 0; i < ldb*nrhs; i++ ) {
00121 b_i[i] = b_save[i];
00122 }
00123 info_i = LAPACKE_dpptrs_work( LAPACK_COL_MAJOR, uplo_i, n_i, nrhs_i, ap_i,
00124 b_i, ldb_i );
00125
00126 failed = compare_dpptrs( b, b_i, info, info_i, ldb, nrhs );
00127 if( failed == 0 ) {
00128 printf( "PASSED: column-major middle-level interface to dpptrs\n" );
00129 } else {
00130 printf( "FAILED: column-major middle-level interface to dpptrs\n" );
00131 }
00132
00133
00134
00135 for( i = 0; i < (n*(n+1)/2); i++ ) {
00136 ap_i[i] = ap[i];
00137 }
00138 for( i = 0; i < ldb*nrhs; i++ ) {
00139 b_i[i] = b_save[i];
00140 }
00141 info_i = LAPACKE_dpptrs( LAPACK_COL_MAJOR, uplo_i, n_i, nrhs_i, ap_i, b_i,
00142 ldb_i );
00143
00144 failed = compare_dpptrs( b, b_i, info, info_i, ldb, nrhs );
00145 if( failed == 0 ) {
00146 printf( "PASSED: column-major high-level interface to dpptrs\n" );
00147 } else {
00148 printf( "FAILED: column-major high-level interface to dpptrs\n" );
00149 }
00150
00151
00152
00153 for( i = 0; i < (n*(n+1)/2); i++ ) {
00154 ap_i[i] = ap[i];
00155 }
00156 for( i = 0; i < ldb*nrhs; i++ ) {
00157 b_i[i] = b_save[i];
00158 }
00159
00160 LAPACKE_dpp_trans( LAPACK_COL_MAJOR, uplo, n, ap_i, ap_r );
00161 LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, nrhs, b_i, ldb, b_r, nrhs+2 );
00162 info_i = LAPACKE_dpptrs_work( LAPACK_ROW_MAJOR, uplo_i, n_i, nrhs_i, ap_r,
00163 b_r, ldb_r );
00164
00165 LAPACKE_dge_trans( LAPACK_ROW_MAJOR, n, nrhs, b_r, nrhs+2, b_i, ldb );
00166
00167 failed = compare_dpptrs( b, b_i, info, info_i, ldb, nrhs );
00168 if( failed == 0 ) {
00169 printf( "PASSED: row-major middle-level interface to dpptrs\n" );
00170 } else {
00171 printf( "FAILED: row-major middle-level interface to dpptrs\n" );
00172 }
00173
00174
00175
00176 for( i = 0; i < (n*(n+1)/2); i++ ) {
00177 ap_i[i] = ap[i];
00178 }
00179 for( i = 0; i < ldb*nrhs; i++ ) {
00180 b_i[i] = b_save[i];
00181 }
00182
00183
00184 LAPACKE_dpp_trans( LAPACK_COL_MAJOR, uplo, n, ap_i, ap_r );
00185 LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, nrhs, b_i, ldb, b_r, nrhs+2 );
00186 info_i = LAPACKE_dpptrs( LAPACK_ROW_MAJOR, uplo_i, n_i, nrhs_i, ap_r, b_r,
00187 ldb_r );
00188
00189 LAPACKE_dge_trans( LAPACK_ROW_MAJOR, n, nrhs, b_r, nrhs+2, b_i, ldb );
00190
00191 failed = compare_dpptrs( b, b_i, info, info_i, ldb, nrhs );
00192 if( failed == 0 ) {
00193 printf( "PASSED: row-major high-level interface to dpptrs\n" );
00194 } else {
00195 printf( "FAILED: row-major high-level interface to dpptrs\n" );
00196 }
00197
00198
00199 if( ap != NULL ) {
00200 LAPACKE_free( ap );
00201 }
00202 if( ap_i != NULL ) {
00203 LAPACKE_free( ap_i );
00204 }
00205 if( ap_r != NULL ) {
00206 LAPACKE_free( ap_r );
00207 }
00208 if( b != NULL ) {
00209 LAPACKE_free( b );
00210 }
00211 if( b_i != NULL ) {
00212 LAPACKE_free( b_i );
00213 }
00214 if( b_r != NULL ) {
00215 LAPACKE_free( b_r );
00216 }
00217 if( b_save != NULL ) {
00218 LAPACKE_free( b_save );
00219 }
00220
00221 return 0;
00222 }
00223
00224
00225 static void init_scalars_dpptrs( char *uplo, lapack_int *n, lapack_int *nrhs,
00226 lapack_int *ldb )
00227 {
00228 *uplo = 'L';
00229 *n = 4;
00230 *nrhs = 2;
00231 *ldb = 8;
00232
00233 return;
00234 }
00235
00236
00237 static void init_ap( lapack_int size, double *ap ) {
00238 lapack_int i;
00239 for( i = 0; i < size; i++ ) {
00240 ap[i] = 0;
00241 }
00242 ap[0] = 2.03960780543711410e+000;
00243 ap[1] = -1.52970585407783540e+000;
00244 ap[2] = 2.74562589193457660e-001;
00245 ap[3] = -4.90290337845460110e-002;
00246 ap[4] = 1.64012194668567270e+000;
00247 ap[5] = -2.49981411948373810e-001;
00248 ap[6] = 6.73730390738910060e-001;
00249 ap[7] = 7.88748805574805310e-001;
00250 ap[8] = 6.61657563374256520e-001;
00251 ap[9] = 5.34689426929868320e-001;
00252 }
00253 static void init_b( lapack_int size, double *b ) {
00254 lapack_int i;
00255 for( i = 0; i < size; i++ ) {
00256 b[i] = 0;
00257 }
00258 b[0] = 8.69999999999999930e+000;
00259 b[8] = 8.30000000000000070e+000;
00260 b[1] = -1.33500000000000000e+001;
00261 b[9] = 2.12999999999999990e+000;
00262 b[2] = 1.88999999999999990e+000;
00263 b[10] = 1.61000000000000010e+000;
00264 b[3] = -4.13999999999999970e+000;
00265 b[11] = 5.00000000000000000e+000;
00266 }
00267
00268
00269
00270 static int compare_dpptrs( double *b, double *b_i, lapack_int info,
00271 lapack_int info_i, lapack_int ldb, lapack_int nrhs )
00272 {
00273 lapack_int i;
00274 int failed = 0;
00275 for( i = 0; i < ldb*nrhs; i++ ) {
00276 failed += compare_doubles(b[i],b_i[i]);
00277 }
00278 failed += (info == info_i) ? 0 : 1;
00279 if( info != 0 || info_i != 0 ) {
00280 printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00281 }
00282
00283 return failed;
00284 }