32 USAGE(
"CUNGESV",
"N LDA NRHS LDB",
33 " - N : the size of the matrix\n"
34 " - LDA : leading dimension of the matrix A\n"
35 " - NRHS : number of RHS\n"
36 " - LDB : leading dimension of the RHS B\n");
40 int N = atoi(argv[0]);
41 int LDA = atoi(argv[1]);
42 int NRHS = atoi(argv[2]);
43 int LDB = atoi(argv[3]);
47 int info, info_solution;
50 int LDBxNRHS = LDB*NRHS;
58 if ( (!A1) || (!A2) || (!B1) || (!B2) ) {
59 printf(
"Out of Memory \n ");
63 eps = LAPACKE_dlamch_work(
'e');
70 LAPACKE_zlarnv_work(
IONE,
ISEED, LDAxN, A1);
71 for (i = 0; i < N; i++)
72 for (j = 0; j < N; j++)
73 A2[LDA*j+i] = A1[LDA*j+i] ;
76 LAPACKE_zlarnv_work(
IONE,
ISEED, LDBxNRHS, B1);
77 for (i = 0; i < N; i++)
78 for (j = 0; j < NRHS; j++)
79 B2[LDB*j+i] = B1[LDB*j+i] ;
82 printf(
"------ TESTS FOR PLASMA ZCUNGESV ROUTINE ------- \n");
83 printf(
" Size of the Matrix %d by %d\n", N, N);
85 printf(
" The matrix A is randomly generated for each test.\n");
86 printf(
"============\n");
87 printf(
" The relative machine precision (eps) is to be %e \n",eps);
88 printf(
" Computational tests pass if scaled residuals are less than 60.\n");
93 printf(
"PLASMA_zcposv is not completed: info = %d\n", info);
96 printf(
" Solution obtained with %d iterations\n", ITER);
99 info_solution =
check_solution(N, NRHS, A1, LDA, B1, B2, LDB, eps);
102 if (info_solution == 0) {
103 printf(
"***************************************************\n");
104 printf(
" ---- TESTING ZCUNGESV.................... PASSED !\n");
105 printf(
"***************************************************\n");
108 printf(
"************************************************\n");
109 printf(
" - TESTING ZCUNGESV .. FAILED !\n");
110 printf(
"************************************************\n");
113 free(A1); free(A2); free(B1); free(B2);
125 double Rnorm, Anorm, Xnorm, Bnorm, result;
127 double *work = (
double *)malloc(N*
sizeof(
double));
136 cblas_zgemm(
CblasColMajor,
CblasNoTrans,
CblasNoTrans, N, NRHS, N,
CBLAS_SADDR(alpha), A1, LDA, B2, LDB,
CBLAS_SADDR(beta), B1, LDB);
139 if (getenv(
"PLASMA_TESTING_VERBOSE"))
140 printf(
"||A||_oo=%f\n||X||_oo=%f\n||B||_oo=%f\n||A X - B||_oo=%e\n", Anorm, Xnorm, Bnorm, Rnorm );
142 result = Rnorm / ( (Anorm*Xnorm+Bnorm)*N*eps ) ;
143 printf(
"============\n");
144 printf(
"Checking the Residual of the solution \n");
145 printf(
"-- ||Ax-B||_oo/((||A||_oo||x||_oo+||B||_oo).N.eps) = %e \n", result);
147 if ( isnan(Xnorm) || isinf(Xnorm) || isnan(result) || isinf(result) || (result > 60.0) ) {
148 printf(
"-- The solution is suspicious ! \n");
152 printf(
"-- The solution is CORRECT ! \n");
158 return info_solution;