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