34 USAGE(
"GETRI",
"N LDA",
35 " - N : the size of the matrix\n"
36 " - LDA : leading dimension of the matrix A\n");
40 int N = atoi(argv[0]);
41 int LDA = atoi(argv[1]);
43 int info_inverse, info_factorization;
49 float *D = (
float *)malloc(LDA*
sizeof(
float));
50 int *
IPIV = (
int *)malloc(N*
sizeof(
int));
53 if ( (!A1) || (!A2) || (!IPIV) ){
54 printf(
"Out of Memory \n ");
58 eps = LAPACKE_slamch_work(
'e');
66 for ( i = 0; i < N; i++)
67 for ( j = 0; j < N; j++)
68 A2[LDA*j+i] = A1[LDA*j+i];
71 printf(
"------ TESTS FOR PLASMA CGETRI ROUTINE ------- \n");
72 printf(
" Size of the Matrix %d by %d\n", N, N);
74 printf(
" The matrix A is randomly generated for each test.\n");
75 printf(
"============\n");
76 printf(
" The relative machine precision (eps) is to be %e \n", eps);
77 printf(
" Computational tests pass if scaled residuals are less than 60.\n");
89 info_inverse = check_inverse(N, A1, A2, LDA, IPIV, eps);
91 if ( (info_inverse == 0) && (info_factorization == 0) ) {
92 printf(
"***************************************************\n");
93 printf(
" ---- TESTING CGETRI ..................... PASSED !\n");
94 printf(
"***************************************************\n");
97 printf(
"***************************************************\n");
98 printf(
" - TESTING CGETRI ... FAILED !\n");
99 printf(
"***************************************************\n");
102 free(A1); free(A2); free(IPIV); free(WORK); free(D);
113 int info_factorization;
114 float Rnorm, Anorm, Xnorm, Bnorm, result;
116 float *work = (
float *)malloc(N*
sizeof(
float));
124 LAPACKE_clarnv_work(1,
ISEED, LDA, x);
125 LAPACKE_clacpy_work(LAPACK_COL_MAJOR,
'A', N, 1, x, LDA, b, LDA);
134 alpha, A1, LDA, x, LDA, beta, b, LDA);
138 if (getenv(
"PLASMA_TESTING_VERBOSE"))
139 printf(
"||A||_oo=%f\n||X||_oo=%f\n||B||_oo=%f\n||A X - B||_oo=%e\n", Anorm, Xnorm, Bnorm, Rnorm );
141 result = Rnorm / ( (Anorm*Xnorm+Bnorm)*N*eps ) ;
142 printf(
"============\n");
143 printf(
"Checking the Residual of the solution \n");
144 printf(
"-- ||Ax-B||_oo/((||A||_oo||x||_oo+||B||_oo).N.eps) = %e \n", result);
146 if ( isnan(Xnorm) || isinf(Xnorm) || isnan(result) || isinf(result) || (result > 60.0) ) {
147 printf(
"-- The factorization is suspicious ! \n");
148 info_factorization = 1;
151 printf(
"-- The factorization is CORRECT ! \n");
152 info_factorization = 0;
154 free(x); free(b); free(work);
156 return info_factorization;
168 float Rnorm, Anorm, Ainvnorm, result;
170 float *
W = (
float *)malloc(N*
sizeof(
float));
177 PLASMA_cgemm(
PlasmaNoTrans,
PlasmaNoTrans, N, N, N, alpha, A2, LDA, A1, LDA, beta, work, N);
181 *(work+i+i*N) = *(work+i+i*N) + zone;
187 if (getenv(
"PLASMA_TESTING_VERBOSE"))
188 printf(
"||A||_1=%f\n||Ainv||_1=%f\n||Id - A*Ainv||_1=%e\n", Anorm, Ainvnorm, Rnorm );
190 result = Rnorm / ( (Anorm*Ainvnorm)*N*eps ) ;
191 printf(
"============\n");
192 printf(
"Checking the Residual of the inverse \n");
193 printf(
"-- ||Id - A*Ainv||_1/((||A||_1||Ainv||_1).N.eps) = %e \n", result);
195 if ( isnan(Ainvnorm) || isinf(Ainvnorm) || isnan(result) || isinf(result) || (result > 60.0) ) {
196 printf(
"-- The inverse is suspicious ! \n");
200 printf(
"-- The inverse is CORRECT ! \n");