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_zsytri( char *uplo, lapack_int *n, lapack_int *lda );
00055 static void init_a( lapack_int size, lapack_complex_double *a );
00056 static void init_ipiv( lapack_int size, lapack_int *ipiv );
00057 static void init_work( lapack_int size, lapack_complex_double *work );
00058 static int compare_zsytri( lapack_complex_double *a, lapack_complex_double *a_i,
00059 lapack_int info, lapack_int info_i, lapack_int lda,
00060 lapack_int n );
00061
00062 int main(void)
00063 {
00064
00065 char uplo, uplo_i;
00066 lapack_int n, n_i;
00067 lapack_int lda, lda_i;
00068 lapack_int lda_r;
00069 lapack_int info, info_i;
00070 lapack_int i;
00071 int failed;
00072
00073
00074 lapack_complex_double *a = NULL, *a_i = NULL;
00075 lapack_int *ipiv = NULL, *ipiv_i = NULL;
00076 lapack_complex_double *work = NULL, *work_i = NULL;
00077 lapack_complex_double *a_save = NULL;
00078 lapack_complex_double *a_r = NULL;
00079
00080
00081 init_scalars_zsytri( &uplo, &n, &lda );
00082 lda_r = n+2;
00083 uplo_i = uplo;
00084 n_i = n;
00085 lda_i = lda;
00086
00087
00088 a = (lapack_complex_double *)
00089 LAPACKE_malloc( lda*n * sizeof(lapack_complex_double) );
00090 ipiv = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
00091 work = (lapack_complex_double *)
00092 LAPACKE_malloc( 2*n * sizeof(lapack_complex_double) );
00093
00094
00095 a_i = (lapack_complex_double *)
00096 LAPACKE_malloc( lda*n * sizeof(lapack_complex_double) );
00097 ipiv_i = (lapack_int *)LAPACKE_malloc( n * sizeof(lapack_int) );
00098 work_i = (lapack_complex_double *)
00099 LAPACKE_malloc( 2*n * sizeof(lapack_complex_double) );
00100
00101
00102 a_save = (lapack_complex_double *)
00103 LAPACKE_malloc( lda*n * sizeof(lapack_complex_double) );
00104
00105
00106 a_r = (lapack_complex_double *)
00107 LAPACKE_malloc( n*(n+2) * sizeof(lapack_complex_double) );
00108
00109
00110 init_a( lda*n, a );
00111 init_ipiv( n, ipiv );
00112 init_work( 2*n, work );
00113
00114
00115 for( i = 0; i < lda*n; i++ ) {
00116 a_save[i] = a[i];
00117 }
00118
00119
00120 zsytri_( &uplo, &n, a, &lda, ipiv, work, &info );
00121
00122
00123
00124 for( i = 0; i < lda*n; i++ ) {
00125 a_i[i] = a_save[i];
00126 }
00127 for( i = 0; i < n; i++ ) {
00128 ipiv_i[i] = ipiv[i];
00129 }
00130 for( i = 0; i < 2*n; i++ ) {
00131 work_i[i] = work[i];
00132 }
00133 info_i = LAPACKE_zsytri_work( LAPACK_COL_MAJOR, uplo_i, n_i, a_i, lda_i,
00134 ipiv_i, work_i );
00135
00136 failed = compare_zsytri( a, a_i, info, info_i, lda, n );
00137 if( failed == 0 ) {
00138 printf( "PASSED: column-major middle-level interface to zsytri\n" );
00139 } else {
00140 printf( "FAILED: column-major middle-level interface to zsytri\n" );
00141 }
00142
00143
00144
00145 for( i = 0; i < lda*n; i++ ) {
00146 a_i[i] = a_save[i];
00147 }
00148 for( i = 0; i < n; i++ ) {
00149 ipiv_i[i] = ipiv[i];
00150 }
00151 for( i = 0; i < 2*n; i++ ) {
00152 work_i[i] = work[i];
00153 }
00154 info_i = LAPACKE_zsytri( LAPACK_COL_MAJOR, uplo_i, n_i, a_i, lda_i,
00155 ipiv_i );
00156
00157 failed = compare_zsytri( a, a_i, info, info_i, lda, n );
00158 if( failed == 0 ) {
00159 printf( "PASSED: column-major high-level interface to zsytri\n" );
00160 } else {
00161 printf( "FAILED: column-major high-level interface to zsytri\n" );
00162 }
00163
00164
00165
00166 for( i = 0; i < lda*n; i++ ) {
00167 a_i[i] = a_save[i];
00168 }
00169 for( i = 0; i < n; i++ ) {
00170 ipiv_i[i] = ipiv[i];
00171 }
00172 for( i = 0; i < 2*n; i++ ) {
00173 work_i[i] = work[i];
00174 }
00175
00176 LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, n, a_i, lda, a_r, n+2 );
00177 info_i = LAPACKE_zsytri_work( LAPACK_ROW_MAJOR, uplo_i, n_i, a_r, lda_r,
00178 ipiv_i, work_i );
00179
00180 LAPACKE_zge_trans( LAPACK_ROW_MAJOR, n, n, a_r, n+2, a_i, lda );
00181
00182 failed = compare_zsytri( a, a_i, info, info_i, lda, n );
00183 if( failed == 0 ) {
00184 printf( "PASSED: row-major middle-level interface to zsytri\n" );
00185 } else {
00186 printf( "FAILED: row-major middle-level interface to zsytri\n" );
00187 }
00188
00189
00190
00191 for( i = 0; i < lda*n; i++ ) {
00192 a_i[i] = a_save[i];
00193 }
00194 for( i = 0; i < n; i++ ) {
00195 ipiv_i[i] = ipiv[i];
00196 }
00197 for( i = 0; i < 2*n; i++ ) {
00198 work_i[i] = work[i];
00199 }
00200
00201
00202 LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, n, a_i, lda, a_r, n+2 );
00203 info_i = LAPACKE_zsytri( LAPACK_ROW_MAJOR, uplo_i, n_i, a_r, lda_r,
00204 ipiv_i );
00205
00206 LAPACKE_zge_trans( LAPACK_ROW_MAJOR, n, n, a_r, n+2, a_i, lda );
00207
00208 failed = compare_zsytri( a, a_i, info, info_i, lda, n );
00209 if( failed == 0 ) {
00210 printf( "PASSED: row-major high-level interface to zsytri\n" );
00211 } else {
00212 printf( "FAILED: row-major high-level interface to zsytri\n" );
00213 }
00214
00215
00216 if( a != NULL ) {
00217 LAPACKE_free( a );
00218 }
00219 if( a_i != NULL ) {
00220 LAPACKE_free( a_i );
00221 }
00222 if( a_r != NULL ) {
00223 LAPACKE_free( a_r );
00224 }
00225 if( a_save != NULL ) {
00226 LAPACKE_free( a_save );
00227 }
00228 if( ipiv != NULL ) {
00229 LAPACKE_free( ipiv );
00230 }
00231 if( ipiv_i != NULL ) {
00232 LAPACKE_free( ipiv_i );
00233 }
00234 if( work != NULL ) {
00235 LAPACKE_free( work );
00236 }
00237 if( work_i != NULL ) {
00238 LAPACKE_free( work_i );
00239 }
00240
00241 return 0;
00242 }
00243
00244
00245 static void init_scalars_zsytri( char *uplo, lapack_int *n, lapack_int *lda )
00246 {
00247 *uplo = 'L';
00248 *n = 4;
00249 *lda = 8;
00250
00251 return;
00252 }
00253
00254
00255 static void init_a( lapack_int size, lapack_complex_double *a ) {
00256 lapack_int i;
00257 for( i = 0; i < size; i++ ) {
00258 a[i] = lapack_make_complex_double( 0.0, 0.0 );
00259 }
00260 a[0] = lapack_make_complex_double( -3.90000000000000010e-001,
00261 -7.09999999999999960e-001 );
00262 a[8] = lapack_make_complex_double( 0.00000000000000000e+000,
00263 0.00000000000000000e+000 );
00264 a[16] = lapack_make_complex_double( 0.00000000000000000e+000,
00265 0.00000000000000000e+000 );
00266 a[24] = lapack_make_complex_double( 0.00000000000000000e+000,
00267 0.00000000000000000e+000 );
00268 a[1] = lapack_make_complex_double( -7.86000000000000030e+000,
00269 -2.96000000000000000e+000 );
00270 a[9] = lapack_make_complex_double( -2.83000000000000010e+000,
00271 -2.99999999999999990e-002 );
00272 a[17] = lapack_make_complex_double( 0.00000000000000000e+000,
00273 0.00000000000000000e+000 );
00274 a[25] = lapack_make_complex_double( 0.00000000000000000e+000,
00275 0.00000000000000000e+000 );
00276 a[2] = lapack_make_complex_double( 5.27872480164079950e-001,
00277 -3.71466001482590570e-001 );
00278 a[10] = lapack_make_complex_double( -6.07839105668319330e-001,
00279 2.81079647893121950e-001 );
00280 a[18] = lapack_make_complex_double( 4.40790623673101220e+000,
00281 5.39912067679694110e+000 );
00282 a[26] = lapack_make_complex_double( 0.00000000000000000e+000,
00283 0.00000000000000000e+000 );
00284 a[3] = lapack_make_complex_double( 4.42558238872675090e-001,
00285 1.93648369829740290e-001 );
00286 a[11] = lapack_make_complex_double( -4.82282297518538240e-001,
00287 1.49893621910528460e-002 );
00288 a[19] = lapack_make_complex_double( -1.07082188009268430e-001,
00289 -3.15678086248845520e-001 );
00290 a[27] = lapack_make_complex_double( -2.09541488784005690e+000,
00291 -2.20113928144078570e+000 );
00292 }
00293 static void init_ipiv( lapack_int size, lapack_int *ipiv ) {
00294 lapack_int i;
00295 for( i = 0; i < size; i++ ) {
00296 ipiv[i] = 0;
00297 }
00298 ipiv[0] = -3;
00299 ipiv[1] = -3;
00300 ipiv[2] = 3;
00301 ipiv[3] = 4;
00302 }
00303 static void init_work( lapack_int size, lapack_complex_double *work ) {
00304 lapack_int i;
00305 for( i = 0; i < size; i++ ) {
00306 work[i] = lapack_make_complex_double( 0.0, 0.0 );
00307 }
00308 }
00309
00310
00311
00312 static int compare_zsytri( lapack_complex_double *a, lapack_complex_double *a_i,
00313 lapack_int info, lapack_int info_i, lapack_int lda,
00314 lapack_int n )
00315 {
00316 lapack_int i;
00317 int failed = 0;
00318 for( i = 0; i < lda*n; i++ ) {
00319 failed += compare_complex_doubles(a[i],a_i[i]);
00320 }
00321 failed += (info == info_i) ? 0 : 1;
00322 if( info != 0 || info_i != 0 ) {
00323 printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00324 }
00325
00326 return failed;
00327 }