28 static int check_solution(
int,
int ,
double *,
int,
double *,
double *,
int,
double);
34 USAGE(
"CGESV",
"N LDA NRHS LDB",
35 " - N : the size of the matrix\n"
36 " - LDA : leading dimension of the matrix A\n"
37 " - NRHS : number of RHS\n"
38 " - LDB : leading dimension of the matrix B\n");
42 int N = atoi(argv[0]);
43 int LDA = atoi(argv[1]);
44 int NRHS = atoi(argv[2]);
45 int LDB = atoi(argv[3]);
48 int info, info_solution;
51 int LDBxNRHS = LDB*NRHS;
53 double *A1 = (
double *)malloc(LDA*N*
sizeof(
double));
54 double *A2 = (
double *)malloc(LDA*N*
sizeof(
double));
55 double *B1 = (
double *)malloc(LDB*NRHS*
sizeof(
double));
56 double *B2 = (
double *)malloc(LDB*NRHS*
sizeof(
double));
57 int *ipiv = (
int *)malloc(N*
sizeof(
int));
60 if ( (!A1) || (!A2) || (!B1) || (!B2) ) {
61 printf(
"Out of Memory \n ");
65 eps = LAPACKE_dlamch_work(
'e');
72 LAPACKE_dlarnv_work(
IONE,
ISEED, LDAxN, A1);
73 for ( i = 0; i < N; i++)
74 for ( j = 0; j < N; j++)
75 A2[LDA*j+i] = A1[LDA*j+i];
78 LAPACKE_dlarnv_work(
IONE,
ISEED, LDBxNRHS, B1);
79 for ( i = 0; i < N; i++)
80 for ( j = 0; j < NRHS; j++)
81 B2[LDB*j+i] = B1[LDB*j+i];
84 printf(
"------ TESTS FOR PLASMA DSGESV ROUTINE ------- \n");
85 printf(
" Size of the Matrix %d by %d\n", N, N);
87 printf(
" The matrix A is randomly generated for each test.\n");
88 printf(
"============\n");
89 printf(
" The relative machine precision (eps) is to be %e \n", eps);
90 printf(
" Computational tests pass if scaled residuals are less than 60.\n");
93 info =
PLASMA_dsgesv(N, NRHS, A2, LDA, ipiv, B1, LDB, B2, LDB, &ITER);
95 printf(
"PLASMA_dsgesv is not completed: info = %d\n", info);
98 printf(
" Solution obtained with %d iterations\n", ITER);
101 info_solution =
check_solution(N, NRHS, A1, LDA, B1, B2, LDB, eps);
104 if ((info_solution == 0)){
105 printf(
"***************************************************\n");
106 printf(
" ---- TESTING DSGESV ..................... PASSED !\n");
107 printf(
"***************************************************\n");
110 printf(
"************************************************\n");
111 printf(
" ---- TESTING DSGESV ... FAILED !\n");
112 printf(
"************************************************\n");
115 free(A1); free(A2); free(B1); free(B2); free(ipiv);
123 static int check_solution(
int N,
int NRHS,
double *A1,
int LDA,
double *B1,
double *B2,
int LDB,
double eps )
126 double Rnorm, Anorm, Xnorm, Bnorm;
128 double *work = (
double *)malloc(N*(
sizeof *work));
138 cblas_dgemm(
CblasColMajor,
CblasNoTrans,
CblasNoTrans, N, NRHS, N, (alpha), A1, LDA, B2, LDB, (beta), B1, LDB);
141 result = Rnorm/((Anorm*Xnorm+Bnorm)*N*eps);
143 if (getenv(
"PLASMA_TESTING_VERBOSE"))
144 printf(
"||A||_oo=%f\n||X||_oo=%f\n||B||_oo=%f\n||A X - B||_oo=%e\n", Anorm, Xnorm, Bnorm, Rnorm );
146 printf(
"============\n");
147 printf(
"Checking the Residual of the solution \n");
148 printf(
"-- ||Ax-B||_oo/((||A||_oo||x||_oo+||B||_oo).N.eps) = %e \n", result);
150 if ( isnan(Xnorm) || isinf(Xnorm) || isnan(result) || isinf(result) || (result > 60.0) ){
151 printf(
"-- The solution is suspicious ! \n");
155 printf(
"-- The solution is CORRECT ! \n");
161 return info_solution;