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