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