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_zhpgst( lapack_int *itype, char *uplo, lapack_int *n );
00055 static void init_ap( lapack_int size, lapack_complex_double *ap );
00056 static void init_bp( lapack_int size, lapack_complex_double *bp );
00057 static int compare_zhpgst( lapack_complex_double *ap,
00058 lapack_complex_double *ap_i, lapack_int info,
00059 lapack_int info_i, lapack_int n );
00060
00061 int main(void)
00062 {
00063
00064 lapack_int itype, itype_i;
00065 char uplo, uplo_i;
00066 lapack_int n, n_i;
00067 lapack_int info, info_i;
00068 lapack_int i;
00069 int failed;
00070
00071
00072 lapack_complex_double *ap = NULL, *ap_i = NULL;
00073 lapack_complex_double *bp = NULL, *bp_i = NULL;
00074 lapack_complex_double *ap_save = NULL;
00075 lapack_complex_double *ap_r = NULL;
00076 lapack_complex_double *bp_r = NULL;
00077
00078
00079 init_scalars_zhpgst( &itype, &uplo, &n );
00080 itype_i = itype;
00081 uplo_i = uplo;
00082 n_i = n;
00083
00084
00085 ap = (lapack_complex_double *)
00086 LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(lapack_complex_double) );
00087 bp = (lapack_complex_double *)
00088 LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(lapack_complex_double) );
00089
00090
00091 ap_i = (lapack_complex_double *)
00092 LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(lapack_complex_double) );
00093 bp_i = (lapack_complex_double *)
00094 LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(lapack_complex_double) );
00095
00096
00097 ap_save = (lapack_complex_double *)
00098 LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(lapack_complex_double) );
00099
00100
00101 ap_r = (lapack_complex_double *)
00102 LAPACKE_malloc( n*(n+1)/2 * sizeof(lapack_complex_double) );
00103 bp_r = (lapack_complex_double *)
00104 LAPACKE_malloc( n*(n+1)/2 * sizeof(lapack_complex_double) );
00105
00106
00107 init_ap( (n*(n+1)/2), ap );
00108 init_bp( (n*(n+1)/2), bp );
00109
00110
00111 for( i = 0; i < (n*(n+1)/2); i++ ) {
00112 ap_save[i] = ap[i];
00113 }
00114
00115
00116 zhpgst_( &itype, &uplo, &n, ap, bp, &info );
00117
00118
00119
00120 for( i = 0; i < (n*(n+1)/2); i++ ) {
00121 ap_i[i] = ap_save[i];
00122 }
00123 for( i = 0; i < (n*(n+1)/2); i++ ) {
00124 bp_i[i] = bp[i];
00125 }
00126 info_i = LAPACKE_zhpgst_work( LAPACK_COL_MAJOR, itype_i, uplo_i, n_i, ap_i,
00127 bp_i );
00128
00129 failed = compare_zhpgst( ap, ap_i, info, info_i, n );
00130 if( failed == 0 ) {
00131 printf( "PASSED: column-major middle-level interface to zhpgst\n" );
00132 } else {
00133 printf( "FAILED: column-major middle-level interface to zhpgst\n" );
00134 }
00135
00136
00137
00138 for( i = 0; i < (n*(n+1)/2); i++ ) {
00139 ap_i[i] = ap_save[i];
00140 }
00141 for( i = 0; i < (n*(n+1)/2); i++ ) {
00142 bp_i[i] = bp[i];
00143 }
00144 info_i = LAPACKE_zhpgst( LAPACK_COL_MAJOR, itype_i, uplo_i, n_i, ap_i,
00145 bp_i );
00146
00147 failed = compare_zhpgst( ap, ap_i, info, info_i, n );
00148 if( failed == 0 ) {
00149 printf( "PASSED: column-major high-level interface to zhpgst\n" );
00150 } else {
00151 printf( "FAILED: column-major high-level interface to zhpgst\n" );
00152 }
00153
00154
00155
00156 for( i = 0; i < (n*(n+1)/2); i++ ) {
00157 ap_i[i] = ap_save[i];
00158 }
00159 for( i = 0; i < (n*(n+1)/2); i++ ) {
00160 bp_i[i] = bp[i];
00161 }
00162
00163 LAPACKE_zpp_trans( LAPACK_COL_MAJOR, uplo, n, ap_i, ap_r );
00164 LAPACKE_zpp_trans( LAPACK_COL_MAJOR, uplo, n, bp_i, bp_r );
00165 info_i = LAPACKE_zhpgst_work( LAPACK_ROW_MAJOR, itype_i, uplo_i, n_i, ap_r,
00166 bp_r );
00167
00168 LAPACKE_zpp_trans( LAPACK_ROW_MAJOR, uplo, n, ap_r, ap_i );
00169
00170 failed = compare_zhpgst( ap, ap_i, info, info_i, n );
00171 if( failed == 0 ) {
00172 printf( "PASSED: row-major middle-level interface to zhpgst\n" );
00173 } else {
00174 printf( "FAILED: row-major middle-level interface to zhpgst\n" );
00175 }
00176
00177
00178
00179 for( i = 0; i < (n*(n+1)/2); i++ ) {
00180 ap_i[i] = ap_save[i];
00181 }
00182 for( i = 0; i < (n*(n+1)/2); i++ ) {
00183 bp_i[i] = bp[i];
00184 }
00185
00186
00187 LAPACKE_zpp_trans( LAPACK_COL_MAJOR, uplo, n, ap_i, ap_r );
00188 LAPACKE_zpp_trans( LAPACK_COL_MAJOR, uplo, n, bp_i, bp_r );
00189 info_i = LAPACKE_zhpgst( LAPACK_ROW_MAJOR, itype_i, uplo_i, n_i, ap_r,
00190 bp_r );
00191
00192 LAPACKE_zpp_trans( LAPACK_ROW_MAJOR, uplo, n, ap_r, ap_i );
00193
00194 failed = compare_zhpgst( ap, ap_i, info, info_i, n );
00195 if( failed == 0 ) {
00196 printf( "PASSED: row-major high-level interface to zhpgst\n" );
00197 } else {
00198 printf( "FAILED: row-major high-level interface to zhpgst\n" );
00199 }
00200
00201
00202 if( ap != NULL ) {
00203 LAPACKE_free( ap );
00204 }
00205 if( ap_i != NULL ) {
00206 LAPACKE_free( ap_i );
00207 }
00208 if( ap_r != NULL ) {
00209 LAPACKE_free( ap_r );
00210 }
00211 if( ap_save != NULL ) {
00212 LAPACKE_free( ap_save );
00213 }
00214 if( bp != NULL ) {
00215 LAPACKE_free( bp );
00216 }
00217 if( bp_i != NULL ) {
00218 LAPACKE_free( bp_i );
00219 }
00220 if( bp_r != NULL ) {
00221 LAPACKE_free( bp_r );
00222 }
00223
00224 return 0;
00225 }
00226
00227
00228 static void init_scalars_zhpgst( lapack_int *itype, char *uplo, lapack_int *n )
00229 {
00230 *itype = 1;
00231 *uplo = 'L';
00232 *n = 4;
00233
00234 return;
00235 }
00236
00237
00238 static void init_ap( lapack_int size, lapack_complex_double *ap ) {
00239 lapack_int i;
00240 for( i = 0; i < size; i++ ) {
00241 ap[i] = lapack_make_complex_double( 0.0, 0.0 );
00242 }
00243 ap[0] = lapack_make_complex_double( -7.36000000000000030e+000,
00244 0.00000000000000000e+000 );
00245 ap[1] = lapack_make_complex_double( 7.70000000000000020e-001,
00246 4.29999999999999990e-001 );
00247 ap[2] = lapack_make_complex_double( -6.40000000000000010e-001,
00248 9.20000000000000040e-001 );
00249 ap[3] = lapack_make_complex_double( 3.00999999999999980e+000,
00250 6.96999999999999980e+000 );
00251 ap[4] = lapack_make_complex_double( 3.49000000000000020e+000,
00252 0.00000000000000000e+000 );
00253 ap[5] = lapack_make_complex_double( 2.18999999999999990e+000,
00254 -4.45000000000000020e+000 );
00255 ap[6] = lapack_make_complex_double( 1.89999999999999990e+000,
00256 -3.73000000000000000e+000 );
00257 ap[7] = lapack_make_complex_double( 1.20000000000000000e-001,
00258 0.00000000000000000e+000 );
00259 ap[8] = lapack_make_complex_double( 2.87999999999999990e+000,
00260 3.16999999999999990e+000 );
00261 ap[9] = lapack_make_complex_double( -2.54000000000000000e+000,
00262 0.00000000000000000e+000 );
00263 }
00264 static void init_bp( lapack_int size, lapack_complex_double *bp ) {
00265 lapack_int i;
00266 for( i = 0; i < size; i++ ) {
00267 bp[i] = lapack_make_complex_double( 0.0, 0.0 );
00268 }
00269 bp[0] = lapack_make_complex_double( 1.79722007556114290e+000,
00270 0.00000000000000000e+000 );
00271 bp[1] = lapack_make_complex_double( 8.40186474952732460e-001,
00272 1.06831657742334190e+000 );
00273 bp[2] = lapack_make_complex_double( 1.05718827974184860e+000,
00274 -4.67388502622712030e-001 );
00275 bp[3] = lapack_make_complex_double( 2.33694251311356020e-001,
00276 -1.39103721018664310e+000 );
00277 bp[4] = lapack_make_complex_double( 1.31635343950968520e+000,
00278 0.00000000000000000e+000 );
00279 bp[5] = lapack_make_complex_double( -4.70174947010632950e-001,
00280 3.13065815599946400e-001 );
00281 bp[6] = lapack_make_complex_double( 8.33525092394419580e-002,
00282 3.67607144303747430e-002 );
00283 bp[7] = lapack_make_complex_double( 1.56039297713712430e+000,
00284 0.00000000000000000e+000 );
00285 bp[8] = lapack_make_complex_double( 9.35961733792340160e-001,
00286 9.89969219281573890e-001 );
00287 bp[9] = lapack_make_complex_double( 6.60333297365588770e-001,
00288 0.00000000000000000e+000 );
00289 }
00290
00291
00292
00293 static int compare_zhpgst( lapack_complex_double *ap,
00294 lapack_complex_double *ap_i, lapack_int info,
00295 lapack_int info_i, lapack_int n )
00296 {
00297 lapack_int i;
00298 int failed = 0;
00299 for( i = 0; i < (n*(n+1)/2); i++ ) {
00300 failed += compare_complex_doubles(ap[i],ap_i[i]);
00301 }
00302 failed += (info == info_i) ? 0 : 1;
00303 if( info != 0 || info_i != 0 ) {
00304 printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00305 }
00306
00307 return failed;
00308 }