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_dsterf( lapack_int *n );
00055 static void init_d( lapack_int size, double *d );
00056 static void init_e( lapack_int size, double *e );
00057 static int compare_dsterf( double *d, double *d_i, double *e, double *e_i,
00058 lapack_int info, lapack_int info_i, lapack_int n );
00059
00060 int main(void)
00061 {
00062
00063 lapack_int n, n_i;
00064 lapack_int info, info_i;
00065 lapack_int i;
00066 int failed;
00067
00068
00069 double *d = NULL, *d_i = NULL;
00070 double *e = NULL, *e_i = NULL;
00071 double *d_save = NULL;
00072 double *e_save = NULL;
00073
00074
00075 init_scalars_dsterf( &n );
00076 n_i = n;
00077
00078
00079 d = (double *)LAPACKE_malloc( n * sizeof(double) );
00080 e = (double *)LAPACKE_malloc( (n-1) * sizeof(double) );
00081
00082
00083 d_i = (double *)LAPACKE_malloc( n * sizeof(double) );
00084 e_i = (double *)LAPACKE_malloc( (n-1) * sizeof(double) );
00085
00086
00087 d_save = (double *)LAPACKE_malloc( n * sizeof(double) );
00088 e_save = (double *)LAPACKE_malloc( (n-1) * sizeof(double) );
00089
00090
00091
00092
00093 init_d( n, d );
00094 init_e( (n-1), e );
00095
00096
00097 for( i = 0; i < n; i++ ) {
00098 d_save[i] = d[i];
00099 }
00100 for( i = 0; i < (n-1); i++ ) {
00101 e_save[i] = e[i];
00102 }
00103
00104
00105 dsterf_( &n, d, e, &info );
00106
00107
00108
00109 for( i = 0; i < n; i++ ) {
00110 d_i[i] = d_save[i];
00111 }
00112 for( i = 0; i < (n-1); i++ ) {
00113 e_i[i] = e_save[i];
00114 }
00115 info_i = LAPACKE_dsterf_work( n_i, d_i, e_i );
00116
00117 failed = compare_dsterf( d, d_i, e, e_i, info, info_i, n );
00118 if( failed == 0 ) {
00119 printf( "PASSED: column-major middle-level interface to dsterf\n" );
00120 } else {
00121 printf( "FAILED: column-major middle-level interface to dsterf\n" );
00122 }
00123
00124
00125
00126 for( i = 0; i < n; i++ ) {
00127 d_i[i] = d_save[i];
00128 }
00129 for( i = 0; i < (n-1); i++ ) {
00130 e_i[i] = e_save[i];
00131 }
00132 info_i = LAPACKE_dsterf( n_i, d_i, e_i );
00133
00134 failed = compare_dsterf( d, d_i, e, e_i, info, info_i, n );
00135 if( failed == 0 ) {
00136 printf( "PASSED: column-major high-level interface to dsterf\n" );
00137 } else {
00138 printf( "FAILED: column-major high-level interface to dsterf\n" );
00139 }
00140
00141 failed = compare_dsterf( d, d_i, e, e_i, info, info_i, n );
00142 if( failed == 0 ) {
00143 printf( "PASSED: row-major middle-level interface to dsterf\n" );
00144 } else {
00145 printf( "FAILED: row-major middle-level interface to dsterf\n" );
00146 }
00147
00148 failed = compare_dsterf( d, d_i, e, e_i, info, info_i, n );
00149 if( failed == 0 ) {
00150 printf( "PASSED: row-major high-level interface to dsterf\n" );
00151 } else {
00152 printf( "FAILED: row-major high-level interface to dsterf\n" );
00153 }
00154
00155
00156 if( d != NULL ) {
00157 LAPACKE_free( d );
00158 }
00159 if( d_i != NULL ) {
00160 LAPACKE_free( d_i );
00161 }
00162 if( d_save != NULL ) {
00163 LAPACKE_free( d_save );
00164 }
00165 if( e != NULL ) {
00166 LAPACKE_free( e );
00167 }
00168 if( e_i != NULL ) {
00169 LAPACKE_free( e_i );
00170 }
00171 if( e_save != NULL ) {
00172 LAPACKE_free( e_save );
00173 }
00174
00175 return 0;
00176 }
00177
00178
00179 static void init_scalars_dsterf( lapack_int *n )
00180 {
00181 *n = 4;
00182
00183 return;
00184 }
00185
00186
00187 static void init_d( lapack_int size, double *d ) {
00188 lapack_int i;
00189 for( i = 0; i < size; i++ ) {
00190 d[i] = 0;
00191 }
00192 d[0] = 5.76923076923076890e-002;
00193 d[1] = -1.12281732623795280e+000;
00194 d[2] = -2.27994375116573610e-002;
00195 d[3] = -3.65163806065562310e-001;
00196 }
00197 static void init_e( lapack_int size, double *e ) {
00198 lapack_int i;
00199 for( i = 0; i < size; i++ ) {
00200 e[i] = 0;
00201 }
00202 e[0] = -6.92063721827608340e-001;
00203 e[1] = -1.37737608436229640e+000;
00204 e[2] = 3.80464130611855360e-001;
00205 }
00206
00207
00208
00209 static int compare_dsterf( double *d, double *d_i, double *e, double *e_i,
00210 lapack_int info, lapack_int info_i, lapack_int n )
00211 {
00212 lapack_int i;
00213 int failed = 0;
00214 for( i = 0; i < n; i++ ) {
00215 failed += compare_doubles(d[i],d_i[i]);
00216 }
00217 for( i = 0; i < (n-1); i++ ) {
00218 failed += compare_doubles(e[i],e_i[i]);
00219 }
00220 failed += (info == info_i) ? 0 : 1;
00221 if( info != 0 || info_i != 0 ) {
00222 printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00223 }
00224
00225 return failed;
00226 }