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