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_cpptrs( char *uplo, lapack_int *n, lapack_int *nrhs,
00055 lapack_int *ldb );
00056 static void init_ap( lapack_int size, lapack_complex_float *ap );
00057 static void init_b( lapack_int size, lapack_complex_float *b );
00058 static int compare_cpptrs( lapack_complex_float *b, lapack_complex_float *b_i,
00059 lapack_int info, lapack_int info_i, lapack_int ldb,
00060 lapack_int nrhs );
00061
00062 int main(void)
00063 {
00064
00065 char uplo, uplo_i;
00066 lapack_int n, n_i;
00067 lapack_int nrhs, nrhs_i;
00068 lapack_int ldb, ldb_i;
00069 lapack_int ldb_r;
00070 lapack_int info, info_i;
00071 lapack_int i;
00072 int failed;
00073
00074
00075 lapack_complex_float *ap = NULL, *ap_i = NULL;
00076 lapack_complex_float *b = NULL, *b_i = NULL;
00077 lapack_complex_float *b_save = NULL;
00078 lapack_complex_float *ap_r = NULL;
00079 lapack_complex_float *b_r = NULL;
00080
00081
00082 init_scalars_cpptrs( &uplo, &n, &nrhs, &ldb );
00083 ldb_r = nrhs+2;
00084 uplo_i = uplo;
00085 n_i = n;
00086 nrhs_i = nrhs;
00087 ldb_i = ldb;
00088
00089
00090 ap = (lapack_complex_float *)
00091 LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(lapack_complex_float) );
00092 b = (lapack_complex_float *)
00093 LAPACKE_malloc( ldb*nrhs * sizeof(lapack_complex_float) );
00094
00095
00096 ap_i = (lapack_complex_float *)
00097 LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(lapack_complex_float) );
00098 b_i = (lapack_complex_float *)
00099 LAPACKE_malloc( ldb*nrhs * sizeof(lapack_complex_float) );
00100
00101
00102 b_save = (lapack_complex_float *)
00103 LAPACKE_malloc( ldb*nrhs * sizeof(lapack_complex_float) );
00104
00105
00106 ap_r = (lapack_complex_float *)
00107 LAPACKE_malloc( n*(n+1)/2 * sizeof(lapack_complex_float) );
00108 b_r = (lapack_complex_float *)
00109 LAPACKE_malloc( n*(nrhs+2) * sizeof(lapack_complex_float) );
00110
00111
00112 init_ap( (n*(n+1)/2), ap );
00113 init_b( ldb*nrhs, b );
00114
00115
00116 for( i = 0; i < ldb*nrhs; i++ ) {
00117 b_save[i] = b[i];
00118 }
00119
00120
00121 cpptrs_( &uplo, &n, &nrhs, ap, b, &ldb, &info );
00122
00123
00124
00125 for( i = 0; i < (n*(n+1)/2); i++ ) {
00126 ap_i[i] = ap[i];
00127 }
00128 for( i = 0; i < ldb*nrhs; i++ ) {
00129 b_i[i] = b_save[i];
00130 }
00131 info_i = LAPACKE_cpptrs_work( LAPACK_COL_MAJOR, uplo_i, n_i, nrhs_i, ap_i,
00132 b_i, ldb_i );
00133
00134 failed = compare_cpptrs( b, b_i, info, info_i, ldb, nrhs );
00135 if( failed == 0 ) {
00136 printf( "PASSED: column-major middle-level interface to cpptrs\n" );
00137 } else {
00138 printf( "FAILED: column-major middle-level interface to cpptrs\n" );
00139 }
00140
00141
00142
00143 for( i = 0; i < (n*(n+1)/2); i++ ) {
00144 ap_i[i] = ap[i];
00145 }
00146 for( i = 0; i < ldb*nrhs; i++ ) {
00147 b_i[i] = b_save[i];
00148 }
00149 info_i = LAPACKE_cpptrs( LAPACK_COL_MAJOR, uplo_i, n_i, nrhs_i, ap_i, b_i,
00150 ldb_i );
00151
00152 failed = compare_cpptrs( b, b_i, info, info_i, ldb, nrhs );
00153 if( failed == 0 ) {
00154 printf( "PASSED: column-major high-level interface to cpptrs\n" );
00155 } else {
00156 printf( "FAILED: column-major high-level interface to cpptrs\n" );
00157 }
00158
00159
00160
00161 for( i = 0; i < (n*(n+1)/2); i++ ) {
00162 ap_i[i] = ap[i];
00163 }
00164 for( i = 0; i < ldb*nrhs; i++ ) {
00165 b_i[i] = b_save[i];
00166 }
00167
00168 LAPACKE_cpp_trans( LAPACK_COL_MAJOR, uplo, n, ap_i, ap_r );
00169 LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, nrhs, b_i, ldb, b_r, nrhs+2 );
00170 info_i = LAPACKE_cpptrs_work( LAPACK_ROW_MAJOR, uplo_i, n_i, nrhs_i, ap_r,
00171 b_r, ldb_r );
00172
00173 LAPACKE_cge_trans( LAPACK_ROW_MAJOR, n, nrhs, b_r, nrhs+2, b_i, ldb );
00174
00175 failed = compare_cpptrs( b, b_i, info, info_i, ldb, nrhs );
00176 if( failed == 0 ) {
00177 printf( "PASSED: row-major middle-level interface to cpptrs\n" );
00178 } else {
00179 printf( "FAILED: row-major middle-level interface to cpptrs\n" );
00180 }
00181
00182
00183
00184 for( i = 0; i < (n*(n+1)/2); i++ ) {
00185 ap_i[i] = ap[i];
00186 }
00187 for( i = 0; i < ldb*nrhs; i++ ) {
00188 b_i[i] = b_save[i];
00189 }
00190
00191
00192 LAPACKE_cpp_trans( LAPACK_COL_MAJOR, uplo, n, ap_i, ap_r );
00193 LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, nrhs, b_i, ldb, b_r, nrhs+2 );
00194 info_i = LAPACKE_cpptrs( LAPACK_ROW_MAJOR, uplo_i, n_i, nrhs_i, ap_r, b_r,
00195 ldb_r );
00196
00197 LAPACKE_cge_trans( LAPACK_ROW_MAJOR, n, nrhs, b_r, nrhs+2, b_i, ldb );
00198
00199 failed = compare_cpptrs( b, b_i, info, info_i, ldb, nrhs );
00200 if( failed == 0 ) {
00201 printf( "PASSED: row-major high-level interface to cpptrs\n" );
00202 } else {
00203 printf( "FAILED: row-major high-level interface to cpptrs\n" );
00204 }
00205
00206
00207 if( ap != NULL ) {
00208 LAPACKE_free( ap );
00209 }
00210 if( ap_i != NULL ) {
00211 LAPACKE_free( ap_i );
00212 }
00213 if( ap_r != NULL ) {
00214 LAPACKE_free( ap_r );
00215 }
00216 if( b != NULL ) {
00217 LAPACKE_free( b );
00218 }
00219 if( b_i != NULL ) {
00220 LAPACKE_free( b_i );
00221 }
00222 if( b_r != NULL ) {
00223 LAPACKE_free( b_r );
00224 }
00225 if( b_save != NULL ) {
00226 LAPACKE_free( b_save );
00227 }
00228
00229 return 0;
00230 }
00231
00232
00233 static void init_scalars_cpptrs( char *uplo, lapack_int *n, lapack_int *nrhs,
00234 lapack_int *ldb )
00235 {
00236 *uplo = 'L';
00237 *n = 4;
00238 *nrhs = 2;
00239 *ldb = 8;
00240
00241 return;
00242 }
00243
00244
00245 static void init_ap( lapack_int size, lapack_complex_float *ap ) {
00246 lapack_int i;
00247 for( i = 0; i < size; i++ ) {
00248 ap[i] = lapack_make_complex_float( 0.0f, 0.0f );
00249 }
00250 ap[0] = lapack_make_complex_float( 1.797220111e+000, 0.000000000e+000 );
00251 ap[1] = lapack_make_complex_float( 8.401864767e-001, 1.068316579e+000 );
00252 ap[2] = lapack_make_complex_float( 1.057188272e+000, -4.673885107e-001 );
00253 ap[3] = lapack_make_complex_float( 2.336942554e-001, -1.391037226e+000 );
00254 ap[4] = lapack_make_complex_float( 1.316353440e+000, 0.000000000e+000 );
00255 ap[5] = lapack_make_complex_float( -4.701749682e-001, 3.130658865e-001 );
00256 ap[6] = lapack_make_complex_float( 8.335255831e-002, 3.676066920e-002 );
00257 ap[7] = lapack_make_complex_float( 1.560392976e+000, 0.000000000e+000 );
00258 ap[8] = lapack_make_complex_float( 9.359616637e-001, 9.899691939e-001 );
00259 ap[9] = lapack_make_complex_float( 6.603332758e-001, 0.000000000e+000 );
00260 }
00261 static void init_b( lapack_int size, lapack_complex_float *b ) {
00262 lapack_int i;
00263 for( i = 0; i < size; i++ ) {
00264 b[i] = lapack_make_complex_float( 0.0f, 0.0f );
00265 }
00266 b[0] = lapack_make_complex_float( 3.930000067e+000, -6.139999866e+000 );
00267 b[8] = lapack_make_complex_float( 1.480000019e+000, 6.579999924e+000 );
00268 b[1] = lapack_make_complex_float( 6.170000076e+000, 9.420000076e+000 );
00269 b[9] = lapack_make_complex_float( 4.650000095e+000, -4.750000000e+000 );
00270 b[2] = lapack_make_complex_float( -7.170000076e+000, -2.182999992e+001 );
00271 b[10] = lapack_make_complex_float( -4.909999847e+000, 2.289999962e+000 );
00272 b[3] = lapack_make_complex_float( 1.990000010e+000, -1.438000011e+001 );
00273 b[11] = lapack_make_complex_float( 7.639999866e+000, -1.078999996e+001 );
00274 }
00275
00276
00277
00278 static int compare_cpptrs( lapack_complex_float *b, lapack_complex_float *b_i,
00279 lapack_int info, lapack_int info_i, lapack_int ldb,
00280 lapack_int nrhs )
00281 {
00282 lapack_int i;
00283 int failed = 0;
00284 for( i = 0; i < ldb*nrhs; i++ ) {
00285 failed += compare_complex_floats(b[i],b_i[i]);
00286 }
00287 failed += (info == info_i) ? 0 : 1;
00288 if( info != 0 || info_i != 0 ) {
00289 printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00290 }
00291
00292 return failed;
00293 }