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_zpptri( char *uplo, lapack_int *n );
00055 static void init_ap( lapack_int size, lapack_complex_double *ap );
00056 static int compare_zpptri( lapack_complex_double *ap,
00057 lapack_complex_double *ap_i, lapack_int info,
00058 lapack_int info_i, lapack_int n );
00059
00060 int main(void)
00061 {
00062
00063 char uplo, uplo_i;
00064 lapack_int n, n_i;
00065 lapack_int info, info_i;
00066 lapack_int i;
00067 int failed;
00068
00069
00070 lapack_complex_double *ap = NULL, *ap_i = NULL;
00071 lapack_complex_double *ap_save = NULL;
00072 lapack_complex_double *ap_r = NULL;
00073
00074
00075 init_scalars_zpptri( &uplo, &n );
00076 uplo_i = uplo;
00077 n_i = n;
00078
00079
00080 ap = (lapack_complex_double *)
00081 LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(lapack_complex_double) );
00082
00083
00084 ap_i = (lapack_complex_double *)
00085 LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(lapack_complex_double) );
00086
00087
00088 ap_save = (lapack_complex_double *)
00089 LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(lapack_complex_double) );
00090
00091
00092 ap_r = (lapack_complex_double *)
00093 LAPACKE_malloc( n*(n+1)/2 * sizeof(lapack_complex_double) );
00094
00095
00096 init_ap( (n*(n+1)/2), ap );
00097
00098
00099 for( i = 0; i < (n*(n+1)/2); i++ ) {
00100 ap_save[i] = ap[i];
00101 }
00102
00103
00104 zpptri_( &uplo, &n, ap, &info );
00105
00106
00107
00108 for( i = 0; i < (n*(n+1)/2); i++ ) {
00109 ap_i[i] = ap_save[i];
00110 }
00111 info_i = LAPACKE_zpptri_work( LAPACK_COL_MAJOR, uplo_i, n_i, ap_i );
00112
00113 failed = compare_zpptri( ap, ap_i, info, info_i, n );
00114 if( failed == 0 ) {
00115 printf( "PASSED: column-major middle-level interface to zpptri\n" );
00116 } else {
00117 printf( "FAILED: column-major middle-level interface to zpptri\n" );
00118 }
00119
00120
00121
00122 for( i = 0; i < (n*(n+1)/2); i++ ) {
00123 ap_i[i] = ap_save[i];
00124 }
00125 info_i = LAPACKE_zpptri( LAPACK_COL_MAJOR, uplo_i, n_i, ap_i );
00126
00127 failed = compare_zpptri( ap, ap_i, info, info_i, n );
00128 if( failed == 0 ) {
00129 printf( "PASSED: column-major high-level interface to zpptri\n" );
00130 } else {
00131 printf( "FAILED: column-major high-level interface to zpptri\n" );
00132 }
00133
00134
00135
00136 for( i = 0; i < (n*(n+1)/2); i++ ) {
00137 ap_i[i] = ap_save[i];
00138 }
00139
00140 LAPACKE_zpp_trans( LAPACK_COL_MAJOR, uplo, n, ap_i, ap_r );
00141 info_i = LAPACKE_zpptri_work( LAPACK_ROW_MAJOR, uplo_i, n_i, ap_r );
00142
00143 LAPACKE_zpp_trans( LAPACK_ROW_MAJOR, uplo, n, ap_r, ap_i );
00144
00145 failed = compare_zpptri( ap, ap_i, info, info_i, n );
00146 if( failed == 0 ) {
00147 printf( "PASSED: row-major middle-level interface to zpptri\n" );
00148 } else {
00149 printf( "FAILED: row-major middle-level interface to zpptri\n" );
00150 }
00151
00152
00153
00154 for( i = 0; i < (n*(n+1)/2); i++ ) {
00155 ap_i[i] = ap_save[i];
00156 }
00157
00158
00159 LAPACKE_zpp_trans( LAPACK_COL_MAJOR, uplo, n, ap_i, ap_r );
00160 info_i = LAPACKE_zpptri( LAPACK_ROW_MAJOR, uplo_i, n_i, ap_r );
00161
00162 LAPACKE_zpp_trans( LAPACK_ROW_MAJOR, uplo, n, ap_r, ap_i );
00163
00164 failed = compare_zpptri( ap, ap_i, info, info_i, n );
00165 if( failed == 0 ) {
00166 printf( "PASSED: row-major high-level interface to zpptri\n" );
00167 } else {
00168 printf( "FAILED: row-major high-level interface to zpptri\n" );
00169 }
00170
00171
00172 if( ap != NULL ) {
00173 LAPACKE_free( ap );
00174 }
00175 if( ap_i != NULL ) {
00176 LAPACKE_free( ap_i );
00177 }
00178 if( ap_r != NULL ) {
00179 LAPACKE_free( ap_r );
00180 }
00181 if( ap_save != NULL ) {
00182 LAPACKE_free( ap_save );
00183 }
00184
00185 return 0;
00186 }
00187
00188
00189 static void init_scalars_zpptri( char *uplo, lapack_int *n )
00190 {
00191 *uplo = 'L';
00192 *n = 4;
00193
00194 return;
00195 }
00196
00197
00198 static void init_ap( lapack_int size, lapack_complex_double *ap ) {
00199 lapack_int i;
00200 for( i = 0; i < size; i++ ) {
00201 ap[i] = lapack_make_complex_double( 0.0, 0.0 );
00202 }
00203 ap[0] = lapack_make_complex_double( 1.79722007556114290e+000,
00204 0.00000000000000000e+000 );
00205 ap[1] = lapack_make_complex_double( 8.40186474952732460e-001,
00206 1.06831657742334190e+000 );
00207 ap[2] = lapack_make_complex_double( 1.05718827974184860e+000,
00208 -4.67388502622712030e-001 );
00209 ap[3] = lapack_make_complex_double( 2.33694251311356020e-001,
00210 -1.39103721018664310e+000 );
00211 ap[4] = lapack_make_complex_double( 1.31635343950968520e+000,
00212 0.00000000000000000e+000 );
00213 ap[5] = lapack_make_complex_double( -4.70174947010632950e-001,
00214 3.13065815599946400e-001 );
00215 ap[6] = lapack_make_complex_double( 8.33525092394419580e-002,
00216 3.67607144303747430e-002 );
00217 ap[7] = lapack_make_complex_double( 1.56039297713712430e+000,
00218 0.00000000000000000e+000 );
00219 ap[8] = lapack_make_complex_double( 9.35961733792340160e-001,
00220 9.89969219281573890e-001 );
00221 ap[9] = lapack_make_complex_double( 6.60333297365588770e-001,
00222 0.00000000000000000e+000 );
00223 }
00224
00225
00226
00227 static int compare_zpptri( lapack_complex_double *ap,
00228 lapack_complex_double *ap_i, lapack_int info,
00229 lapack_int info_i, lapack_int n )
00230 {
00231 lapack_int i;
00232 int failed = 0;
00233 for( i = 0; i < (n*(n+1)/2); i++ ) {
00234 failed += compare_complex_doubles(ap[i],ap_i[i]);
00235 }
00236 failed += (info == info_i) ? 0 : 1;
00237 if( info != 0 || info_i != 0 ) {
00238 printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00239 }
00240
00241 return failed;
00242 }