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_zpotri( char *uplo, lapack_int *n, lapack_int *lda );
00055 static void init_a( lapack_int size, lapack_complex_double *a );
00056 static int compare_zpotri( 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_zpotri( &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 zpotri_( &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_zpotri_work( LAPACK_COL_MAJOR, uplo_i, n_i, a_i, lda_i );
00116
00117 failed = compare_zpotri( a, a_i, info, info_i, lda, n );
00118 if( failed == 0 ) {
00119 printf( "PASSED: column-major middle-level interface to zpotri\n" );
00120 } else {
00121 printf( "FAILED: column-major middle-level interface to zpotri\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_zpotri( LAPACK_COL_MAJOR, uplo_i, n_i, a_i, lda_i );
00130
00131 failed = compare_zpotri( a, a_i, info, info_i, lda, n );
00132 if( failed == 0 ) {
00133 printf( "PASSED: column-major high-level interface to zpotri\n" );
00134 } else {
00135 printf( "FAILED: column-major high-level interface to zpotri\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_zpotri_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_zpotri( a, a_i, info, info_i, lda, n );
00150 if( failed == 0 ) {
00151 printf( "PASSED: row-major middle-level interface to zpotri\n" );
00152 } else {
00153 printf( "FAILED: row-major middle-level interface to zpotri\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_zpotri( 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_zpotri( a, a_i, info, info_i, lda, n );
00169 if( failed == 0 ) {
00170 printf( "PASSED: row-major high-level interface to zpotri\n" );
00171 } else {
00172 printf( "FAILED: row-major high-level interface to zpotri\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_zpotri( 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( 1.79722007556114290e+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( 8.40186474952732460e-001,
00217 1.06831657742334190e+000 );
00218 a[9] = lapack_make_complex_double( 1.31635343950968520e+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.05718827974184860e+000,
00225 -4.67388502622712030e-001 );
00226 a[10] = lapack_make_complex_double( -4.70174947010632950e-001,
00227 3.13065815599946400e-001 );
00228 a[18] = lapack_make_complex_double( 1.56039297713712430e+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( 2.33694251311356020e-001,
00233 -1.39103721018664310e+000 );
00234 a[11] = lapack_make_complex_double( 8.33525092394419580e-002,
00235 3.67607144303747430e-002 );
00236 a[19] = lapack_make_complex_double( 9.35961733792340160e-001,
00237 9.89969219281573660e-001 );
00238 a[27] = lapack_make_complex_double( 6.60333297365589100e-001,
00239 0.00000000000000000e+000 );
00240 }
00241
00242
00243
00244 static int compare_zpotri( 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 }