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_cpptri( char *uplo, lapack_int *n );
00055 static void init_ap( lapack_int size, lapack_complex_float *ap );
00056 static int compare_cpptri( lapack_complex_float *ap, lapack_complex_float *ap_i,
00057 lapack_int info, lapack_int info_i, lapack_int n );
00058
00059 int main(void)
00060 {
00061
00062 char uplo, uplo_i;
00063 lapack_int n, n_i;
00064 lapack_int info, info_i;
00065 lapack_int i;
00066 int failed;
00067
00068
00069 lapack_complex_float *ap = NULL, *ap_i = NULL;
00070 lapack_complex_float *ap_save = NULL;
00071 lapack_complex_float *ap_r = NULL;
00072
00073
00074 init_scalars_cpptri( &uplo, &n );
00075 uplo_i = uplo;
00076 n_i = n;
00077
00078
00079 ap = (lapack_complex_float *)
00080 LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(lapack_complex_float) );
00081
00082
00083 ap_i = (lapack_complex_float *)
00084 LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(lapack_complex_float) );
00085
00086
00087 ap_save = (lapack_complex_float *)
00088 LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(lapack_complex_float) );
00089
00090
00091 ap_r = (lapack_complex_float *)
00092 LAPACKE_malloc( n*(n+1)/2 * sizeof(lapack_complex_float) );
00093
00094
00095 init_ap( (n*(n+1)/2), ap );
00096
00097
00098 for( i = 0; i < (n*(n+1)/2); i++ ) {
00099 ap_save[i] = ap[i];
00100 }
00101
00102
00103 cpptri_( &uplo, &n, ap, &info );
00104
00105
00106
00107 for( i = 0; i < (n*(n+1)/2); i++ ) {
00108 ap_i[i] = ap_save[i];
00109 }
00110 info_i = LAPACKE_cpptri_work( LAPACK_COL_MAJOR, uplo_i, n_i, ap_i );
00111
00112 failed = compare_cpptri( ap, ap_i, info, info_i, n );
00113 if( failed == 0 ) {
00114 printf( "PASSED: column-major middle-level interface to cpptri\n" );
00115 } else {
00116 printf( "FAILED: column-major middle-level interface to cpptri\n" );
00117 }
00118
00119
00120
00121 for( i = 0; i < (n*(n+1)/2); i++ ) {
00122 ap_i[i] = ap_save[i];
00123 }
00124 info_i = LAPACKE_cpptri( LAPACK_COL_MAJOR, uplo_i, n_i, ap_i );
00125
00126 failed = compare_cpptri( ap, ap_i, info, info_i, n );
00127 if( failed == 0 ) {
00128 printf( "PASSED: column-major high-level interface to cpptri\n" );
00129 } else {
00130 printf( "FAILED: column-major high-level interface to cpptri\n" );
00131 }
00132
00133
00134
00135 for( i = 0; i < (n*(n+1)/2); i++ ) {
00136 ap_i[i] = ap_save[i];
00137 }
00138
00139 LAPACKE_cpp_trans( LAPACK_COL_MAJOR, uplo, n, ap_i, ap_r );
00140 info_i = LAPACKE_cpptri_work( LAPACK_ROW_MAJOR, uplo_i, n_i, ap_r );
00141
00142 LAPACKE_cpp_trans( LAPACK_ROW_MAJOR, uplo, n, ap_r, ap_i );
00143
00144 failed = compare_cpptri( ap, ap_i, info, info_i, n );
00145 if( failed == 0 ) {
00146 printf( "PASSED: row-major middle-level interface to cpptri\n" );
00147 } else {
00148 printf( "FAILED: row-major middle-level interface to cpptri\n" );
00149 }
00150
00151
00152
00153 for( i = 0; i < (n*(n+1)/2); i++ ) {
00154 ap_i[i] = ap_save[i];
00155 }
00156
00157
00158 LAPACKE_cpp_trans( LAPACK_COL_MAJOR, uplo, n, ap_i, ap_r );
00159 info_i = LAPACKE_cpptri( LAPACK_ROW_MAJOR, uplo_i, n_i, ap_r );
00160
00161 LAPACKE_cpp_trans( LAPACK_ROW_MAJOR, uplo, n, ap_r, ap_i );
00162
00163 failed = compare_cpptri( ap, ap_i, info, info_i, n );
00164 if( failed == 0 ) {
00165 printf( "PASSED: row-major high-level interface to cpptri\n" );
00166 } else {
00167 printf( "FAILED: row-major high-level interface to cpptri\n" );
00168 }
00169
00170
00171 if( ap != NULL ) {
00172 LAPACKE_free( ap );
00173 }
00174 if( ap_i != NULL ) {
00175 LAPACKE_free( ap_i );
00176 }
00177 if( ap_r != NULL ) {
00178 LAPACKE_free( ap_r );
00179 }
00180 if( ap_save != NULL ) {
00181 LAPACKE_free( ap_save );
00182 }
00183
00184 return 0;
00185 }
00186
00187
00188 static void init_scalars_cpptri( char *uplo, lapack_int *n )
00189 {
00190 *uplo = 'L';
00191 *n = 4;
00192
00193 return;
00194 }
00195
00196
00197 static void init_ap( lapack_int size, lapack_complex_float *ap ) {
00198 lapack_int i;
00199 for( i = 0; i < size; i++ ) {
00200 ap[i] = lapack_make_complex_float( 0.0f, 0.0f );
00201 }
00202 ap[0] = lapack_make_complex_float( 1.797220111e+000, 0.000000000e+000 );
00203 ap[1] = lapack_make_complex_float( 8.401864767e-001, 1.068316579e+000 );
00204 ap[2] = lapack_make_complex_float( 1.057188272e+000, -4.673885107e-001 );
00205 ap[3] = lapack_make_complex_float( 2.336942554e-001, -1.391037226e+000 );
00206 ap[4] = lapack_make_complex_float( 1.316353440e+000, 0.000000000e+000 );
00207 ap[5] = lapack_make_complex_float( -4.701749682e-001, 3.130658865e-001 );
00208 ap[6] = lapack_make_complex_float( 8.335255831e-002, 3.676066920e-002 );
00209 ap[7] = lapack_make_complex_float( 1.560392976e+000, 0.000000000e+000 );
00210 ap[8] = lapack_make_complex_float( 9.359616637e-001, 9.899691939e-001 );
00211 ap[9] = lapack_make_complex_float( 6.603332758e-001, 0.000000000e+000 );
00212 }
00213
00214
00215
00216 static int compare_cpptri( lapack_complex_float *ap, lapack_complex_float *ap_i,
00217 lapack_int info, lapack_int info_i, lapack_int n )
00218 {
00219 lapack_int i;
00220 int failed = 0;
00221 for( i = 0; i < (n*(n+1)/2); i++ ) {
00222 failed += compare_complex_floats(ap[i],ap_i[i]);
00223 }
00224 failed += (info == info_i) ? 0 : 1;
00225 if( info != 0 || info_i != 0 ) {
00226 printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00227 }
00228
00229 return failed;
00230 }