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_dpbtrf( char *uplo, lapack_int *n, lapack_int *kd,
00055 lapack_int *ldab );
00056 static void init_ab( lapack_int size, double *ab );
00057 static int compare_dpbtrf( double *ab, double *ab_i, lapack_int info,
00058 lapack_int info_i, lapack_int ldab, lapack_int n );
00059
00060 int main(void)
00061 {
00062
00063 char uplo, uplo_i;
00064 lapack_int n, n_i;
00065 lapack_int kd, kd_i;
00066 lapack_int ldab, ldab_i;
00067 lapack_int ldab_r;
00068 lapack_int info, info_i;
00069 lapack_int i;
00070 int failed;
00071
00072
00073 double *ab = NULL, *ab_i = NULL;
00074 double *ab_save = NULL;
00075 double *ab_r = NULL;
00076
00077
00078 init_scalars_dpbtrf( &uplo, &n, &kd, &ldab );
00079 ldab_r = n+2;
00080 uplo_i = uplo;
00081 n_i = n;
00082 kd_i = kd;
00083 ldab_i = ldab;
00084
00085
00086 ab = (double *)LAPACKE_malloc( ldab*n * sizeof(double) );
00087
00088
00089 ab_i = (double *)LAPACKE_malloc( ldab*n * sizeof(double) );
00090
00091
00092 ab_save = (double *)LAPACKE_malloc( ldab*n * sizeof(double) );
00093
00094
00095 ab_r = (double *)LAPACKE_malloc( (kd+1)*(n+2) * sizeof(double) );
00096
00097
00098 init_ab( ldab*n, ab );
00099
00100
00101 for( i = 0; i < ldab*n; i++ ) {
00102 ab_save[i] = ab[i];
00103 }
00104
00105
00106 dpbtrf_( &uplo, &n, &kd, ab, &ldab, &info );
00107
00108
00109
00110 for( i = 0; i < ldab*n; i++ ) {
00111 ab_i[i] = ab_save[i];
00112 }
00113 info_i = LAPACKE_dpbtrf_work( LAPACK_COL_MAJOR, uplo_i, n_i, kd_i, ab_i,
00114 ldab_i );
00115
00116 failed = compare_dpbtrf( ab, ab_i, info, info_i, ldab, n );
00117 if( failed == 0 ) {
00118 printf( "PASSED: column-major middle-level interface to dpbtrf\n" );
00119 } else {
00120 printf( "FAILED: column-major middle-level interface to dpbtrf\n" );
00121 }
00122
00123
00124
00125 for( i = 0; i < ldab*n; i++ ) {
00126 ab_i[i] = ab_save[i];
00127 }
00128 info_i = LAPACKE_dpbtrf( LAPACK_COL_MAJOR, uplo_i, n_i, kd_i, ab_i,
00129 ldab_i );
00130
00131 failed = compare_dpbtrf( ab, ab_i, info, info_i, ldab, n );
00132 if( failed == 0 ) {
00133 printf( "PASSED: column-major high-level interface to dpbtrf\n" );
00134 } else {
00135 printf( "FAILED: column-major high-level interface to dpbtrf\n" );
00136 }
00137
00138
00139
00140 for( i = 0; i < ldab*n; i++ ) {
00141 ab_i[i] = ab_save[i];
00142 }
00143
00144 LAPACKE_dge_trans( LAPACK_COL_MAJOR, kd+1, n, ab_i, ldab, ab_r, n+2 );
00145 info_i = LAPACKE_dpbtrf_work( LAPACK_ROW_MAJOR, uplo_i, n_i, kd_i, ab_r,
00146 ldab_r );
00147
00148 LAPACKE_dge_trans( LAPACK_ROW_MAJOR, kd+1, n, ab_r, n+2, ab_i, ldab );
00149
00150 failed = compare_dpbtrf( ab, ab_i, info, info_i, ldab, n );
00151 if( failed == 0 ) {
00152 printf( "PASSED: row-major middle-level interface to dpbtrf\n" );
00153 } else {
00154 printf( "FAILED: row-major middle-level interface to dpbtrf\n" );
00155 }
00156
00157
00158
00159 for( i = 0; i < ldab*n; i++ ) {
00160 ab_i[i] = ab_save[i];
00161 }
00162
00163
00164 LAPACKE_dge_trans( LAPACK_COL_MAJOR, kd+1, n, ab_i, ldab, ab_r, n+2 );
00165 info_i = LAPACKE_dpbtrf( LAPACK_ROW_MAJOR, uplo_i, n_i, kd_i, ab_r,
00166 ldab_r );
00167
00168 LAPACKE_dge_trans( LAPACK_ROW_MAJOR, kd+1, n, ab_r, n+2, ab_i, ldab );
00169
00170 failed = compare_dpbtrf( ab, ab_i, info, info_i, ldab, n );
00171 if( failed == 0 ) {
00172 printf( "PASSED: row-major high-level interface to dpbtrf\n" );
00173 } else {
00174 printf( "FAILED: row-major high-level interface to dpbtrf\n" );
00175 }
00176
00177
00178 if( ab != NULL ) {
00179 LAPACKE_free( ab );
00180 }
00181 if( ab_i != NULL ) {
00182 LAPACKE_free( ab_i );
00183 }
00184 if( ab_r != NULL ) {
00185 LAPACKE_free( ab_r );
00186 }
00187 if( ab_save != NULL ) {
00188 LAPACKE_free( ab_save );
00189 }
00190
00191 return 0;
00192 }
00193
00194
00195 static void init_scalars_dpbtrf( char *uplo, lapack_int *n, lapack_int *kd,
00196 lapack_int *ldab )
00197 {
00198 *uplo = 'L';
00199 *n = 4;
00200 *kd = 1;
00201 *ldab = 9;
00202
00203 return;
00204 }
00205
00206
00207 static void init_ab( lapack_int size, double *ab ) {
00208 lapack_int i;
00209 for( i = 0; i < size; i++ ) {
00210 ab[i] = 0;
00211 }
00212 ab[0] = 5.49000000000000020e+000;
00213 ab[9] = 5.62999999999999990e+000;
00214 ab[18] = 2.60000000000000010e+000;
00215 ab[27] = 5.16999999999999990e+000;
00216 ab[1] = 2.68000000000000020e+000;
00217 ab[10] = -2.39000000000000010e+000;
00218 ab[19] = -2.22000000000000020e+000;
00219 ab[28] = 0.00000000000000000e+000;
00220 }
00221
00222
00223
00224 static int compare_dpbtrf( double *ab, double *ab_i, lapack_int info,
00225 lapack_int info_i, lapack_int ldab, lapack_int n )
00226 {
00227 lapack_int i;
00228 int failed = 0;
00229 for( i = 0; i < ldab*n; i++ ) {
00230 failed += compare_doubles(ab[i],ab_i[i]);
00231 }
00232 failed += (info == info_i) ? 0 : 1;
00233 if( info != 0 || info_i != 0 ) {
00234 printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00235 }
00236
00237 return failed;
00238 }