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_zpotrf( char *uplo, lapack_int *n, lapack_int *lda );
00055 static void init_a( lapack_int size, lapack_complex_double *a );
00056 static int compare_zpotrf( lapack_complex_double *a, lapack_complex_double *a_i,
00057 lapack_int info, lapack_int info_i, lapack_int lda,
00058 lapack_int n );
00059
00060 int main(void)
00061 {
00062
00063 char uplo, uplo_i;
00064 lapack_int n, n_i;
00065 lapack_int lda, lda_i;
00066 lapack_int lda_r;
00067 lapack_int info, info_i;
00068 lapack_int i;
00069 int failed;
00070
00071
00072 lapack_complex_double *a = NULL, *a_i = NULL;
00073 lapack_complex_double *a_save = NULL;
00074 lapack_complex_double *a_r = NULL;
00075
00076
00077 init_scalars_zpotrf( &uplo, &n, &lda );
00078 lda_r = n+2;
00079 uplo_i = uplo;
00080 n_i = n;
00081 lda_i = lda;
00082
00083
00084 a = (lapack_complex_double *)
00085 LAPACKE_malloc( lda*n * sizeof(lapack_complex_double) );
00086
00087
00088 a_i = (lapack_complex_double *)
00089 LAPACKE_malloc( lda*n * sizeof(lapack_complex_double) );
00090
00091
00092 a_save = (lapack_complex_double *)
00093 LAPACKE_malloc( lda*n * sizeof(lapack_complex_double) );
00094
00095
00096 a_r = (lapack_complex_double *)
00097 LAPACKE_malloc( n*(n+2) * sizeof(lapack_complex_double) );
00098
00099
00100 init_a( lda*n, a );
00101
00102
00103 for( i = 0; i < lda*n; i++ ) {
00104 a_save[i] = a[i];
00105 }
00106
00107
00108 zpotrf_( &uplo, &n, a, &lda, &info );
00109
00110
00111
00112 for( i = 0; i < lda*n; i++ ) {
00113 a_i[i] = a_save[i];
00114 }
00115 info_i = LAPACKE_zpotrf_work( LAPACK_COL_MAJOR, uplo_i, n_i, a_i, lda_i );
00116
00117 failed = compare_zpotrf( a, a_i, info, info_i, lda, n );
00118 if( failed == 0 ) {
00119 printf( "PASSED: column-major middle-level interface to zpotrf\n" );
00120 } else {
00121 printf( "FAILED: column-major middle-level interface to zpotrf\n" );
00122 }
00123
00124
00125
00126 for( i = 0; i < lda*n; i++ ) {
00127 a_i[i] = a_save[i];
00128 }
00129 info_i = LAPACKE_zpotrf( LAPACK_COL_MAJOR, uplo_i, n_i, a_i, lda_i );
00130
00131 failed = compare_zpotrf( a, a_i, info, info_i, lda, n );
00132 if( failed == 0 ) {
00133 printf( "PASSED: column-major high-level interface to zpotrf\n" );
00134 } else {
00135 printf( "FAILED: column-major high-level interface to zpotrf\n" );
00136 }
00137
00138
00139
00140 for( i = 0; i < lda*n; i++ ) {
00141 a_i[i] = a_save[i];
00142 }
00143
00144 LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, n, a_i, lda, a_r, n+2 );
00145 info_i = LAPACKE_zpotrf_work( LAPACK_ROW_MAJOR, uplo_i, n_i, a_r, lda_r );
00146
00147 LAPACKE_zge_trans( LAPACK_ROW_MAJOR, n, n, a_r, n+2, a_i, lda );
00148
00149 failed = compare_zpotrf( a, a_i, info, info_i, lda, n );
00150 if( failed == 0 ) {
00151 printf( "PASSED: row-major middle-level interface to zpotrf\n" );
00152 } else {
00153 printf( "FAILED: row-major middle-level interface to zpotrf\n" );
00154 }
00155
00156
00157
00158 for( i = 0; i < lda*n; i++ ) {
00159 a_i[i] = a_save[i];
00160 }
00161
00162
00163 LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, n, a_i, lda, a_r, n+2 );
00164 info_i = LAPACKE_zpotrf( LAPACK_ROW_MAJOR, uplo_i, n_i, a_r, lda_r );
00165
00166 LAPACKE_zge_trans( LAPACK_ROW_MAJOR, n, n, a_r, n+2, a_i, lda );
00167
00168 failed = compare_zpotrf( a, a_i, info, info_i, lda, n );
00169 if( failed == 0 ) {
00170 printf( "PASSED: row-major high-level interface to zpotrf\n" );
00171 } else {
00172 printf( "FAILED: row-major high-level interface to zpotrf\n" );
00173 }
00174
00175
00176 if( a != NULL ) {
00177 LAPACKE_free( a );
00178 }
00179 if( a_i != NULL ) {
00180 LAPACKE_free( a_i );
00181 }
00182 if( a_r != NULL ) {
00183 LAPACKE_free( a_r );
00184 }
00185 if( a_save != NULL ) {
00186 LAPACKE_free( a_save );
00187 }
00188
00189 return 0;
00190 }
00191
00192
00193 static void init_scalars_zpotrf( char *uplo, lapack_int *n, lapack_int *lda )
00194 {
00195 *uplo = 'L';
00196 *n = 4;
00197 *lda = 8;
00198
00199 return;
00200 }
00201
00202
00203 static void init_a( lapack_int size, lapack_complex_double *a ) {
00204 lapack_int i;
00205 for( i = 0; i < size; i++ ) {
00206 a[i] = lapack_make_complex_double( 0.0, 0.0 );
00207 }
00208 a[0] = lapack_make_complex_double( 3.23000000000000000e+000,
00209 0.00000000000000000e+000 );
00210 a[8] = lapack_make_complex_double( 0.00000000000000000e+000,
00211 0.00000000000000000e+000 );
00212 a[16] = lapack_make_complex_double( 0.00000000000000000e+000,
00213 0.00000000000000000e+000 );
00214 a[24] = lapack_make_complex_double( 0.00000000000000000e+000,
00215 0.00000000000000000e+000 );
00216 a[1] = lapack_make_complex_double( 1.51000000000000000e+000,
00217 1.91999999999999990e+000 );
00218 a[9] = lapack_make_complex_double( 3.58000000000000010e+000,
00219 0.00000000000000000e+000 );
00220 a[17] = lapack_make_complex_double( 0.00000000000000000e+000,
00221 0.00000000000000000e+000 );
00222 a[25] = lapack_make_complex_double( 0.00000000000000000e+000,
00223 0.00000000000000000e+000 );
00224 a[2] = lapack_make_complex_double( 1.89999999999999990e+000,
00225 -8.39999999999999970e-001 );
00226 a[10] = lapack_make_complex_double( -2.30000000000000010e-001,
00227 -1.11000000000000010e+000 );
00228 a[18] = lapack_make_complex_double( 4.08999999999999990e+000,
00229 0.00000000000000000e+000 );
00230 a[26] = lapack_make_complex_double( 0.00000000000000000e+000,
00231 0.00000000000000000e+000 );
00232 a[3] = lapack_make_complex_double( 4.19999999999999980e-001,
00233 -2.50000000000000000e+000 );
00234 a[11] = lapack_make_complex_double( -1.17999999999999990e+000,
00235 -1.37000000000000010e+000 );
00236 a[19] = lapack_make_complex_double( 2.33000000000000010e+000,
00237 1.40000000000000010e-001 );
00238 a[27] = lapack_make_complex_double( 4.29000000000000000e+000,
00239 0.00000000000000000e+000 );
00240 }
00241
00242
00243
00244 static int compare_zpotrf( lapack_complex_double *a, lapack_complex_double *a_i,
00245 lapack_int info, lapack_int info_i, lapack_int lda,
00246 lapack_int n )
00247 {
00248 lapack_int i;
00249 int failed = 0;
00250 for( i = 0; i < lda*n; i++ ) {
00251 failed += compare_complex_doubles(a[i],a_i[i]);
00252 }
00253 failed += (info == info_i) ? 0 : 1;
00254 if( info != 0 || info_i != 0 ) {
00255 printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00256 }
00257
00258 return failed;
00259 }