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_sopgtr( char *uplo, lapack_int *n, lapack_int *ldq );
00055 static void init_ap( lapack_int size, float *ap );
00056 static void init_tau( lapack_int size, float *tau );
00057 static void init_q( lapack_int size, float *q );
00058 static void init_work( lapack_int size, float *work );
00059 static int compare_sopgtr( float *q, float *q_i, lapack_int info,
00060 lapack_int info_i, lapack_int ldq, lapack_int n );
00061
00062 int main(void)
00063 {
00064
00065 char uplo, uplo_i;
00066 lapack_int n, n_i;
00067 lapack_int ldq, ldq_i;
00068 lapack_int ldq_r;
00069 lapack_int info, info_i;
00070 lapack_int i;
00071 int failed;
00072
00073
00074 float *ap = NULL, *ap_i = NULL;
00075 float *tau = NULL, *tau_i = NULL;
00076 float *q = NULL, *q_i = NULL;
00077 float *work = NULL, *work_i = NULL;
00078 float *q_save = NULL;
00079 float *ap_r = NULL;
00080 float *q_r = NULL;
00081
00082
00083 init_scalars_sopgtr( &uplo, &n, &ldq );
00084 ldq_r = n+2;
00085 uplo_i = uplo;
00086 n_i = n;
00087 ldq_i = ldq;
00088
00089
00090 ap = (float *)LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(float) );
00091 tau = (float *)LAPACKE_malloc( (n-1) * sizeof(float) );
00092 q = (float *)LAPACKE_malloc( ldq*n * sizeof(float) );
00093 work = (float *)LAPACKE_malloc( (n-1) * sizeof(float) );
00094
00095
00096 ap_i = (float *)LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(float) );
00097 tau_i = (float *)LAPACKE_malloc( (n-1) * sizeof(float) );
00098 q_i = (float *)LAPACKE_malloc( ldq*n * sizeof(float) );
00099 work_i = (float *)LAPACKE_malloc( (n-1) * sizeof(float) );
00100
00101
00102 q_save = (float *)LAPACKE_malloc( ldq*n * sizeof(float) );
00103
00104
00105 ap_r = (float *)LAPACKE_malloc( n*(n+1)/2 * sizeof(float) );
00106 q_r = (float *)LAPACKE_malloc( n*(n+2) * sizeof(float) );
00107
00108
00109 init_ap( (n*(n+1)/2), ap );
00110 init_tau( (n-1), tau );
00111 init_q( ldq*n, q );
00112 init_work( (n-1), work );
00113
00114
00115 for( i = 0; i < ldq*n; i++ ) {
00116 q_save[i] = q[i];
00117 }
00118
00119
00120 sopgtr_( &uplo, &n, ap, tau, q, &ldq, work, &info );
00121
00122
00123
00124 for( i = 0; i < (n*(n+1)/2); i++ ) {
00125 ap_i[i] = ap[i];
00126 }
00127 for( i = 0; i < (n-1); i++ ) {
00128 tau_i[i] = tau[i];
00129 }
00130 for( i = 0; i < ldq*n; i++ ) {
00131 q_i[i] = q_save[i];
00132 }
00133 for( i = 0; i < (n-1); i++ ) {
00134 work_i[i] = work[i];
00135 }
00136 info_i = LAPACKE_sopgtr_work( LAPACK_COL_MAJOR, uplo_i, n_i, ap_i, tau_i,
00137 q_i, ldq_i, work_i );
00138
00139 failed = compare_sopgtr( q, q_i, info, info_i, ldq, n );
00140 if( failed == 0 ) {
00141 printf( "PASSED: column-major middle-level interface to sopgtr\n" );
00142 } else {
00143 printf( "FAILED: column-major middle-level interface to sopgtr\n" );
00144 }
00145
00146
00147
00148 for( i = 0; i < (n*(n+1)/2); i++ ) {
00149 ap_i[i] = ap[i];
00150 }
00151 for( i = 0; i < (n-1); i++ ) {
00152 tau_i[i] = tau[i];
00153 }
00154 for( i = 0; i < ldq*n; i++ ) {
00155 q_i[i] = q_save[i];
00156 }
00157 for( i = 0; i < (n-1); i++ ) {
00158 work_i[i] = work[i];
00159 }
00160 info_i = LAPACKE_sopgtr( LAPACK_COL_MAJOR, uplo_i, n_i, ap_i, tau_i, q_i,
00161 ldq_i );
00162
00163 failed = compare_sopgtr( q, q_i, info, info_i, ldq, n );
00164 if( failed == 0 ) {
00165 printf( "PASSED: column-major high-level interface to sopgtr\n" );
00166 } else {
00167 printf( "FAILED: column-major high-level interface to sopgtr\n" );
00168 }
00169
00170
00171
00172 for( i = 0; i < (n*(n+1)/2); i++ ) {
00173 ap_i[i] = ap[i];
00174 }
00175 for( i = 0; i < (n-1); i++ ) {
00176 tau_i[i] = tau[i];
00177 }
00178 for( i = 0; i < ldq*n; i++ ) {
00179 q_i[i] = q_save[i];
00180 }
00181 for( i = 0; i < (n-1); i++ ) {
00182 work_i[i] = work[i];
00183 }
00184
00185 LAPACKE_spp_trans( LAPACK_COL_MAJOR, uplo, n, ap_i, ap_r );
00186 LAPACKE_sge_trans( LAPACK_COL_MAJOR, n, n, q_i, ldq, q_r, n+2 );
00187 info_i = LAPACKE_sopgtr_work( LAPACK_ROW_MAJOR, uplo_i, n_i, ap_r, tau_i,
00188 q_r, ldq_r, work_i );
00189
00190 LAPACKE_sge_trans( LAPACK_ROW_MAJOR, n, n, q_r, n+2, q_i, ldq );
00191
00192 failed = compare_sopgtr( q, q_i, info, info_i, ldq, n );
00193 if( failed == 0 ) {
00194 printf( "PASSED: row-major middle-level interface to sopgtr\n" );
00195 } else {
00196 printf( "FAILED: row-major middle-level interface to sopgtr\n" );
00197 }
00198
00199
00200
00201 for( i = 0; i < (n*(n+1)/2); i++ ) {
00202 ap_i[i] = ap[i];
00203 }
00204 for( i = 0; i < (n-1); i++ ) {
00205 tau_i[i] = tau[i];
00206 }
00207 for( i = 0; i < ldq*n; i++ ) {
00208 q_i[i] = q_save[i];
00209 }
00210 for( i = 0; i < (n-1); i++ ) {
00211 work_i[i] = work[i];
00212 }
00213
00214
00215 LAPACKE_spp_trans( LAPACK_COL_MAJOR, uplo, n, ap_i, ap_r );
00216 LAPACKE_sge_trans( LAPACK_COL_MAJOR, n, n, q_i, ldq, q_r, n+2 );
00217 info_i = LAPACKE_sopgtr( LAPACK_ROW_MAJOR, uplo_i, n_i, ap_r, tau_i, q_r,
00218 ldq_r );
00219
00220 LAPACKE_sge_trans( LAPACK_ROW_MAJOR, n, n, q_r, n+2, q_i, ldq );
00221
00222 failed = compare_sopgtr( q, q_i, info, info_i, ldq, n );
00223 if( failed == 0 ) {
00224 printf( "PASSED: row-major high-level interface to sopgtr\n" );
00225 } else {
00226 printf( "FAILED: row-major high-level interface to sopgtr\n" );
00227 }
00228
00229
00230 if( ap != NULL ) {
00231 LAPACKE_free( ap );
00232 }
00233 if( ap_i != NULL ) {
00234 LAPACKE_free( ap_i );
00235 }
00236 if( ap_r != NULL ) {
00237 LAPACKE_free( ap_r );
00238 }
00239 if( tau != NULL ) {
00240 LAPACKE_free( tau );
00241 }
00242 if( tau_i != NULL ) {
00243 LAPACKE_free( tau_i );
00244 }
00245 if( q != NULL ) {
00246 LAPACKE_free( q );
00247 }
00248 if( q_i != NULL ) {
00249 LAPACKE_free( q_i );
00250 }
00251 if( q_r != NULL ) {
00252 LAPACKE_free( q_r );
00253 }
00254 if( q_save != NULL ) {
00255 LAPACKE_free( q_save );
00256 }
00257 if( work != NULL ) {
00258 LAPACKE_free( work );
00259 }
00260 if( work_i != NULL ) {
00261 LAPACKE_free( work_i );
00262 }
00263
00264 return 0;
00265 }
00266
00267
00268 static void init_scalars_sopgtr( char *uplo, lapack_int *n, lapack_int *ldq )
00269 {
00270 *uplo = 'L';
00271 *n = 4;
00272 *ldq = 8;
00273
00274 return;
00275 }
00276
00277
00278 static void init_ap( lapack_int size, float *ap ) {
00279 lapack_int i;
00280 for( i = 0; i < size; i++ ) {
00281 ap[i] = 0;
00282 }
00283 ap[0] = 2.069999933e+000;
00284 ap[1] = -5.825753212e+000;
00285 ap[2] = 4.331793189e-001;
00286 ap[3] = -1.186086312e-001;
00287 ap[4] = 1.474093199e+000;
00288 ap[5] = 2.624044895e+000;
00289 ap[6] = 8.062880635e-001;
00290 ap[7] = -6.491593122e-001;
00291 ap[8] = 9.162727594e-001;
00292 ap[9] = -1.694934368e+000;
00293 }
00294 static void init_tau( lapack_int size, float *tau ) {
00295 lapack_int i;
00296 for( i = 0; i < size; i++ ) {
00297 tau[i] = 0;
00298 }
00299 tau[0] = 1.664291739e+000;
00300 tau[1] = 1.212047458e+000;
00301 tau[2] = 0.000000000e+000;
00302 }
00303 static void init_q( lapack_int size, float *q ) {
00304 lapack_int i;
00305 for( i = 0; i < size; i++ ) {
00306 q[i] = 0;
00307 }
00308 }
00309 static void init_work( lapack_int size, float *work ) {
00310 lapack_int i;
00311 for( i = 0; i < size; i++ ) {
00312 work[i] = 0;
00313 }
00314 }
00315
00316
00317
00318 static int compare_sopgtr( float *q, float *q_i, lapack_int info,
00319 lapack_int info_i, lapack_int ldq, lapack_int n )
00320 {
00321 lapack_int i;
00322 int failed = 0;
00323 for( i = 0; i < ldq*n; i++ ) {
00324 failed += compare_floats(q[i],q_i[i]);
00325 }
00326 failed += (info == info_i) ? 0 : 1;
00327 if( info != 0 || info_i != 0 ) {
00328 printf( "info=%d, info_i=%d\n",(int)info,(int)info_i );
00329 }
00330
00331 return failed;
00332 }