LAPACK 3.12.0
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
dtrsm.f
Go to the documentation of this file.
1*> \brief \b DTRSM
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 DTRSM(SIDE,UPLO,TRANSA,DIAG,M,N,ALPHA,A,LDA,B,LDB)
12*
13* .. Scalar Arguments ..
14* DOUBLE PRECISION ALPHA
15* INTEGER LDA,LDB,M,N
16* CHARACTER DIAG,SIDE,TRANSA,UPLO
17* ..
18* .. Array Arguments ..
19* DOUBLE PRECISION A(LDA,*),B(LDB,*)
20* ..
21*
22*
23*> \par Purpose:
24* =============
25*>
26*> \verbatim
27*>
28*> DTRSM solves one of the matrix equations
29*>
30*> op( A )*X = alpha*B, or X*op( A ) = alpha*B,
31*>
32*> where alpha is a scalar, X and B are m by n matrices, A is a unit, or
33*> non-unit, upper or lower triangular matrix and op( A ) is one of
34*>
35*> op( A ) = A or op( A ) = A**T.
36*>
37*> The matrix X is overwritten on B.
38*> \endverbatim
39*
40* Arguments:
41* ==========
42*
43*> \param[in] SIDE
44*> \verbatim
45*> SIDE is CHARACTER*1
46*> On entry, SIDE specifies whether op( A ) appears on the left
47*> or right of X as follows:
48*>
49*> SIDE = 'L' or 'l' op( A )*X = alpha*B.
50*>
51*> SIDE = 'R' or 'r' X*op( A ) = alpha*B.
52*> \endverbatim
53*>
54*> \param[in] UPLO
55*> \verbatim
56*> UPLO is CHARACTER*1
57*> On entry, UPLO specifies whether the matrix A is an upper or
58*> lower triangular matrix as follows:
59*>
60*> UPLO = 'U' or 'u' A is an upper triangular matrix.
61*>
62*> UPLO = 'L' or 'l' A is a lower triangular matrix.
63*> \endverbatim
64*>
65*> \param[in] TRANSA
66*> \verbatim
67*> TRANSA is CHARACTER*1
68*> On entry, TRANSA specifies the form of op( A ) to be used in
69*> the matrix multiplication as follows:
70*>
71*> TRANSA = 'N' or 'n' op( A ) = A.
72*>
73*> TRANSA = 'T' or 't' op( A ) = A**T.
74*>
75*> TRANSA = 'C' or 'c' op( A ) = A**T.
76*> \endverbatim
77*>
78*> \param[in] DIAG
79*> \verbatim
80*> DIAG is CHARACTER*1
81*> On entry, DIAG specifies whether or not A is unit triangular
82*> as follows:
83*>
84*> DIAG = 'U' or 'u' A is assumed to be unit triangular.
85*>
86*> DIAG = 'N' or 'n' A is not assumed to be unit
87*> triangular.
88*> \endverbatim
89*>
90*> \param[in] M
91*> \verbatim
92*> M is INTEGER
93*> On entry, M specifies the number of rows of B. M must be at
94*> least zero.
95*> \endverbatim
96*>
97*> \param[in] N
98*> \verbatim
99*> N is INTEGER
100*> On entry, N specifies the number of columns of B. N must be
101*> at least zero.
102*> \endverbatim
103*>
104*> \param[in] ALPHA
105*> \verbatim
106*> ALPHA is DOUBLE PRECISION.
107*> On entry, ALPHA specifies the scalar alpha. When alpha is
108*> zero then A is not referenced and B need not be set before
109*> entry.
110*> \endverbatim
111*>
112*> \param[in] A
113*> \verbatim
114*> A is DOUBLE PRECISION array, dimension ( LDA, k ),
115*> where k is m when SIDE = 'L' or 'l'
116*> and k is n when SIDE = 'R' or 'r'.
117*> Before entry with UPLO = 'U' or 'u', the leading k by k
118*> upper triangular part of the array A must contain the upper
119*> triangular matrix and the strictly lower triangular part of
120*> A is not referenced.
121*> Before entry with UPLO = 'L' or 'l', the leading k by k
122*> lower triangular part of the array A must contain the lower
123*> triangular matrix and the strictly upper triangular part of
124*> A is not referenced.
125*> Note that when DIAG = 'U' or 'u', the diagonal elements of
126*> A are not referenced either, but are assumed to be unity.
127*> \endverbatim
128*>
129*> \param[in] LDA
130*> \verbatim
131*> LDA is INTEGER
132*> On entry, LDA specifies the first dimension of A as declared
133*> in the calling (sub) program. When SIDE = 'L' or 'l' then
134*> LDA must be at least max( 1, m ), when SIDE = 'R' or 'r'
135*> then LDA must be at least max( 1, n ).
136*> \endverbatim
137*>
138*> \param[in,out] B
139*> \verbatim
140*> B is DOUBLE PRECISION array, dimension ( LDB, N )
141*> Before entry, the leading m by n part of the array B must
142*> contain the right-hand side matrix B, and on exit is
143*> overwritten by the solution matrix X.
144*> \endverbatim
145*>
146*> \param[in] LDB
147*> \verbatim
148*> LDB is INTEGER
149*> On entry, LDB specifies the first dimension of B as declared
150*> in the calling (sub) program. LDB must be at least
151*> max( 1, m ).
152*> \endverbatim
153*
154* Authors:
155* ========
156*
157*> \author Univ. of Tennessee
158*> \author Univ. of California Berkeley
159*> \author Univ. of Colorado Denver
160*> \author NAG Ltd.
161*
162*> \ingroup trsm
163*
164*> \par Further Details:
165* =====================
166*>
167*> \verbatim
168*>
169*> Level 3 Blas routine.
170*>
171*>
172*> -- Written on 8-February-1989.
173*> Jack Dongarra, Argonne National Laboratory.
174*> Iain Duff, AERE Harwell.
175*> Jeremy Du Croz, Numerical Algorithms Group Ltd.
176*> Sven Hammarling, Numerical Algorithms Group Ltd.
177*> \endverbatim
178*>
179* =====================================================================
180 SUBROUTINE dtrsm(SIDE,UPLO,TRANSA,DIAG,M,N,ALPHA,A,LDA,B,LDB)
181*
182* -- Reference BLAS level3 routine --
183* -- Reference BLAS is a software package provided by Univ. of Tennessee, --
184* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
185*
186* .. Scalar Arguments ..
187 DOUBLE PRECISION ALPHA
188 INTEGER LDA,LDB,M,N
189 CHARACTER DIAG,SIDE,TRANSA,UPLO
190* ..
191* .. Array Arguments ..
192 DOUBLE PRECISION A(LDA,*),B(LDB,*)
193* ..
194*
195* =====================================================================
196*
197* .. External Functions ..
198 LOGICAL LSAME
199 EXTERNAL lsame
200* ..
201* .. External Subroutines ..
202 EXTERNAL xerbla
203* ..
204* .. Intrinsic Functions ..
205 INTRINSIC max
206* ..
207* .. Local Scalars ..
208 DOUBLE PRECISION TEMP
209 INTEGER I,INFO,J,K,NROWA
210 LOGICAL LSIDE,NOUNIT,UPPER
211* ..
212* .. Parameters ..
213 DOUBLE PRECISION ONE,ZERO
214 parameter(one=1.0d+0,zero=0.0d+0)
215* ..
216*
217* Test the input parameters.
218*
219 lside = lsame(side,'L')
220 IF (lside) THEN
221 nrowa = m
222 ELSE
223 nrowa = n
224 END IF
225 nounit = lsame(diag,'N')
226 upper = lsame(uplo,'U')
227*
228 info = 0
229 IF ((.NOT.lside) .AND. (.NOT.lsame(side,'R'))) THEN
230 info = 1
231 ELSE IF ((.NOT.upper) .AND. (.NOT.lsame(uplo,'L'))) THEN
232 info = 2
233 ELSE IF ((.NOT.lsame(transa,'N')) .AND.
234 + (.NOT.lsame(transa,'T')) .AND.
235 + (.NOT.lsame(transa,'C'))) THEN
236 info = 3
237 ELSE IF ((.NOT.lsame(diag,'U')) .AND.
238 + (.NOT.lsame(diag,'N'))) THEN
239 info = 4
240 ELSE IF (m.LT.0) THEN
241 info = 5
242 ELSE IF (n.LT.0) THEN
243 info = 6
244 ELSE IF (lda.LT.max(1,nrowa)) THEN
245 info = 9
246 ELSE IF (ldb.LT.max(1,m)) THEN
247 info = 11
248 END IF
249 IF (info.NE.0) THEN
250 CALL xerbla('DTRSM ',info)
251 RETURN
252 END IF
253*
254* Quick return if possible.
255*
256 IF (m.EQ.0 .OR. n.EQ.0) RETURN
257*
258* And when alpha.eq.zero.
259*
260 IF (alpha.EQ.zero) THEN
261 DO 20 j = 1,n
262 DO 10 i = 1,m
263 b(i,j) = zero
264 10 CONTINUE
265 20 CONTINUE
266 RETURN
267 END IF
268*
269* Start the operations.
270*
271 IF (lside) THEN
272 IF (lsame(transa,'N')) THEN
273*
274* Form B := alpha*inv( A )*B.
275*
276 IF (upper) THEN
277 DO 60 j = 1,n
278 IF (alpha.NE.one) THEN
279 DO 30 i = 1,m
280 b(i,j) = alpha*b(i,j)
281 30 CONTINUE
282 END IF
283 DO 50 k = m,1,-1
284 IF (b(k,j).NE.zero) THEN
285 IF (nounit) b(k,j) = b(k,j)/a(k,k)
286 DO 40 i = 1,k - 1
287 b(i,j) = b(i,j) - b(k,j)*a(i,k)
288 40 CONTINUE
289 END IF
290 50 CONTINUE
291 60 CONTINUE
292 ELSE
293 DO 100 j = 1,n
294 IF (alpha.NE.one) THEN
295 DO 70 i = 1,m
296 b(i,j) = alpha*b(i,j)
297 70 CONTINUE
298 END IF
299 DO 90 k = 1,m
300 IF (b(k,j).NE.zero) THEN
301 IF (nounit) b(k,j) = b(k,j)/a(k,k)
302 DO 80 i = k + 1,m
303 b(i,j) = b(i,j) - b(k,j)*a(i,k)
304 80 CONTINUE
305 END IF
306 90 CONTINUE
307 100 CONTINUE
308 END IF
309 ELSE
310*
311* Form B := alpha*inv( A**T )*B.
312*
313 IF (upper) THEN
314 DO 130 j = 1,n
315 DO 120 i = 1,m
316 temp = alpha*b(i,j)
317 DO 110 k = 1,i - 1
318 temp = temp - a(k,i)*b(k,j)
319 110 CONTINUE
320 IF (nounit) temp = temp/a(i,i)
321 b(i,j) = temp
322 120 CONTINUE
323 130 CONTINUE
324 ELSE
325 DO 160 j = 1,n
326 DO 150 i = m,1,-1
327 temp = alpha*b(i,j)
328 DO 140 k = i + 1,m
329 temp = temp - a(k,i)*b(k,j)
330 140 CONTINUE
331 IF (nounit) temp = temp/a(i,i)
332 b(i,j) = temp
333 150 CONTINUE
334 160 CONTINUE
335 END IF
336 END IF
337 ELSE
338 IF (lsame(transa,'N')) THEN
339*
340* Form B := alpha*B*inv( A ).
341*
342 IF (upper) THEN
343 DO 210 j = 1,n
344 IF (alpha.NE.one) THEN
345 DO 170 i = 1,m
346 b(i,j) = alpha*b(i,j)
347 170 CONTINUE
348 END IF
349 DO 190 k = 1,j - 1
350 IF (a(k,j).NE.zero) THEN
351 DO 180 i = 1,m
352 b(i,j) = b(i,j) - a(k,j)*b(i,k)
353 180 CONTINUE
354 END IF
355 190 CONTINUE
356 IF (nounit) THEN
357 temp = one/a(j,j)
358 DO 200 i = 1,m
359 b(i,j) = temp*b(i,j)
360 200 CONTINUE
361 END IF
362 210 CONTINUE
363 ELSE
364 DO 260 j = n,1,-1
365 IF (alpha.NE.one) THEN
366 DO 220 i = 1,m
367 b(i,j) = alpha*b(i,j)
368 220 CONTINUE
369 END IF
370 DO 240 k = j + 1,n
371 IF (a(k,j).NE.zero) THEN
372 DO 230 i = 1,m
373 b(i,j) = b(i,j) - a(k,j)*b(i,k)
374 230 CONTINUE
375 END IF
376 240 CONTINUE
377 IF (nounit) THEN
378 temp = one/a(j,j)
379 DO 250 i = 1,m
380 b(i,j) = temp*b(i,j)
381 250 CONTINUE
382 END IF
383 260 CONTINUE
384 END IF
385 ELSE
386*
387* Form B := alpha*B*inv( A**T ).
388*
389 IF (upper) THEN
390 DO 310 k = n,1,-1
391 IF (nounit) THEN
392 temp = one/a(k,k)
393 DO 270 i = 1,m
394 b(i,k) = temp*b(i,k)
395 270 CONTINUE
396 END IF
397 DO 290 j = 1,k - 1
398 IF (a(j,k).NE.zero) THEN
399 temp = a(j,k)
400 DO 280 i = 1,m
401 b(i,j) = b(i,j) - temp*b(i,k)
402 280 CONTINUE
403 END IF
404 290 CONTINUE
405 IF (alpha.NE.one) THEN
406 DO 300 i = 1,m
407 b(i,k) = alpha*b(i,k)
408 300 CONTINUE
409 END IF
410 310 CONTINUE
411 ELSE
412 DO 360 k = 1,n
413 IF (nounit) THEN
414 temp = one/a(k,k)
415 DO 320 i = 1,m
416 b(i,k) = temp*b(i,k)
417 320 CONTINUE
418 END IF
419 DO 340 j = k + 1,n
420 IF (a(j,k).NE.zero) THEN
421 temp = a(j,k)
422 DO 330 i = 1,m
423 b(i,j) = b(i,j) - temp*b(i,k)
424 330 CONTINUE
425 END IF
426 340 CONTINUE
427 IF (alpha.NE.one) THEN
428 DO 350 i = 1,m
429 b(i,k) = alpha*b(i,k)
430 350 CONTINUE
431 END IF
432 360 CONTINUE
433 END IF
434 END IF
435 END IF
436*
437 RETURN
438*
439* End of DTRSM
440*
441 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine dtrsm(side, uplo, transa, diag, m, n, alpha, a, lda, b, ldb)
DTRSM
Definition dtrsm.f:181