LAPACK 3.12.0
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
chemm.f
Go to the documentation of this file.
1*> \brief \b CHEMM
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8* Definition:
9* ===========
10*
11* SUBROUTINE CHEMM(SIDE,UPLO,M,N,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
12*
13* .. Scalar Arguments ..
14* COMPLEX ALPHA,BETA
15* INTEGER LDA,LDB,LDC,M,N
16* CHARACTER SIDE,UPLO
17* ..
18* .. Array Arguments ..
19* COMPLEX A(LDA,*),B(LDB,*),C(LDC,*)
20* ..
21*
22*
23*> \par Purpose:
24* =============
25*>
26*> \verbatim
27*>
28*> CHEMM performs one of the matrix-matrix operations
29*>
30*> C := alpha*A*B + beta*C,
31*>
32*> or
33*>
34*> C := alpha*B*A + beta*C,
35*>
36*> where alpha and beta are scalars, A is an hermitian matrix and B and
37*> C are m by n matrices.
38*> \endverbatim
39*
40* Arguments:
41* ==========
42*
43*> \param[in] SIDE
44*> \verbatim
45*> SIDE is CHARACTER*1
46*> On entry, SIDE specifies whether the hermitian matrix A
47*> appears on the left or right in the operation as follows:
48*>
49*> SIDE = 'L' or 'l' C := alpha*A*B + beta*C,
50*>
51*> SIDE = 'R' or 'r' C := alpha*B*A + beta*C,
52*> \endverbatim
53*>
54*> \param[in] UPLO
55*> \verbatim
56*> UPLO is CHARACTER*1
57*> On entry, UPLO specifies whether the upper or lower
58*> triangular part of the hermitian matrix A is to be
59*> referenced as follows:
60*>
61*> UPLO = 'U' or 'u' Only the upper triangular part of the
62*> hermitian matrix is to be referenced.
63*>
64*> UPLO = 'L' or 'l' Only the lower triangular part of the
65*> hermitian matrix is to be referenced.
66*> \endverbatim
67*>
68*> \param[in] M
69*> \verbatim
70*> M is INTEGER
71*> On entry, M specifies the number of rows of the matrix C.
72*> M must be at least zero.
73*> \endverbatim
74*>
75*> \param[in] N
76*> \verbatim
77*> N is INTEGER
78*> On entry, N specifies the number of columns of the matrix C.
79*> N must be at least zero.
80*> \endverbatim
81*>
82*> \param[in] ALPHA
83*> \verbatim
84*> ALPHA is COMPLEX
85*> On entry, ALPHA specifies the scalar alpha.
86*> \endverbatim
87*>
88*> \param[in] A
89*> \verbatim
90*> A is COMPLEX array, dimension ( LDA, ka ), where ka is
91*> m when SIDE = 'L' or 'l' and is n otherwise.
92*> Before entry with SIDE = 'L' or 'l', the m by m part of
93*> the array A must contain the hermitian matrix, such that
94*> when UPLO = 'U' or 'u', the leading m by m upper triangular
95*> part of the array A must contain the upper triangular part
96*> of the hermitian matrix and the strictly lower triangular
97*> part of A is not referenced, and when UPLO = 'L' or 'l',
98*> the leading m by m lower triangular part of the array A
99*> must contain the lower triangular part of the hermitian
100*> matrix and the strictly upper triangular part of A is not
101*> referenced.
102*> Before entry with SIDE = 'R' or 'r', the n by n part of
103*> the array A must contain the hermitian matrix, such that
104*> when UPLO = 'U' or 'u', the leading n by n upper triangular
105*> part of the array A must contain the upper triangular part
106*> of the hermitian matrix and the strictly lower triangular
107*> part of A is not referenced, and when UPLO = 'L' or 'l',
108*> the leading n by n lower triangular part of the array A
109*> must contain the lower triangular part of the hermitian
110*> matrix and the strictly upper triangular part of A is not
111*> referenced.
112*> Note that the imaginary parts of the diagonal elements need
113*> not be set, they are assumed to be zero.
114*> \endverbatim
115*>
116*> \param[in] LDA
117*> \verbatim
118*> LDA is INTEGER
119*> On entry, LDA specifies the first dimension of A as declared
120*> in the calling (sub) program. When SIDE = 'L' or 'l' then
121*> LDA must be at least max( 1, m ), otherwise LDA must be at
122*> least max( 1, n ).
123*> \endverbatim
124*>
125*> \param[in] B
126*> \verbatim
127*> B is COMPLEX array, dimension ( LDB, N )
128*> Before entry, the leading m by n part of the array B must
129*> contain the matrix B.
130*> \endverbatim
131*>
132*> \param[in] LDB
133*> \verbatim
134*> LDB is INTEGER
135*> On entry, LDB specifies the first dimension of B as declared
136*> in the calling (sub) program. LDB must be at least
137*> max( 1, m ).
138*> \endverbatim
139*>
140*> \param[in] BETA
141*> \verbatim
142*> BETA is COMPLEX
143*> On entry, BETA specifies the scalar beta. When BETA is
144*> supplied as zero then C need not be set on input.
145*> \endverbatim
146*>
147*> \param[in,out] C
148*> \verbatim
149*> C is COMPLEX array, dimension ( LDC, N )
150*> Before entry, the leading m by n part of the array C must
151*> contain the matrix C, except when beta is zero, in which
152*> case C need not be set on entry.
153*> On exit, the array C is overwritten by the m by n updated
154*> matrix.
155*> \endverbatim
156*>
157*> \param[in] LDC
158*> \verbatim
159*> LDC is INTEGER
160*> On entry, LDC specifies the first dimension of C as declared
161*> in the calling (sub) program. LDC must be at least
162*> max( 1, m ).
163*> \endverbatim
164*
165* Authors:
166* ========
167*
168*> \author Univ. of Tennessee
169*> \author Univ. of California Berkeley
170*> \author Univ. of Colorado Denver
171*> \author NAG Ltd.
172*
173*> \ingroup hemm
174*
175*> \par Further Details:
176* =====================
177*>
178*> \verbatim
179*>
180*> Level 3 Blas routine.
181*>
182*> -- Written on 8-February-1989.
183*> Jack Dongarra, Argonne National Laboratory.
184*> Iain Duff, AERE Harwell.
185*> Jeremy Du Croz, Numerical Algorithms Group Ltd.
186*> Sven Hammarling, Numerical Algorithms Group Ltd.
187*> \endverbatim
188*>
189* =====================================================================
190 SUBROUTINE chemm(SIDE,UPLO,M,N,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
191*
192* -- Reference BLAS level3 routine --
193* -- Reference BLAS is a software package provided by Univ. of Tennessee, --
194* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
195*
196* .. Scalar Arguments ..
197 COMPLEX ALPHA,BETA
198 INTEGER LDA,LDB,LDC,M,N
199 CHARACTER SIDE,UPLO
200* ..
201* .. Array Arguments ..
202 COMPLEX A(LDA,*),B(LDB,*),C(LDC,*)
203* ..
204*
205* =====================================================================
206*
207* .. External Functions ..
208 LOGICAL LSAME
209 EXTERNAL lsame
210* ..
211* .. External Subroutines ..
212 EXTERNAL xerbla
213* ..
214* .. Intrinsic Functions ..
215 INTRINSIC conjg,max,real
216* ..
217* .. Local Scalars ..
218 COMPLEX TEMP1,TEMP2
219 INTEGER I,INFO,J,K,NROWA
220 LOGICAL UPPER
221* ..
222* .. Parameters ..
223 COMPLEX ONE
224 parameter(one= (1.0e+0,0.0e+0))
225 COMPLEX ZERO
226 parameter(zero= (0.0e+0,0.0e+0))
227* ..
228*
229* Set NROWA as the number of rows of A.
230*
231 IF (lsame(side,'L')) THEN
232 nrowa = m
233 ELSE
234 nrowa = n
235 END IF
236 upper = lsame(uplo,'U')
237*
238* Test the input parameters.
239*
240 info = 0
241 IF ((.NOT.lsame(side,'L')) .AND.
242 + (.NOT.lsame(side,'R'))) THEN
243 info = 1
244 ELSE IF ((.NOT.upper) .AND.
245 + (.NOT.lsame(uplo,'L'))) THEN
246 info = 2
247 ELSE IF (m.LT.0) THEN
248 info = 3
249 ELSE IF (n.LT.0) THEN
250 info = 4
251 ELSE IF (lda.LT.max(1,nrowa)) THEN
252 info = 7
253 ELSE IF (ldb.LT.max(1,m)) THEN
254 info = 9
255 ELSE IF (ldc.LT.max(1,m)) THEN
256 info = 12
257 END IF
258 IF (info.NE.0) THEN
259 CALL xerbla('CHEMM ',info)
260 RETURN
261 END IF
262*
263* Quick return if possible.
264*
265 IF ((m.EQ.0) .OR. (n.EQ.0) .OR.
266 + ((alpha.EQ.zero).AND. (beta.EQ.one))) RETURN
267*
268* And when alpha.eq.zero.
269*
270 IF (alpha.EQ.zero) THEN
271 IF (beta.EQ.zero) THEN
272 DO 20 j = 1,n
273 DO 10 i = 1,m
274 c(i,j) = zero
275 10 CONTINUE
276 20 CONTINUE
277 ELSE
278 DO 40 j = 1,n
279 DO 30 i = 1,m
280 c(i,j) = beta*c(i,j)
281 30 CONTINUE
282 40 CONTINUE
283 END IF
284 RETURN
285 END IF
286*
287* Start the operations.
288*
289 IF (lsame(side,'L')) THEN
290*
291* Form C := alpha*A*B + beta*C.
292*
293 IF (upper) THEN
294 DO 70 j = 1,n
295 DO 60 i = 1,m
296 temp1 = alpha*b(i,j)
297 temp2 = zero
298 DO 50 k = 1,i - 1
299 c(k,j) = c(k,j) + temp1*a(k,i)
300 temp2 = temp2 + b(k,j)*conjg(a(k,i))
301 50 CONTINUE
302 IF (beta.EQ.zero) THEN
303 c(i,j) = temp1*real(a(i,i)) + alpha*temp2
304 ELSE
305 c(i,j) = beta*c(i,j) + temp1*real(a(i,i)) +
306 + alpha*temp2
307 END IF
308 60 CONTINUE
309 70 CONTINUE
310 ELSE
311 DO 100 j = 1,n
312 DO 90 i = m,1,-1
313 temp1 = alpha*b(i,j)
314 temp2 = zero
315 DO 80 k = i + 1,m
316 c(k,j) = c(k,j) + temp1*a(k,i)
317 temp2 = temp2 + b(k,j)*conjg(a(k,i))
318 80 CONTINUE
319 IF (beta.EQ.zero) THEN
320 c(i,j) = temp1*real(a(i,i)) + alpha*temp2
321 ELSE
322 c(i,j) = beta*c(i,j) + temp1*real(a(i,i)) +
323 + alpha*temp2
324 END IF
325 90 CONTINUE
326 100 CONTINUE
327 END IF
328 ELSE
329*
330* Form C := alpha*B*A + beta*C.
331*
332 DO 170 j = 1,n
333 temp1 = alpha*real(a(j,j))
334 IF (beta.EQ.zero) THEN
335 DO 110 i = 1,m
336 c(i,j) = temp1*b(i,j)
337 110 CONTINUE
338 ELSE
339 DO 120 i = 1,m
340 c(i,j) = beta*c(i,j) + temp1*b(i,j)
341 120 CONTINUE
342 END IF
343 DO 140 k = 1,j - 1
344 IF (upper) THEN
345 temp1 = alpha*a(k,j)
346 ELSE
347 temp1 = alpha*conjg(a(j,k))
348 END IF
349 DO 130 i = 1,m
350 c(i,j) = c(i,j) + temp1*b(i,k)
351 130 CONTINUE
352 140 CONTINUE
353 DO 160 k = j + 1,n
354 IF (upper) THEN
355 temp1 = alpha*conjg(a(j,k))
356 ELSE
357 temp1 = alpha*a(k,j)
358 END IF
359 DO 150 i = 1,m
360 c(i,j) = c(i,j) + temp1*b(i,k)
361 150 CONTINUE
362 160 CONTINUE
363 170 CONTINUE
364 END IF
365*
366 RETURN
367*
368* End of CHEMM
369*
370 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine chemm(side, uplo, m, n, alpha, a, lda, b, ldb, beta, c, ldc)
CHEMM
Definition chemm.f:191