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_dsygst( lapack_int *itype, char *uplo, lapack_int *n,
00055 lapack_int *lda, lapack_int *ldb );
00056 static void init_a( lapack_int size, double *a );
00057 static void init_b( lapack_int size, double *b );
00058 static int compare_dsygst( double *a, double *a_i, lapack_int info,
00059 lapack_int info_i, lapack_int lda, 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 lda, lda_i;
00068 lapack_int lda_r;
00069 lapack_int ldb, ldb_i;
00070 lapack_int ldb_r;
00071 lapack_int info, info_i;
00072 lapack_int i;
00073 int failed;
00074
00075
00076 double *a = NULL, *a_i = NULL;
00077 double *b = NULL, *b_i = NULL;
00078 double *a_save = NULL;
00079 double *a_r = NULL;
00080 double *b_r = NULL;
00081
00082
00083 init_scalars_dsygst( &itype, &uplo, &n, &lda, &ldb );
00084 lda_r = n+2;
00085 ldb_r = n+2;
00086 itype_i = itype;
00087 uplo_i = uplo;
00088 n_i = n;
00089 lda_i = lda;
00090 ldb_i = ldb;
00091
00092
00093 a = (double *)LAPACKE_malloc( lda*n * sizeof(double) );
00094 b = (double *)LAPACKE_malloc( ldb*n * sizeof(double) );
00095
00096
00097 a_i = (double *)LAPACKE_malloc( lda*n * sizeof(double) );
00098 b_i = (double *)LAPACKE_malloc( ldb*n * sizeof(double) );
00099
00100
00101 a_save = (double *)LAPACKE_malloc( lda*n * sizeof(double) );
00102
00103
00104 a_r = (double *)LAPACKE_malloc( n*(n+2) * sizeof(double) );
00105 b_r = (double *)LAPACKE_malloc( n*(n+2) * sizeof(double) );
00106
00107
00108 init_a( lda*n, a );
00109 init_b( ldb*n, b );
00110
00111
00112 for( i = 0; i < lda*n; i++ ) {
00113 a_save[i] = a[i];
00114 }
00115
00116
00117 dsygst_( &itype, &uplo, &n, a, &lda, b, &ldb, &info );
00118
00119
00120
00121 for( i = 0; i < lda*n; i++ ) {
00122 a_i[i] = a_save[i];
00123 }
00124 for( i = 0; i < ldb*n; i++ ) {
00125 b_i[i] = b[i];
00126 }
00127 info_i = LAPACKE_dsygst_work( LAPACK_COL_MAJOR, itype_i, uplo_i, n_i, a_i,
00128 lda_i, b_i, ldb_i );
00129
00130 failed = compare_dsygst( a, a_i, info, info_i, lda, n );
00131 if( failed == 0 ) {
00132 printf( "PASSED: column-major middle-level interface to dsygst\n" );
00133 } else {
00134 printf( "FAILED: column-major middle-level interface to dsygst\n" );
00135 }
00136
00137
00138
00139 for( i = 0; i < lda*n; i++ ) {
00140 a_i[i] = a_save[i];
00141 }
00142 for( i = 0; i < ldb*n; i++ ) {
00143 b_i[i] = b[i];
00144 }
00145 info_i = LAPACKE_dsygst( LAPACK_COL_MAJOR, itype_i, uplo_i, n_i, a_i, lda_i,
00146 b_i, ldb_i );
00147
00148 failed = compare_dsygst( a, a_i, info, info_i, lda, n );
00149 if( failed == 0 ) {
00150 printf( "PASSED: column-major high-level interface to dsygst\n" );
00151 } else {
00152 printf( "FAILED: column-major high-level interface to dsygst\n" );
00153 }
00154
00155
00156
00157 for( i = 0; i < lda*n; i++ ) {
00158 a_i[i] = a_save[i];
00159 }
00160 for( i = 0; i < ldb*n; i++ ) {
00161 b_i[i] = b[i];
00162 }
00163
00164 LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, n, a_i, lda, a_r, n+2 );
00165 LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, n, b_i, ldb, b_r, n+2 );
00166 info_i = LAPACKE_dsygst_work( LAPACK_ROW_MAJOR, itype_i, uplo_i, n_i, a_r,
00167 lda_r, b_r, ldb_r );
00168
00169 LAPACKE_dge_trans( LAPACK_ROW_MAJOR, n, n, a_r, n+2, a_i, lda );
00170
00171 failed = compare_dsygst( a, a_i, info, info_i, lda, n );
00172 if( failed == 0 ) {
00173 printf( "PASSED: row-major middle-level interface to dsygst\n" );
00174 } else {
00175 printf( "FAILED: row-major middle-level interface to dsygst\n" );
00176 }
00177
00178
00179
00180 for( i = 0; i < lda*n; i++ ) {
00181 a_i[i] = a_save[i];
00182 }
00183 for( i = 0; i < ldb*n; i++ ) {
00184 b_i[i] = b[i];
00185 }
00186
00187
00188 LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, n, a_i, lda, a_r, n+2 );
00189 LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, n, b_i, ldb, b_r, n+2 );
00190 info_i = LAPACKE_dsygst( LAPACK_ROW_MAJOR, itype_i, uplo_i, n_i, a_r, lda_r,
00191 b_r, ldb_r );
00192
00193 LAPACKE_dge_trans( LAPACK_ROW_MAJOR, n, n, a_r, n+2, a_i, lda );
00194
00195 failed = compare_dsygst( a, a_i, info, info_i, lda, n );
00196 if( failed == 0 ) {
00197 printf( "PASSED: row-major high-level interface to dsygst\n" );
00198 } else {
00199 printf( "FAILED: row-major high-level interface to dsygst\n" );
00200 }
00201
00202
00203 if( a != NULL ) {
00204 LAPACKE_free( a );
00205 }
00206 if( a_i != NULL ) {
00207 LAPACKE_free( a_i );
00208 }
00209 if( a_r != NULL ) {
00210 LAPACKE_free( a_r );
00211 }
00212 if( a_save != NULL ) {
00213 LAPACKE_free( a_save );
00214 }
00215 if( b != NULL ) {
00216 LAPACKE_free( b );
00217 }
00218 if( b_i != NULL ) {
00219 LAPACKE_free( b_i );
00220 }
00221 if( b_r != NULL ) {
00222 LAPACKE_free( b_r );
00223 }
00224
00225 return 0;
00226 }
00227
00228
00229 static void init_scalars_dsygst( lapack_int *itype, char *uplo, lapack_int *n,
00230 lapack_int *lda, lapack_int *ldb )
00231 {
00232 *itype = 1;
00233 *uplo = 'L';
00234 *n = 4;
00235 *lda = 8;
00236 *ldb = 8;
00237
00238 return;
00239 }
00240
00241
00242 static void init_a( lapack_int size, double *a ) {
00243 lapack_int i;
00244 for( i = 0; i < size; i++ ) {
00245 a[i] = 0;
00246 }
00247 a[0] = 2.39999999999999990e-001;
00248 a[8] = 0.00000000000000000e+000;
00249 a[16] = 0.00000000000000000e+000;
00250 a[24] = 0.00000000000000000e+000;
00251 a[1] = 3.90000000000000010e-001;
00252 a[9] = -1.10000000000000000e-001;
00253 a[17] = 0.00000000000000000e+000;
00254 a[25] = 0.00000000000000000e+000;
00255 a[2] = 4.19999999999999980e-001;
00256 a[10] = 7.90000000000000040e-001;
00257 a[18] = -2.50000000000000000e-001;
00258 a[26] = 0.00000000000000000e+000;
00259 a[3] = -1.60000000000000000e-001;
00260 a[11] = 6.30000000000000000e-001;
00261 a[19] = 4.79999999999999980e-001;
00262 a[27] = -2.99999999999999990e-002;
00263 }
00264 static void init_b( lapack_int size, double *b ) {
00265 lapack_int i;
00266 for( i = 0; i < size; i++ ) {
00267 b[i] = 0;
00268 }
00269 b[0] = 2.03960780543711410e+000;
00270 b[8] = 0.00000000000000000e+000;
00271 b[16] = 0.00000000000000000e+000;
00272 b[24] = 0.00000000000000000e+000;
00273 b[1] = -1.52970585407783540e+000;
00274 b[9] = 1.64012194668567270e+000;
00275 b[17] = 0.00000000000000000e+000;
00276 b[25] = 0.00000000000000000e+000;
00277 b[2] = 2.74562589193457660e-001;
00278 b[10] = -2.49981411948373810e-001;
00279 b[18] = 7.88748805574805310e-001;
00280 b[26] = 0.00000000000000000e+000;
00281 b[3] = -4.90290337845460110e-002;
00282 b[11] = 6.18856422262437760e-001;
00283 b[19] = 6.44266130231023420e-001;
00284 b[27] = 6.16063337578070080e-001;
00285 }
00286
00287
00288
00289 static int compare_dsygst( double *a, double *a_i, lapack_int info,
00290 lapack_int info_i, lapack_int lda, lapack_int n )
00291 {
00292 lapack_int i;
00293 int failed = 0;
00294 for( i = 0; i < lda*n; i++ ) {
00295 failed += compare_doubles(a[i],a_i[i]);
00296 }
00297 failed += (info == info_i) ? 0 : 1;
00298 if( info != 0 || info_i != 0 ) {
00299 printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00300 }
00301
00302 return failed;
00303 }