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_sspgst( lapack_int *itype, char *uplo, lapack_int *n );
00055 static void init_ap( lapack_int size, float *ap );
00056 static void init_bp( lapack_int size, float *bp );
00057 static int compare_sspgst( float *ap, float *ap_i, lapack_int info,
00058 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 float *ap = NULL, *ap_i = NULL;
00072 float *bp = NULL, *bp_i = NULL;
00073 float *ap_save = NULL;
00074 float *ap_r = NULL;
00075 float *bp_r = NULL;
00076
00077
00078 init_scalars_sspgst( &itype, &uplo, &n );
00079 itype_i = itype;
00080 uplo_i = uplo;
00081 n_i = n;
00082
00083
00084 ap = (float *)LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(float) );
00085 bp = (float *)LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(float) );
00086
00087
00088 ap_i = (float *)LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(float) );
00089 bp_i = (float *)LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(float) );
00090
00091
00092 ap_save = (float *)LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(float) );
00093
00094
00095 ap_r = (float *)LAPACKE_malloc( n*(n+1)/2 * sizeof(float) );
00096 bp_r = (float *)LAPACKE_malloc( n*(n+1)/2 * sizeof(float) );
00097
00098
00099 init_ap( (n*(n+1)/2), ap );
00100 init_bp( (n*(n+1)/2), bp );
00101
00102
00103 for( i = 0; i < (n*(n+1)/2); i++ ) {
00104 ap_save[i] = ap[i];
00105 }
00106
00107
00108 sspgst_( &itype, &uplo, &n, ap, bp, &info );
00109
00110
00111
00112 for( i = 0; i < (n*(n+1)/2); i++ ) {
00113 ap_i[i] = ap_save[i];
00114 }
00115 for( i = 0; i < (n*(n+1)/2); i++ ) {
00116 bp_i[i] = bp[i];
00117 }
00118 info_i = LAPACKE_sspgst_work( LAPACK_COL_MAJOR, itype_i, uplo_i, n_i, ap_i,
00119 bp_i );
00120
00121 failed = compare_sspgst( ap, ap_i, info, info_i, n );
00122 if( failed == 0 ) {
00123 printf( "PASSED: column-major middle-level interface to sspgst\n" );
00124 } else {
00125 printf( "FAILED: column-major middle-level interface to sspgst\n" );
00126 }
00127
00128
00129
00130 for( i = 0; i < (n*(n+1)/2); i++ ) {
00131 ap_i[i] = ap_save[i];
00132 }
00133 for( i = 0; i < (n*(n+1)/2); i++ ) {
00134 bp_i[i] = bp[i];
00135 }
00136 info_i = LAPACKE_sspgst( LAPACK_COL_MAJOR, itype_i, uplo_i, n_i, ap_i,
00137 bp_i );
00138
00139 failed = compare_sspgst( ap, ap_i, info, info_i, n );
00140 if( failed == 0 ) {
00141 printf( "PASSED: column-major high-level interface to sspgst\n" );
00142 } else {
00143 printf( "FAILED: column-major high-level interface to sspgst\n" );
00144 }
00145
00146
00147
00148 for( i = 0; i < (n*(n+1)/2); i++ ) {
00149 ap_i[i] = ap_save[i];
00150 }
00151 for( i = 0; i < (n*(n+1)/2); i++ ) {
00152 bp_i[i] = bp[i];
00153 }
00154
00155 LAPACKE_spp_trans( LAPACK_COL_MAJOR, uplo, n, ap_i, ap_r );
00156 LAPACKE_spp_trans( LAPACK_COL_MAJOR, uplo, n, bp_i, bp_r );
00157 info_i = LAPACKE_sspgst_work( LAPACK_ROW_MAJOR, itype_i, uplo_i, n_i, ap_r,
00158 bp_r );
00159
00160 LAPACKE_spp_trans( LAPACK_ROW_MAJOR, uplo, n, ap_r, ap_i );
00161
00162 failed = compare_sspgst( ap, ap_i, info, info_i, n );
00163 if( failed == 0 ) {
00164 printf( "PASSED: row-major middle-level interface to sspgst\n" );
00165 } else {
00166 printf( "FAILED: row-major middle-level interface to sspgst\n" );
00167 }
00168
00169
00170
00171 for( i = 0; i < (n*(n+1)/2); i++ ) {
00172 ap_i[i] = ap_save[i];
00173 }
00174 for( i = 0; i < (n*(n+1)/2); i++ ) {
00175 bp_i[i] = bp[i];
00176 }
00177
00178
00179 LAPACKE_spp_trans( LAPACK_COL_MAJOR, uplo, n, ap_i, ap_r );
00180 LAPACKE_spp_trans( LAPACK_COL_MAJOR, uplo, n, bp_i, bp_r );
00181 info_i = LAPACKE_sspgst( LAPACK_ROW_MAJOR, itype_i, uplo_i, n_i, ap_r,
00182 bp_r );
00183
00184 LAPACKE_spp_trans( LAPACK_ROW_MAJOR, uplo, n, ap_r, ap_i );
00185
00186 failed = compare_sspgst( ap, ap_i, info, info_i, n );
00187 if( failed == 0 ) {
00188 printf( "PASSED: row-major high-level interface to sspgst\n" );
00189 } else {
00190 printf( "FAILED: row-major high-level interface to sspgst\n" );
00191 }
00192
00193
00194 if( ap != NULL ) {
00195 LAPACKE_free( ap );
00196 }
00197 if( ap_i != NULL ) {
00198 LAPACKE_free( ap_i );
00199 }
00200 if( ap_r != NULL ) {
00201 LAPACKE_free( ap_r );
00202 }
00203 if( ap_save != NULL ) {
00204 LAPACKE_free( ap_save );
00205 }
00206 if( bp != NULL ) {
00207 LAPACKE_free( bp );
00208 }
00209 if( bp_i != NULL ) {
00210 LAPACKE_free( bp_i );
00211 }
00212 if( bp_r != NULL ) {
00213 LAPACKE_free( bp_r );
00214 }
00215
00216 return 0;
00217 }
00218
00219
00220 static void init_scalars_sspgst( lapack_int *itype, char *uplo, lapack_int *n )
00221 {
00222 *itype = 1;
00223 *uplo = 'L';
00224 *n = 4;
00225
00226 return;
00227 }
00228
00229
00230 static void init_ap( lapack_int size, float *ap ) {
00231 lapack_int i;
00232 for( i = 0; i < size; i++ ) {
00233 ap[i] = 0;
00234 }
00235 ap[0] = 2.399999946e-001;
00236 ap[1] = 3.899999857e-001;
00237 ap[2] = 4.199999869e-001;
00238 ap[3] = -1.599999964e-001;
00239 ap[4] = -1.099999994e-001;
00240 ap[5] = 7.900000215e-001;
00241 ap[6] = 6.299999952e-001;
00242 ap[7] = -2.500000000e-001;
00243 ap[8] = 4.799999893e-001;
00244 ap[9] = -2.999999933e-002;
00245 }
00246 static void init_bp( lapack_int size, float *bp ) {
00247 lapack_int i;
00248 for( i = 0; i < size; i++ ) {
00249 bp[i] = 0;
00250 }
00251 bp[0] = 2.039607763e+000;
00252 bp[1] = -1.529705763e+000;
00253 bp[2] = 2.745625973e-001;
00254 bp[3] = -4.902903363e-002;
00255 bp[4] = 1.640122056e+000;
00256 bp[5] = -2.499813884e-001;
00257 bp[6] = 6.188563704e-001;
00258 bp[7] = 7.887488008e-001;
00259 bp[8] = 6.442660689e-001;
00260 bp[9] = 6.160634160e-001;
00261 }
00262
00263
00264
00265 static int compare_sspgst( float *ap, float *ap_i, lapack_int info,
00266 lapack_int info_i, lapack_int n )
00267 {
00268 lapack_int i;
00269 int failed = 0;
00270 for( i = 0; i < (n*(n+1)/2); i++ ) {
00271 failed += compare_floats(ap[i],ap_i[i]);
00272 }
00273 failed += (info == info_i) ? 0 : 1;
00274 if( info != 0 || info_i != 0 ) {
00275 printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00276 }
00277
00278 return failed;
00279 }