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_dgebak( char *job, char *side, lapack_int *n,
00055 lapack_int *ilo, lapack_int *ihi,
00056 lapack_int *m, lapack_int *ldv );
00057 static void init_scale( lapack_int size, double *scale );
00058 static void init_v( lapack_int size, double *v );
00059 static int compare_dgebak( double *v, double *v_i, lapack_int info,
00060 lapack_int info_i, lapack_int ldv, lapack_int m );
00061
00062 int main(void)
00063 {
00064
00065 char job, job_i;
00066 char side, side_i;
00067 lapack_int n, n_i;
00068 lapack_int ilo, ilo_i;
00069 lapack_int ihi, ihi_i;
00070 lapack_int m, m_i;
00071 lapack_int ldv, ldv_i;
00072 lapack_int ldv_r;
00073 lapack_int info, info_i;
00074 lapack_int i;
00075 int failed;
00076
00077
00078 double *scale = NULL, *scale_i = NULL;
00079 double *v = NULL, *v_i = NULL;
00080 double *v_save = NULL;
00081 double *v_r = NULL;
00082
00083
00084 init_scalars_dgebak( &job, &side, &n, &ilo, &ihi, &m, &ldv );
00085 ldv_r = m+2;
00086 job_i = job;
00087 side_i = side;
00088 n_i = n;
00089 ilo_i = ilo;
00090 ihi_i = ihi;
00091 m_i = m;
00092 ldv_i = ldv;
00093
00094
00095 scale = (double *)LAPACKE_malloc( n * sizeof(double) );
00096 v = (double *)LAPACKE_malloc( ldv*m * sizeof(double) );
00097
00098
00099 scale_i = (double *)LAPACKE_malloc( n * sizeof(double) );
00100 v_i = (double *)LAPACKE_malloc( ldv*m * sizeof(double) );
00101
00102
00103 v_save = (double *)LAPACKE_malloc( ldv*m * sizeof(double) );
00104
00105
00106 v_r = (double *)LAPACKE_malloc( n*(m+2) * sizeof(double) );
00107
00108
00109 init_scale( n, scale );
00110 init_v( ldv*m, v );
00111
00112
00113 for( i = 0; i < ldv*m; i++ ) {
00114 v_save[i] = v[i];
00115 }
00116
00117
00118 dgebak_( &job, &side, &n, &ilo, &ihi, scale, &m, v, &ldv, &info );
00119
00120
00121
00122 for( i = 0; i < n; i++ ) {
00123 scale_i[i] = scale[i];
00124 }
00125 for( i = 0; i < ldv*m; i++ ) {
00126 v_i[i] = v_save[i];
00127 }
00128 info_i = LAPACKE_dgebak_work( LAPACK_COL_MAJOR, job_i, side_i, n_i, ilo_i,
00129 ihi_i, scale_i, m_i, v_i, ldv_i );
00130
00131 failed = compare_dgebak( v, v_i, info, info_i, ldv, m );
00132 if( failed == 0 ) {
00133 printf( "PASSED: column-major middle-level interface to dgebak\n" );
00134 } else {
00135 printf( "FAILED: column-major middle-level interface to dgebak\n" );
00136 }
00137
00138
00139
00140 for( i = 0; i < n; i++ ) {
00141 scale_i[i] = scale[i];
00142 }
00143 for( i = 0; i < ldv*m; i++ ) {
00144 v_i[i] = v_save[i];
00145 }
00146 info_i = LAPACKE_dgebak( LAPACK_COL_MAJOR, job_i, side_i, n_i, ilo_i, ihi_i,
00147 scale_i, m_i, v_i, ldv_i );
00148
00149 failed = compare_dgebak( v, v_i, info, info_i, ldv, m );
00150 if( failed == 0 ) {
00151 printf( "PASSED: column-major high-level interface to dgebak\n" );
00152 } else {
00153 printf( "FAILED: column-major high-level interface to dgebak\n" );
00154 }
00155
00156
00157
00158 for( i = 0; i < n; i++ ) {
00159 scale_i[i] = scale[i];
00160 }
00161 for( i = 0; i < ldv*m; i++ ) {
00162 v_i[i] = v_save[i];
00163 }
00164
00165 LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, m, v_i, ldv, v_r, m+2 );
00166 info_i = LAPACKE_dgebak_work( LAPACK_ROW_MAJOR, job_i, side_i, n_i, ilo_i,
00167 ihi_i, scale_i, m_i, v_r, ldv_r );
00168
00169 LAPACKE_dge_trans( LAPACK_ROW_MAJOR, n, m, v_r, m+2, v_i, ldv );
00170
00171 failed = compare_dgebak( v, v_i, info, info_i, ldv, m );
00172 if( failed == 0 ) {
00173 printf( "PASSED: row-major middle-level interface to dgebak\n" );
00174 } else {
00175 printf( "FAILED: row-major middle-level interface to dgebak\n" );
00176 }
00177
00178
00179
00180 for( i = 0; i < n; i++ ) {
00181 scale_i[i] = scale[i];
00182 }
00183 for( i = 0; i < ldv*m; i++ ) {
00184 v_i[i] = v_save[i];
00185 }
00186
00187
00188 LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, m, v_i, ldv, v_r, m+2 );
00189 info_i = LAPACKE_dgebak( LAPACK_ROW_MAJOR, job_i, side_i, n_i, ilo_i, ihi_i,
00190 scale_i, m_i, v_r, ldv_r );
00191
00192 LAPACKE_dge_trans( LAPACK_ROW_MAJOR, n, m, v_r, m+2, v_i, ldv );
00193
00194 failed = compare_dgebak( v, v_i, info, info_i, ldv, m );
00195 if( failed == 0 ) {
00196 printf( "PASSED: row-major high-level interface to dgebak\n" );
00197 } else {
00198 printf( "FAILED: row-major high-level interface to dgebak\n" );
00199 }
00200
00201
00202 if( scale != NULL ) {
00203 LAPACKE_free( scale );
00204 }
00205 if( scale_i != NULL ) {
00206 LAPACKE_free( scale_i );
00207 }
00208 if( v != NULL ) {
00209 LAPACKE_free( v );
00210 }
00211 if( v_i != NULL ) {
00212 LAPACKE_free( v_i );
00213 }
00214 if( v_r != NULL ) {
00215 LAPACKE_free( v_r );
00216 }
00217 if( v_save != NULL ) {
00218 LAPACKE_free( v_save );
00219 }
00220
00221 return 0;
00222 }
00223
00224
00225 static void init_scalars_dgebak( char *job, char *side, lapack_int *n,
00226 lapack_int *ilo, lapack_int *ihi,
00227 lapack_int *m, lapack_int *ldv )
00228 {
00229 *job = 'B';
00230 *side = 'R';
00231 *n = 4;
00232 *ilo = 2;
00233 *ihi = 4;
00234 *m = 4;
00235 *ldv = 8;
00236
00237 return;
00238 }
00239
00240
00241 static void init_scale( lapack_int size, double *scale ) {
00242 lapack_int i;
00243 for( i = 0; i < size; i++ ) {
00244 scale[i] = 0;
00245 }
00246 scale[0] = 3.00000000000000000e+000;
00247 scale[1] = 4.00000000000000000e+000;
00248 scale[2] = 4.00000000000000000e+000;
00249 scale[3] = 5.00000000000000000e-001;
00250 }
00251 static void init_v( lapack_int size, double *v ) {
00252 lapack_int i;
00253 for( i = 0; i < size; i++ ) {
00254 v[i] = 0;
00255 }
00256 v[0] = 1.00000000000000000e+000;
00257 v[8] = -2.15709029223295460e-001;
00258 v[16] = -1.00000000000000000e+000;
00259 v[24] = -1.00000000000000000e+000;
00260 v[1] = 0.00000000000000000e+000;
00261 v[9] = 1.00000000000000000e+000;
00262 v[17] = -4.95308301949082260e-001;
00263 v[25] = 1.71833107632870240e-001;
00264 v[2] = 0.00000000000000000e+000;
00265 v[10] = -4.91006373625574700e-001;
00266 v[18] = -2.92210843245896300e-001;
00267 v[26] = -9.53731439243778790e-001;
00268 v[3] = 0.00000000000000000e+000;
00269 v[11] = -8.75122446424736690e-001;
00270 v[19] = -2.61487853687739190e-001;
00271 v[27] = 4.72487441336102100e-001;
00272 }
00273
00274
00275
00276 static int compare_dgebak( double *v, double *v_i, lapack_int info,
00277 lapack_int info_i, lapack_int ldv, lapack_int m )
00278 {
00279 lapack_int i;
00280 int failed = 0;
00281 for( i = 0; i < ldv*m; i++ ) {
00282 failed += compare_doubles(v[i],v_i[i]);
00283 }
00284 failed += (info == info_i) ? 0 : 1;
00285 if( info != 0 || info_i != 0 ) {
00286 printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00287 }
00288
00289 return failed;
00290 }