4
/* Subroutine */ int dtrsm_(char *side, char *uplo, char *transa, char *diag,
5
integer *m, integer *n, doublereal *alpha, doublereal *a, integer *
6
lda, doublereal *b, integer *ldb)
8
/* System generated locals */
9
integer a_dim1, a_offset, b_dim1, b_offset, i__1, i__2, i__3;
12
static doublereal temp;
13
static integer i__, j, k;
15
extern logical lsame_(char *, char *);
18
extern /* Subroutine */ int xerbla_(char *, integer *);
19
static logical nounit;
20
#define a_ref(a_1,a_2) a[(a_2)*a_dim1 + a_1]
21
#define b_ref(a_1,a_2) b[(a_2)*b_dim1 + a_1]
24
DTRSM solves one of the matrix equations
25
op( A )*X = alpha*B, or X*op( A ) = alpha*B,
26
where alpha is a scalar, X and B are m by n matrices, A is a unit, or
27
non-unit, upper or lower triangular matrix and op( A ) is one of
28
op( A ) = A or op( A ) = A'.
29
The matrix X is overwritten on B.
33
On entry, SIDE specifies whether op( A ) appears on the left
34
or right of X as follows:
35
SIDE = 'L' or 'l' op( A )*X = alpha*B.
36
SIDE = 'R' or 'r' X*op( A ) = alpha*B.
39
On entry, UPLO specifies whether the matrix A is an upper or
40
lower triangular matrix as follows:
41
UPLO = 'U' or 'u' A is an upper triangular matrix.
42
UPLO = 'L' or 'l' A is a lower triangular matrix.
45
On entry, TRANSA specifies the form of op( A ) to be used in
46
the matrix multiplication as follows:
47
TRANSA = 'N' or 'n' op( A ) = A.
48
TRANSA = 'T' or 't' op( A ) = A'.
49
TRANSA = 'C' or 'c' op( A ) = A'.
52
On entry, DIAG specifies whether or not A is unit triangular
54
DIAG = 'U' or 'u' A is assumed to be unit triangular.
55
DIAG = 'N' or 'n' A is not assumed to be unit
59
On entry, M specifies the number of rows of B. M must be at
63
On entry, N specifies the number of columns of B. N must be
66
ALPHA - DOUBLE PRECISION.
67
On entry, ALPHA specifies the scalar alpha. When alpha is
68
zero then A is not referenced and B need not be set before
71
A - DOUBLE PRECISION array of DIMENSION ( LDA, k ), where k is m
72
when SIDE = 'L' or 'l' and is n when SIDE = 'R' or 'r'.
73
Before entry with UPLO = 'U' or 'u', the leading k by k
74
upper triangular part of the array A must contain the upper
75
triangular matrix and the strictly lower triangular part of
77
Before entry with UPLO = 'L' or 'l', the leading k by k
78
lower triangular part of the array A must contain the lower
79
triangular matrix and the strictly upper triangular part of
81
Note that when DIAG = 'U' or 'u', the diagonal elements of
82
A are not referenced either, but are assumed to be unity.
85
On entry, LDA specifies the first dimension of A as declared
86
in the calling (sub) program. When SIDE = 'L' or 'l' then
87
LDA must be at least max( 1, m ), when SIDE = 'R' or 'r'
88
then LDA must be at least max( 1, n ).
90
B - DOUBLE PRECISION array of DIMENSION ( LDB, n ).
91
Before entry, the leading m by n part of the array B must
92
contain the right-hand side matrix B, and on exit is
93
overwritten by the solution matrix X.
95
On entry, LDB specifies the first dimension of B as declared
96
in the calling (sub) program. LDB must be at least
100
-- Written on 8-February-1989.
101
Jack Dongarra, Argonne National Laboratory.
102
Iain Duff, AERE Harwell.
103
Jeremy Du Croz, Numerical Algorithms Group Ltd.
104
Sven Hammarling, Numerical Algorithms Group Ltd.
105
Test the input parameters.
106
Parameter adjustments */
108
a_offset = 1 + a_dim1 * 1;
111
b_offset = 1 + b_dim1 * 1;
114
lside = lsame_(side, "L");
120
nounit = lsame_(diag, "N");
121
upper = lsame_(uplo, "U");
123
if (! lside && ! lsame_(side, "R")) {
125
} else if (! upper && ! lsame_(uplo, "L")) {
127
} else if (! lsame_(transa, "N") && ! lsame_(transa,
128
"T") && ! lsame_(transa, "C")) {
130
} else if (! lsame_(diag, "U") && ! lsame_(diag,
137
} else if (*lda < max(1,nrowa)) {
139
} else if (*ldb < max(1,*m)) {
143
xerbla_("DTRSM ", &info);
146
/* Quick return if possible. */
150
/* And when alpha.eq.zero. */
153
for (j = 1; j <= i__1; ++j) {
155
for (i__ = 1; i__ <= i__2; ++i__) {
163
/* Start the operations. */
165
if (lsame_(transa, "N")) {
166
/* Form B := alpha*inv( A )*B. */
169
for (j = 1; j <= i__1; ++j) {
172
for (i__ = 1; i__ <= i__2; ++i__) {
173
b_ref(i__, j) = *alpha * b_ref(i__, j);
177
for (k = *m; k >= 1; --k) {
178
if (b_ref(k, j) != 0.) {
180
b_ref(k, j) = b_ref(k, j) / a_ref(k, k);
183
for (i__ = 1; i__ <= i__2; ++i__) {
184
b_ref(i__, j) = b_ref(i__, j) - b_ref(k, j) *
195
for (j = 1; j <= i__1; ++j) {
198
for (i__ = 1; i__ <= i__2; ++i__) {
199
b_ref(i__, j) = *alpha * b_ref(i__, j);
204
for (k = 1; k <= i__2; ++k) {
205
if (b_ref(k, j) != 0.) {
207
b_ref(k, j) = b_ref(k, j) / a_ref(k, k);
210
for (i__ = k + 1; i__ <= i__3; ++i__) {
211
b_ref(i__, j) = b_ref(i__, j) - b_ref(k, j) *
222
/* Form B := alpha*inv( A' )*B. */
225
for (j = 1; j <= i__1; ++j) {
227
for (i__ = 1; i__ <= i__2; ++i__) {
228
temp = *alpha * b_ref(i__, j);
230
for (k = 1; k <= i__3; ++k) {
231
temp -= a_ref(k, i__) * b_ref(k, j);
235
temp /= a_ref(i__, i__);
237
b_ref(i__, j) = temp;
244
for (j = 1; j <= i__1; ++j) {
245
for (i__ = *m; i__ >= 1; --i__) {
246
temp = *alpha * b_ref(i__, j);
248
for (k = i__ + 1; k <= i__2; ++k) {
249
temp -= a_ref(k, i__) * b_ref(k, j);
253
temp /= a_ref(i__, i__);
255
b_ref(i__, j) = temp;
263
if (lsame_(transa, "N")) {
264
/* Form B := alpha*B*inv( A ). */
267
for (j = 1; j <= i__1; ++j) {
270
for (i__ = 1; i__ <= i__2; ++i__) {
271
b_ref(i__, j) = *alpha * b_ref(i__, j);
276
for (k = 1; k <= i__2; ++k) {
277
if (a_ref(k, j) != 0.) {
279
for (i__ = 1; i__ <= i__3; ++i__) {
280
b_ref(i__, j) = b_ref(i__, j) - a_ref(k, j) *
288
temp = 1. / a_ref(j, j);
290
for (i__ = 1; i__ <= i__2; ++i__) {
291
b_ref(i__, j) = temp * b_ref(i__, j);
298
for (j = *n; j >= 1; --j) {
301
for (i__ = 1; i__ <= i__1; ++i__) {
302
b_ref(i__, j) = *alpha * b_ref(i__, j);
307
for (k = j + 1; k <= i__1; ++k) {
308
if (a_ref(k, j) != 0.) {
310
for (i__ = 1; i__ <= i__2; ++i__) {
311
b_ref(i__, j) = b_ref(i__, j) - a_ref(k, j) *
319
temp = 1. / a_ref(j, j);
321
for (i__ = 1; i__ <= i__1; ++i__) {
322
b_ref(i__, j) = temp * b_ref(i__, j);
330
/* Form B := alpha*B*inv( A' ). */
332
for (k = *n; k >= 1; --k) {
334
temp = 1. / a_ref(k, k);
336
for (i__ = 1; i__ <= i__1; ++i__) {
337
b_ref(i__, k) = temp * b_ref(i__, k);
342
for (j = 1; j <= i__1; ++j) {
343
if (a_ref(j, k) != 0.) {
346
for (i__ = 1; i__ <= i__2; ++i__) {
347
b_ref(i__, j) = b_ref(i__, j) - temp * b_ref(
356
for (i__ = 1; i__ <= i__1; ++i__) {
357
b_ref(i__, k) = *alpha * b_ref(i__, k);
365
for (k = 1; k <= i__1; ++k) {
367
temp = 1. / a_ref(k, k);
369
for (i__ = 1; i__ <= i__2; ++i__) {
370
b_ref(i__, k) = temp * b_ref(i__, k);
375
for (j = k + 1; j <= i__2; ++j) {
376
if (a_ref(j, k) != 0.) {
379
for (i__ = 1; i__ <= i__3; ++i__) {
380
b_ref(i__, j) = b_ref(i__, j) - temp * b_ref(
389
for (i__ = 1; i__ <= i__2; ++i__) {
390
b_ref(i__, k) = *alpha * b_ref(i__, k);