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_sgebak( 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, float *scale );
00058 static void init_v( lapack_int size, float *v );
00059 static int compare_sgebak( float *v, float *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 float *scale = NULL, *scale_i = NULL;
00079 float *v = NULL, *v_i = NULL;
00080 float *v_save = NULL;
00081 float *v_r = NULL;
00082
00083
00084 init_scalars_sgebak( &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 = (float *)LAPACKE_malloc( n * sizeof(float) );
00096 v = (float *)LAPACKE_malloc( ldv*m * sizeof(float) );
00097
00098
00099 scale_i = (float *)LAPACKE_malloc( n * sizeof(float) );
00100 v_i = (float *)LAPACKE_malloc( ldv*m * sizeof(float) );
00101
00102
00103 v_save = (float *)LAPACKE_malloc( ldv*m * sizeof(float) );
00104
00105
00106 v_r = (float *)LAPACKE_malloc( n*(m+2) * sizeof(float) );
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 sgebak_( &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_sgebak_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_sgebak( v, v_i, info, info_i, ldv, m );
00132 if( failed == 0 ) {
00133 printf( "PASSED: column-major middle-level interface to sgebak\n" );
00134 } else {
00135 printf( "FAILED: column-major middle-level interface to sgebak\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_sgebak( 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_sgebak( v, v_i, info, info_i, ldv, m );
00150 if( failed == 0 ) {
00151 printf( "PASSED: column-major high-level interface to sgebak\n" );
00152 } else {
00153 printf( "FAILED: column-major high-level interface to sgebak\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_sge_trans( LAPACK_COL_MAJOR, n, m, v_i, ldv, v_r, m+2 );
00166 info_i = LAPACKE_sgebak_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_sge_trans( LAPACK_ROW_MAJOR, n, m, v_r, m+2, v_i, ldv );
00170
00171 failed = compare_sgebak( v, v_i, info, info_i, ldv, m );
00172 if( failed == 0 ) {
00173 printf( "PASSED: row-major middle-level interface to sgebak\n" );
00174 } else {
00175 printf( "FAILED: row-major middle-level interface to sgebak\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_sge_trans( LAPACK_COL_MAJOR, n, m, v_i, ldv, v_r, m+2 );
00189 info_i = LAPACKE_sgebak( 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_sge_trans( LAPACK_ROW_MAJOR, n, m, v_r, m+2, v_i, ldv );
00193
00194 failed = compare_sgebak( v, v_i, info, info_i, ldv, m );
00195 if( failed == 0 ) {
00196 printf( "PASSED: row-major high-level interface to sgebak\n" );
00197 } else {
00198 printf( "FAILED: row-major high-level interface to sgebak\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_sgebak( 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, float *scale ) {
00242 lapack_int i;
00243 for( i = 0; i < size; i++ ) {
00244 scale[i] = 0;
00245 }
00246 scale[0] = 3.000000000e+000;
00247 scale[1] = 4.000000000e+000;
00248 scale[2] = 4.000000000e+000;
00249 scale[3] = 5.000000000e-001;
00250 }
00251 static void init_v( lapack_int size, float *v ) {
00252 lapack_int i;
00253 for( i = 0; i < size; i++ ) {
00254 v[i] = 0;
00255 }
00256 v[0] = 1.000000000e+000;
00257 v[8] = 2.157093138e-001;
00258 v[16] = 1.000000000e+000;
00259 v[24] = -9.999999404e-001;
00260 v[1] = 0.000000000e+000;
00261 v[9] = -1.000000000e+000;
00262 v[17] = 4.953082502e-001;
00263 v[25] = 1.718333215e-001;
00264 v[2] = 0.000000000e+000;
00265 v[10] = 4.910063446e-001;
00266 v[18] = 2.922107875e-001;
00267 v[26] = -9.537314773e-001;
00268 v[3] = 0.000000000e+000;
00269 v[11] = 8.751223683e-001;
00270 v[19] = 2.614878118e-001;
00271 v[27] = 4.724877477e-001;
00272 }
00273
00274
00275
00276 static int compare_sgebak( float *v, float *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_floats(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 }