KTH framework for Nek5000 toolboxes; testing version  0.0.1
dsymm.f
Go to the documentation of this file.
1  SUBROUTINE dsymm ( SIDE, UPLO, M, N, ALPHA, A, LDA, B, LDB,
2  $ BETA, C, LDC )
3 * .. Scalar Arguments ..
4  CHARACTER*1 SIDE, UPLO
5  INTEGER M, N, LDA, LDB, LDC
6  DOUBLE PRECISION ALPHA, BETA
7 * .. Array Arguments ..
8  DOUBLE PRECISION A( LDA, * ), B( LDB, * ), C( LDC, * )
9 * ..
10 *
11 * Purpose
12 * =======
13 *
14 * DSYMM performs one of the matrix-matrix operations
15 *
16 * C := alpha*A*B + beta*C,
17 *
18 * or
19 *
20 * C := alpha*B*A + beta*C,
21 *
22 * where alpha and beta are scalars, A is a symmetric matrix and B and
23 * C are m by n matrices.
24 *
25 * Parameters
26 * ==========
27 *
28 * SIDE - CHARACTER*1.
29 * On entry, SIDE specifies whether the symmetric matrix A
30 * appears on the left or right in the operation as follows:
31 *
32 * SIDE = 'L' or 'l' C := alpha*A*B + beta*C,
33 *
34 * SIDE = 'R' or 'r' C := alpha*B*A + beta*C,
35 *
36 * Unchanged on exit.
37 *
38 * UPLO - CHARACTER*1.
39 * On entry, UPLO specifies whether the upper or lower
40 * triangular part of the symmetric matrix A is to be
41 * referenced as follows:
42 *
43 * UPLO = 'U' or 'u' Only the upper triangular part of the
44 * symmetric matrix is to be referenced.
45 *
46 * UPLO = 'L' or 'l' Only the lower triangular part of the
47 * symmetric matrix is to be referenced.
48 *
49 * Unchanged on exit.
50 *
51 * M - INTEGER.
52 * On entry, M specifies the number of rows of the matrix C.
53 * M must be at least zero.
54 * Unchanged on exit.
55 *
56 * N - INTEGER.
57 * On entry, N specifies the number of columns of the matrix C.
58 * N must be at least zero.
59 * Unchanged on exit.
60 *
61 * ALPHA - DOUBLE PRECISION.
62 * On entry, ALPHA specifies the scalar alpha.
63 * Unchanged on exit.
64 *
65 * A - DOUBLE PRECISION array of DIMENSION ( LDA, ka ), where ka is
66 * m when SIDE = 'L' or 'l' and is n otherwise.
67 * Before entry with SIDE = 'L' or 'l', the m by m part of
68 * the array A must contain the symmetric matrix, such that
69 * when UPLO = 'U' or 'u', the leading m by m upper triangular
70 * part of the array A must contain the upper triangular part
71 * of the symmetric matrix and the strictly lower triangular
72 * part of A is not referenced, and when UPLO = 'L' or 'l',
73 * the leading m by m lower triangular part of the array A
74 * must contain the lower triangular part of the symmetric
75 * matrix and the strictly upper triangular part of A is not
76 * referenced.
77 * Before entry with SIDE = 'R' or 'r', the n by n part of
78 * the array A must contain the symmetric matrix, such that
79 * when UPLO = 'U' or 'u', the leading n by n upper triangular
80 * part of the array A must contain the upper triangular part
81 * of the symmetric matrix and the strictly lower triangular
82 * part of A is not referenced, and when UPLO = 'L' or 'l',
83 * the leading n by n lower triangular part of the array A
84 * must contain the lower triangular part of the symmetric
85 * matrix and the strictly upper triangular part of A is not
86 * referenced.
87 * Unchanged on exit.
88 *
89 * LDA - INTEGER.
90 * On entry, LDA specifies the first dimension of A as declared
91 * in the calling (sub) program. When SIDE = 'L' or 'l' then
92 * LDA must be at least max( 1, m ), otherwise LDA must be at
93 * least max( 1, n ).
94 * Unchanged on exit.
95 *
96 * B - DOUBLE PRECISION array of DIMENSION ( LDB, n ).
97 * Before entry, the leading m by n part of the array B must
98 * contain the matrix B.
99 * Unchanged on exit.
100 *
101 * LDB - INTEGER.
102 * On entry, LDB specifies the first dimension of B as declared
103 * in the calling (sub) program. LDB must be at least
104 * max( 1, m ).
105 * Unchanged on exit.
106 *
107 * BETA - DOUBLE PRECISION.
108 * On entry, BETA specifies the scalar beta. When BETA is
109 * supplied as zero then C need not be set on input.
110 * Unchanged on exit.
111 *
112 * C - DOUBLE PRECISION array of DIMENSION ( LDC, n ).
113 * Before entry, the leading m by n part of the array C must
114 * contain the matrix C, except when beta is zero, in which
115 * case C need not be set on entry.
116 * On exit, the array C is overwritten by the m by n updated
117 * matrix.
118 *
119 * LDC - INTEGER.
120 * On entry, LDC specifies the first dimension of C as declared
121 * in the calling (sub) program. LDC must be at least
122 * max( 1, m ).
123 * Unchanged on exit.
124 *
125 *
126 * Level 3 Blas routine.
127 *
128 * -- Written on 8-February-1989.
129 * Jack Dongarra, Argonne National Laboratory.
130 * Iain Duff, AERE Harwell.
131 * Jeremy Du Croz, Numerical Algorithms Group Ltd.
132 * Sven Hammarling, Numerical Algorithms Group Ltd.
133 *
134 *
135 * .. External Functions ..
136  LOGICAL LSAME
137  EXTERNAL lsame
138 * .. External Subroutines ..
139  EXTERNAL xerbla
140 * .. Intrinsic Functions ..
141  INTRINSIC max
142 * .. Local Scalars ..
143  LOGICAL UPPER
144  INTEGER I, INFO, J, K, NROWA
145  DOUBLE PRECISION TEMP1, TEMP2
146 * .. Parameters ..
147  DOUBLE PRECISION ONE , ZERO
148  parameter( one = 1.0d+0, zero = 0.0d+0 )
149 * ..
150 * .. Executable Statements ..
151 *
152 * Set NROWA as the number of rows of A.
153 *
154  IF( lsame( side, 'L' ) )THEN
155  nrowa = m
156  ELSE
157  nrowa = n
158  END IF
159  upper = lsame( uplo, 'U' )
160 *
161 * Test the input parameters.
162 *
163  info = 0
164  IF( ( .NOT.lsame( side, 'L' ) ).AND.
165  $ ( .NOT.lsame( side, 'R' ) ) )THEN
166  info = 1
167  ELSE IF( ( .NOT.upper ).AND.
168  $ ( .NOT.lsame( uplo, 'L' ) ) )THEN
169  info = 2
170  ELSE IF( m .LT.0 )THEN
171  info = 3
172  ELSE IF( n .LT.0 )THEN
173  info = 4
174  ELSE IF( lda.LT.max( 1, nrowa ) )THEN
175  info = 7
176  ELSE IF( ldb.LT.max( 1, m ) )THEN
177  info = 9
178  ELSE IF( ldc.LT.max( 1, m ) )THEN
179  info = 12
180  END IF
181  IF( info.NE.0 )THEN
182  CALL xerbla( 'DSYMM ', info )
183  RETURN
184  END IF
185 *
186 * Quick return if possible.
187 *
188  IF( ( m.EQ.0 ).OR.( n.EQ.0 ).OR.
189  $ ( ( alpha.EQ.zero ).AND.( beta.EQ.one ) ) )
190  $ RETURN
191 *
192 * And when alpha.eq.zero.
193 *
194  IF( alpha.EQ.zero )THEN
195  IF( beta.EQ.zero )THEN
196  DO 20, j = 1, n
197  DO 10, i = 1, m
198  c( i, j ) = zero
199  10 CONTINUE
200  20 CONTINUE
201  ELSE
202  DO 40, j = 1, n
203  DO 30, i = 1, m
204  c( i, j ) = beta*c( i, j )
205  30 CONTINUE
206  40 CONTINUE
207  END IF
208  RETURN
209  END IF
210 *
211 * Start the operations.
212 *
213  IF( lsame( side, 'L' ) )THEN
214 *
215 * Form C := alpha*A*B + beta*C.
216 *
217  IF( upper )THEN
218  DO 70, j = 1, n
219  DO 60, i = 1, m
220  temp1 = alpha*b( i, j )
221  temp2 = zero
222  DO 50, k = 1, i - 1
223  c( k, j ) = c( k, j ) + temp1 *a( k, i )
224  temp2 = temp2 + b( k, j )*a( k, i )
225  50 CONTINUE
226  IF( beta.EQ.zero )THEN
227  c( i, j ) = temp1*a( i, i ) + alpha*temp2
228  ELSE
229  c( i, j ) = beta *c( i, j ) +
230  $ temp1*a( i, i ) + alpha*temp2
231  END IF
232  60 CONTINUE
233  70 CONTINUE
234  ELSE
235  DO 100, j = 1, n
236  DO 90, i = m, 1, -1
237  temp1 = alpha*b( i, j )
238  temp2 = zero
239  DO 80, k = i + 1, m
240  c( k, j ) = c( k, j ) + temp1 *a( k, i )
241  temp2 = temp2 + b( k, j )*a( k, i )
242  80 CONTINUE
243  IF( beta.EQ.zero )THEN
244  c( i, j ) = temp1*a( i, i ) + alpha*temp2
245  ELSE
246  c( i, j ) = beta *c( i, j ) +
247  $ temp1*a( i, i ) + alpha*temp2
248  END IF
249  90 CONTINUE
250  100 CONTINUE
251  END IF
252  ELSE
253 *
254 * Form C := alpha*B*A + beta*C.
255 *
256  DO 170, j = 1, n
257  temp1 = alpha*a( j, j )
258  IF( beta.EQ.zero )THEN
259  DO 110, i = 1, m
260  c( i, j ) = temp1*b( i, j )
261  110 CONTINUE
262  ELSE
263  DO 120, i = 1, m
264  c( i, j ) = beta*c( i, j ) + temp1*b( i, j )
265  120 CONTINUE
266  END IF
267  DO 140, k = 1, j - 1
268  IF( upper )THEN
269  temp1 = alpha*a( k, j )
270  ELSE
271  temp1 = alpha*a( j, k )
272  END IF
273  DO 130, i = 1, m
274  c( i, j ) = c( i, j ) + temp1*b( i, k )
275  130 CONTINUE
276  140 CONTINUE
277  DO 160, k = j + 1, n
278  IF( upper )THEN
279  temp1 = alpha*a( j, k )
280  ELSE
281  temp1 = alpha*a( k, j )
282  END IF
283  DO 150, i = 1, m
284  c( i, j ) = c( i, j ) + temp1*b( i, k )
285  150 CONTINUE
286  160 CONTINUE
287  170 CONTINUE
288  END IF
289 *
290  RETURN
291 *
292 * End of DSYMM .
293 *
294  END
subroutine dsymm(SIDE, UPLO, M, N, ALPHA, A, LDA, B, LDB, BETA, C, LDC)
Definition: dsymm.f:3
subroutine xerbla(SRNAME, INFO)
Definition: xerbla.f:2