30 int M,
int N,
float alpha,
32 float *Bref,
float *Bplasma,
int LDB);
38 USAGE(
"TRSM",
"alpha M N LDA LDB",
39 " - alpha : alpha coefficient\n"
40 " - M : number of rows of matrices B\n"
41 " - N : number of columns of matrices B\n"
42 " - LDA : leading dimension of matrix A\n"
43 " - LDB : leading dimension of matrix B\n");
47 float alpha = (float) atol(argv[0]);
48 int M = atoi(argv[1]);
49 int N = atoi(argv[2]);
50 int LDA = atoi(argv[3]);
51 int LDB = atoi(argv[4]);
56 int LDAxM = LDA*
max(M,N);
57 int LDBxN = LDB*
max(M,N);
59 float *
A = (
float *)malloc(LDAxM*
sizeof(
float));
60 float *
B = (
float *)malloc(LDBxN*
sizeof(
float));
61 float *Binit = (
float *)malloc(LDBxN*
sizeof(
float));
62 float *Bfinal = (
float *)malloc(LDBxN*
sizeof(
float));
65 if ( (!A) || (!
B) || (!Binit) || (!Bfinal)){
66 printf(
"Out of Memory \n ");
70 eps = LAPACKE_slamch_work(
'e');
73 printf(
"------ TESTS FOR PLASMA STRSM ROUTINE ------- \n");
74 printf(
" Size of the Matrix B : %d by %d\n", M, N);
76 printf(
" The matrix A is randomly generated for each test.\n");
77 printf(
"============\n");
78 printf(
" The relative machine precision (eps) is to be %e \n",eps);
79 printf(
" Computational tests pass if scaled residuals are less than 10.\n");
86 LAPACKE_slarnv_work(
IONE,
ISEED, LDAxM, A);
87 LAPACKE_slarnv_work(
IONE,
ISEED, LDBxN, B);
88 for(i=0;i<
max(M,N);i++)
89 A[LDA*i+i] = A[LDA*i+i] + 2.0;
100 memcpy(Binit, B, LDBxN*
sizeof(
float));
101 memcpy(Bfinal, B, LDBxN*
sizeof(
float));
105 M, N, alpha, A, LDA, Bfinal, LDB);
109 M, N, alpha, A, LDA, Binit, Bfinal, LDB);
111 printf(
"***************************************************\n");
112 if (info_solution == 0) {
113 printf(
" ---- TESTING STRSM (%s, %s, %s, %s) ...... PASSED !\n",
117 printf(
" ---- TESTING STRSM (%s, %s, %s, %s) ... FAILED !\n",
120 printf(
"***************************************************\n");
127 free(Binit); free(Bfinal);
136 int M,
int N,
float alpha,
138 float *Bref,
float *Bplasma,
int LDB)
141 float Anorm, Binitnorm, Bplasmanorm, Blapacknorm, Rnorm, result;
143 float mzone = (float)-1.0;
145 float *work = (
float *)malloc(
max(M, N)*
sizeof(float));
155 Am, An, A, LDA, work);
160 (
CBLAS_DIAG)diag, M, N, (alpha), A, LDA, Bref, LDB);
164 cblas_saxpy(LDB * N, (mzone), Bplasma, 1, Bref, 1);
168 eps = LAPACKE_slamch_work(
'e');
170 printf(
"Rnorm %e, Anorm %e, Binitnorm %e, Bplasmanorm %e, Blapacknorm %e\n",
171 Rnorm, Anorm, Binitnorm, Bplasmanorm, Blapacknorm);
173 result = Rnorm / ((Anorm + Blapacknorm) *
max(M,N) * eps);
175 printf(
"============\n");
176 printf(
"Checking the norm of the difference against reference STRSM \n");
177 printf(
"-- ||Cplasma - Clapack||_oo/((||A||_oo+||B||_oo).N.eps) = %e \n", result);
179 if ( isinf(Blapacknorm) || isinf(Bplasmanorm) || isnan(result) || isinf(result) || (result > 10.0) ) {
180 printf(
"-- The solution is suspicious ! \n");
184 printf(
"-- The solution is CORRECT ! \n");
189 return info_solution;