54 BLAS_error(
char *rname,
int err,
int val,
int x) {
55 fprintf( stderr,
"%s %d %d %d\n", rname, err, val, x );
63 int i, j;
float anorm, v;
64 char rname[] =
"BLAS_zge_norm";
66 if (order !=
blas_colmajor) BLAS_error( rname, -1, order, 0 );
78 anorm = sqrt( anorm );
81 for (i = 0; i < m; ++i) {
83 for (j = 0; j < n; ++j) {
84 v +=
cabs( a[i + j * lda] );
90 BLAS_error( rname, -2, norm, 0 );
94 if (res) *res = anorm;
99 BLAS_dpow_di(
double x,
int n) {
107 for (; n; n >>= 1, x *= x) {
118 double eps = 1.0, r = 1.0, o = 1.0, b = 2.0;
119 int t = 53, l = 1024, m = -1021;
120 char rname[] =
"BLAS_dfpinfo";
122 if ((
sizeof eps) ==
sizeof(
float)) {
133 eps = BLAS_dpow_di( b, -t );
135 r = BLAS_dpow_di( b, m-1 );
139 o = (o * BLAS_dpow_di( b, l-1 )) * b;
145 BLAS_error( rname, -1, cmach, 0 );
157 USAGE(
"GESV_INCPIV",
"N LDA NRHS LDB",
158 " - N : the size of the matrix\n"
159 " - LDA : leading dimension of the matrix A\n"
160 " - NRHS : number of RHS\n"
161 " - LDB : leading dimension of the matrix B\n");
165 int N = atoi(argv[0]);
166 int LDA = atoi(argv[1]);
167 int NRHS = atoi(argv[2]);
168 int LDB = atoi(argv[3]);
173 int LDBxNRHS = LDB*NRHS;
183 if ( (!A1) || (!A2)|| (!B1) || (!B2) ) {
184 printf(
"Out of Memory \n ");
195 LAPACKE_zlarnv_work(
IONE,
ISEED, LDAxN, A1);
196 for ( i = 0; i < N; i++)
197 for ( j = 0; j < N; j++)
198 A2[LDA*j+i] = A1[LDA*j+i];
201 LAPACKE_zlarnv_work(
IONE,
ISEED, LDBxNRHS, B1);
202 for ( i = 0; i < N; i++)
203 for ( j = 0; j < NRHS; j++)
204 B2[LDB*j+i] = B1[LDB*j+i];
211 printf(
"------ TESTS FOR PLASMA INCPIV ZGESV ROUTINE ------- \n");
212 printf(
" Size of the Matrix %d by %d\n", N, N);
214 printf(
" The matrix A is randomly generated for each test.\n");
215 printf(
"============\n");
216 printf(
" The relative machine precision (eps) is to be %e \n", eps);
217 printf(
" Computational tests pass if scaled residuals are less than 60.\n");
220 info_solution =
check_solution(N, NRHS, A1, LDA, B1, B2, LDB, eps);
222 if ((info_solution == 0)){
223 printf(
"***************************************************\n");
224 printf(
" ---- TESTING INCPIV ZGESV ............... PASSED !\n");
225 printf(
"***************************************************\n");
228 printf(
"************************************************\n");
229 printf(
" - TESTING INCPIV ZGESV ... FAILED !\n");
230 printf(
"************************************************\n");
238 LAPACKE_zlarnv_work(
IONE,
ISEED, LDAxN, A1);
239 for ( i = 0; i < N; i++)
240 for ( j = 0; j < N; j++)
241 A2[LDA*j+i] = A1[LDA*j+i];
244 LAPACKE_zlarnv_work(
IONE,
ISEED, LDBxNRHS, B1);
245 for ( i = 0; i < N; i++)
246 for ( j = 0; j < NRHS; j++)
247 B2[LDB*j+i] = B1[LDB*j+i];
254 printf(
"------ TESTS FOR PLASMA ZGETRF + ZGETRS ROUTINE ------- \n");
255 printf(
" Size of the Matrix %d by %d\n", N, N);
257 printf(
" The matrix A is randomly generated for each test.\n");
258 printf(
"============\n");
259 printf(
" The relative machine precision (eps) is to be %e \n", eps);
260 printf(
" Computational tests pass if scaled residuals are less than 60.\n");
263 info_solution =
check_solution(N, NRHS, A1, LDA, B1, B2, LDB, eps);
265 if ((info_solution == 0)){
266 printf(
"***************************************************\n");
267 printf(
" ---- TESTING INCPIV ZGETRF + ZGETRS ..... PASSED !\n");
268 printf(
"***************************************************\n");
271 printf(
"***************************************************\n");
272 printf(
" - TESTING INCPIV ZGETRF + ZGETRS ... FAILED !\n");
273 printf(
"***************************************************\n");
281 LAPACKE_zlarnv_work(
IONE,
ISEED, LDAxN, A1);
282 for ( i = 0; i < N; i++)
283 for ( j = 0; j < N; j++)
284 A2[LDA*j+i] = A1[LDA*j+i];
287 LAPACKE_zlarnv_work(
IONE,
ISEED, LDBxNRHS, B1);
288 for ( i = 0; i < N; i++)
289 for ( j = 0; j < NRHS; j++)
290 B2[LDB*j+i] = B1[LDB*j+i];
296 N, NRHS, 1.0, A2, LDA, B2, LDB);
299 printf(
"------ TESTS FOR PLASMA INCPIV ZGETRF + ZTRSMPL + ZTRSM ROUTINE ------- \n");
300 printf(
" Size of the Matrix %d by %d\n", N, N);
302 printf(
" The matrix A is randomly generated for each test.\n");
303 printf(
"============\n");
304 printf(
" The relative machine precision (eps) is to be %e \n", eps);
305 printf(
" Computational tests pass if scaled residuals are less than 60.\n");
308 info_solution =
check_solution(N, NRHS, A1, LDA, B1, B2, LDB, eps);
310 if ((info_solution == 0)){
311 printf(
"***************************************************\n");
312 printf(
" ---- TESTING INCPIV ZGETRF + ZTRSMPL + ZTRSM ... PASSED !\n");
313 printf(
"***************************************************\n");
316 printf(
"**************************************************\n");
317 printf(
" - TESTING INCPIV ZGETRF + ZTRSMPL + ZTRSM ... FAILED !\n");
318 printf(
"**************************************************\n");
321 free(A1); free(A2); free(B1); free(B2); free(IPIV); free(L);
333 double Rnorm, Anorm, Xnorm, Bnorm, result;
335 double *work = (
double *)malloc(N*
sizeof(
double));
344 cblas_zgemm(
CblasColMajor,
CblasNoTrans,
CblasNoTrans, N, NRHS, N,
CBLAS_SADDR(alpha), A1, LDA, B2, LDB,
CBLAS_SADDR(beta), B1, LDB);
347 if (getenv(
"PLASMA_TESTING_VERBOSE"))
348 printf(
"||A||_oo=%f\n||X||_oo=%f\n||B||_oo=%f\n||A X - B||_oo=%e\n", Anorm, Xnorm, Bnorm, Rnorm );
350 result = Rnorm / ( (Anorm*Xnorm+Bnorm)*N*eps ) ;
351 printf(
"============\n");
352 printf(
"Checking the Residual of the solution \n");
353 printf(
"-- ||Ax-B||_oo/((||A||_oo||x||_oo+||B||_oo).N.eps) = %e \n", result);
355 if ( isnan(Xnorm) || isinf(Xnorm) || isnan(result) || isinf(result) || (result > 60.0) ) {
356 printf(
"-- The solution is suspicious ! \n");
360 printf(
"-- The solution is CORRECT ! \n");
364 return info_solution;