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