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_zgbtrf( lapack_int *m, lapack_int *n, lapack_int *kl,
00055 lapack_int *ku, lapack_int *ldab );
00056 static void init_ab( lapack_int size, lapack_complex_double *ab );
00057 static void init_ipiv( lapack_int size, lapack_int *ipiv );
00058 static int compare_zgbtrf( lapack_complex_double *ab,
00059 lapack_complex_double *ab_i, lapack_int *ipiv,
00060 lapack_int *ipiv_i, lapack_int info,
00061 lapack_int info_i, lapack_int ldab, lapack_int m,
00062 lapack_int n );
00063
00064 int main(void)
00065 {
00066
00067 lapack_int m, m_i;
00068 lapack_int n, n_i;
00069 lapack_int kl, kl_i;
00070 lapack_int ku, ku_i;
00071 lapack_int ldab, ldab_i;
00072 lapack_int ldab_r;
00073 lapack_int info, info_i;
00074 lapack_int i;
00075 int failed;
00076
00077
00078 lapack_complex_double *ab = NULL, *ab_i = NULL;
00079 lapack_int *ipiv = NULL, *ipiv_i = NULL;
00080 lapack_complex_double *ab_save = NULL;
00081 lapack_int *ipiv_save = NULL;
00082 lapack_complex_double *ab_r = NULL;
00083
00084
00085 init_scalars_zgbtrf( &m, &n, &kl, &ku, &ldab );
00086 ldab_r = n+2;
00087 m_i = m;
00088 n_i = n;
00089 kl_i = kl;
00090 ku_i = ku;
00091 ldab_i = ldab;
00092
00093
00094 ab = (lapack_complex_double *)
00095 LAPACKE_malloc( ldab*n * sizeof(lapack_complex_double) );
00096 ipiv = (lapack_int *)LAPACKE_malloc( MIN(m,n) * sizeof(lapack_int) );
00097
00098
00099 ab_i = (lapack_complex_double *)
00100 LAPACKE_malloc( ldab*n * sizeof(lapack_complex_double) );
00101 ipiv_i = (lapack_int *)LAPACKE_malloc( MIN(m,n) * sizeof(lapack_int) );
00102
00103
00104 ab_save = (lapack_complex_double *)
00105 LAPACKE_malloc( ldab*n * sizeof(lapack_complex_double) );
00106 ipiv_save = (lapack_int *)LAPACKE_malloc( MIN(m,n) * sizeof(lapack_int) );
00107
00108
00109 ab_r = (lapack_complex_double *)
00110 LAPACKE_malloc( ((2*kl+ku+1)*(n+2)) * sizeof(lapack_complex_double) );
00111
00112
00113 init_ab( ldab*n, ab );
00114 init_ipiv( (MIN(m,n)), ipiv );
00115
00116
00117 for( i = 0; i < ldab*n; i++ ) {
00118 ab_save[i] = ab[i];
00119 }
00120 for( i = 0; i < (MIN(m,n)); i++ ) {
00121 ipiv_save[i] = ipiv[i];
00122 }
00123
00124
00125 zgbtrf_( &m, &n, &kl, &ku, ab, &ldab, ipiv, &info );
00126
00127
00128
00129 for( i = 0; i < ldab*n; i++ ) {
00130 ab_i[i] = ab_save[i];
00131 }
00132 for( i = 0; i < (MIN(m,n)); i++ ) {
00133 ipiv_i[i] = ipiv_save[i];
00134 }
00135 info_i = LAPACKE_zgbtrf_work( LAPACK_COL_MAJOR, m_i, n_i, kl_i, ku_i, ab_i,
00136 ldab_i, ipiv_i );
00137
00138 failed = compare_zgbtrf( ab, ab_i, ipiv, ipiv_i, info, info_i, ldab, m, n );
00139 if( failed == 0 ) {
00140 printf( "PASSED: column-major middle-level interface to zgbtrf\n" );
00141 } else {
00142 printf( "FAILED: column-major middle-level interface to zgbtrf\n" );
00143 }
00144
00145
00146
00147 for( i = 0; i < ldab*n; i++ ) {
00148 ab_i[i] = ab_save[i];
00149 }
00150 for( i = 0; i < (MIN(m,n)); i++ ) {
00151 ipiv_i[i] = ipiv_save[i];
00152 }
00153 info_i = LAPACKE_zgbtrf( LAPACK_COL_MAJOR, m_i, n_i, kl_i, ku_i, ab_i,
00154 ldab_i, ipiv_i );
00155
00156 failed = compare_zgbtrf( ab, ab_i, ipiv, ipiv_i, info, info_i, ldab, m, n );
00157 if( failed == 0 ) {
00158 printf( "PASSED: column-major high-level interface to zgbtrf\n" );
00159 } else {
00160 printf( "FAILED: column-major high-level interface to zgbtrf\n" );
00161 }
00162
00163
00164
00165 for( i = 0; i < ldab*n; i++ ) {
00166 ab_i[i] = ab_save[i];
00167 }
00168 for( i = 0; i < (MIN(m,n)); i++ ) {
00169 ipiv_i[i] = ipiv_save[i];
00170 }
00171
00172 LAPACKE_zge_trans( LAPACK_COL_MAJOR, 2*kl+ku+1, n, ab_i, ldab, ab_r, n+2 );
00173 info_i = LAPACKE_zgbtrf_work( LAPACK_ROW_MAJOR, m_i, n_i, kl_i, ku_i, ab_r,
00174 ldab_r, ipiv_i );
00175
00176 LAPACKE_zge_trans( LAPACK_ROW_MAJOR, 2*kl+ku+1, n, ab_r, n+2, ab_i, ldab );
00177
00178 failed = compare_zgbtrf( ab, ab_i, ipiv, ipiv_i, info, info_i, ldab, m, n );
00179 if( failed == 0 ) {
00180 printf( "PASSED: row-major middle-level interface to zgbtrf\n" );
00181 } else {
00182 printf( "FAILED: row-major middle-level interface to zgbtrf\n" );
00183 }
00184
00185
00186
00187 for( i = 0; i < ldab*n; i++ ) {
00188 ab_i[i] = ab_save[i];
00189 }
00190 for( i = 0; i < (MIN(m,n)); i++ ) {
00191 ipiv_i[i] = ipiv_save[i];
00192 }
00193
00194
00195 LAPACKE_zge_trans( LAPACK_COL_MAJOR, 2*kl+ku+1, n, ab_i, ldab, ab_r, n+2 );
00196 info_i = LAPACKE_zgbtrf( LAPACK_ROW_MAJOR, m_i, n_i, kl_i, ku_i, ab_r,
00197 ldab_r, ipiv_i );
00198
00199 LAPACKE_zge_trans( LAPACK_ROW_MAJOR, 2*kl+ku+1, n, ab_r, n+2, ab_i, ldab );
00200
00201 failed = compare_zgbtrf( ab, ab_i, ipiv, ipiv_i, info, info_i, ldab, m, n );
00202 if( failed == 0 ) {
00203 printf( "PASSED: row-major high-level interface to zgbtrf\n" );
00204 } else {
00205 printf( "FAILED: row-major high-level interface to zgbtrf\n" );
00206 }
00207
00208
00209 if( ab != NULL ) {
00210 LAPACKE_free( ab );
00211 }
00212 if( ab_i != NULL ) {
00213 LAPACKE_free( ab_i );
00214 }
00215 if( ab_r != NULL ) {
00216 LAPACKE_free( ab_r );
00217 }
00218 if( ab_save != NULL ) {
00219 LAPACKE_free( ab_save );
00220 }
00221 if( ipiv != NULL ) {
00222 LAPACKE_free( ipiv );
00223 }
00224 if( ipiv_i != NULL ) {
00225 LAPACKE_free( ipiv_i );
00226 }
00227 if( ipiv_save != NULL ) {
00228 LAPACKE_free( ipiv_save );
00229 }
00230
00231 return 0;
00232 }
00233
00234
00235 static void init_scalars_zgbtrf( lapack_int *m, lapack_int *n, lapack_int *kl,
00236 lapack_int *ku, lapack_int *ldab )
00237 {
00238 *m = 4;
00239 *n = 4;
00240 *kl = 1;
00241 *ku = 2;
00242 *ldab = 25;
00243
00244 return;
00245 }
00246
00247
00248 static void init_ab( lapack_int size, lapack_complex_double *ab ) {
00249 lapack_int i;
00250 for( i = 0; i < size; i++ ) {
00251 ab[i] = lapack_make_complex_double( 0.0, 0.0 );
00252 }
00253 ab[0] = lapack_make_complex_double( 0.00000000000000000e+000,
00254 0.00000000000000000e+000 );
00255 ab[25] = lapack_make_complex_double( 0.00000000000000000e+000,
00256 0.00000000000000000e+000 );
00257 ab[50] = lapack_make_complex_double( 0.00000000000000000e+000,
00258 0.00000000000000000e+000 );
00259 ab[75] = lapack_make_complex_double( 0.00000000000000000e+000,
00260 0.00000000000000000e+000 );
00261 ab[1] = lapack_make_complex_double( 0.00000000000000000e+000,
00262 0.00000000000000000e+000 );
00263 ab[26] = lapack_make_complex_double( 0.00000000000000000e+000,
00264 0.00000000000000000e+000 );
00265 ab[51] = lapack_make_complex_double( 9.69999999999999970e-001,
00266 -2.83999999999999990e+000 );
00267 ab[76] = lapack_make_complex_double( 5.89999999999999970e-001,
00268 -4.79999999999999980e-001 );
00269 ab[2] = lapack_make_complex_double( 0.00000000000000000e+000,
00270 0.00000000000000000e+000 );
00271 ab[27] = lapack_make_complex_double( -2.04999999999999980e+000,
00272 -8.49999999999999980e-001 );
00273 ab[52] = lapack_make_complex_double( -3.99000000000000020e+000,
00274 4.00999999999999980e+000 );
00275 ab[77] = lapack_make_complex_double( 3.33000000000000010e+000,
00276 -1.04000000000000000e+000 );
00277 ab[3] = lapack_make_complex_double( -1.64999999999999990e+000,
00278 2.25999999999999980e+000 );
00279 ab[28] = lapack_make_complex_double( -1.48000000000000000e+000,
00280 -1.75000000000000000e+000 );
00281 ab[53] = lapack_make_complex_double( -1.06000000000000010e+000,
00282 1.93999999999999990e+000 );
00283 ab[78] = lapack_make_complex_double( -4.60000000000000020e-001,
00284 -1.72000000000000000e+000 );
00285 ab[4] = lapack_make_complex_double( 0.00000000000000000e+000,
00286 6.29999999999999980e+000 );
00287 ab[29] = lapack_make_complex_double( -7.70000000000000020e-001,
00288 2.83000000000000010e+000 );
00289 ab[54] = lapack_make_complex_double( 4.48000000000000040e+000,
00290 -1.09000000000000010e+000 );
00291 ab[79] = lapack_make_complex_double( 0.00000000000000000e+000,
00292 0.00000000000000000e+000 );
00293 }
00294 static void init_ipiv( lapack_int size, lapack_int *ipiv ) {
00295 lapack_int i;
00296 for( i = 0; i < size; i++ ) {
00297 ipiv[i] = 0;
00298 }
00299 }
00300
00301
00302
00303 static int compare_zgbtrf( lapack_complex_double *ab,
00304 lapack_complex_double *ab_i, lapack_int *ipiv,
00305 lapack_int *ipiv_i, lapack_int info,
00306 lapack_int info_i, lapack_int ldab, lapack_int m,
00307 lapack_int n )
00308 {
00309 lapack_int i;
00310 int failed = 0;
00311 for( i = 0; i < ldab*n; i++ ) {
00312 failed += compare_complex_doubles(ab[i],ab_i[i]);
00313 }
00314 for( i = 0; i < (MIN(m,n)); i++ ) {
00315 failed += (ipiv[i] == ipiv_i[i]) ? 0 : 1;
00316 }
00317 failed += (info == info_i) ? 0 : 1;
00318 if( info != 0 || info_i != 0 ) {
00319 printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00320 }
00321
00322 return failed;
00323 }