LAPACK 3.12.0
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ ctrsm()

subroutine ctrsm ( character  side,
character  uplo,
character  transa,
character  diag,
integer  m,
integer  n,
complex  alpha,
complex, dimension(lda,*)  a,
integer  lda,
complex, dimension(ldb,*)  b,
integer  ldb 
)

CTRSM

Purpose:
 CTRSM  solves one of the matrix equations

    op( A )*X = alpha*B,   or   X*op( A ) = alpha*B,

 where alpha is a scalar, X and B are m by n matrices, A is a unit, or
 non-unit,  upper or lower triangular matrix  and  op( A )  is one  of

    op( A ) = A   or   op( A ) = A**T   or   op( A ) = A**H.

 The matrix X is overwritten on B.
Parameters
[in]SIDE
          SIDE is CHARACTER*1
           On entry, SIDE specifies whether op( A ) appears on the left
           or right of X as follows:

              SIDE = 'L' or 'l'   op( A )*X = alpha*B.

              SIDE = 'R' or 'r'   X*op( A ) = alpha*B.
[in]UPLO
          UPLO is CHARACTER*1
           On entry, UPLO specifies whether the matrix A is an upper or
           lower triangular matrix as follows:

              UPLO = 'U' or 'u'   A is an upper triangular matrix.

              UPLO = 'L' or 'l'   A is a lower triangular matrix.
[in]TRANSA
          TRANSA is CHARACTER*1
           On entry, TRANSA specifies the form of op( A ) to be used in
           the matrix multiplication as follows:

              TRANSA = 'N' or 'n'   op( A ) = A.

              TRANSA = 'T' or 't'   op( A ) = A**T.

              TRANSA = 'C' or 'c'   op( A ) = A**H.
[in]DIAG
          DIAG is CHARACTER*1
           On entry, DIAG specifies whether or not A is unit triangular
           as follows:

              DIAG = 'U' or 'u'   A is assumed to be unit triangular.

              DIAG = 'N' or 'n'   A is not assumed to be unit
                                  triangular.
[in]M
          M is INTEGER
           On entry, M specifies the number of rows of B. M must be at
           least zero.
[in]N
          N is INTEGER
           On entry, N specifies the number of columns of B.  N must be
           at least zero.
[in]ALPHA
          ALPHA is COMPLEX
           On entry,  ALPHA specifies the scalar  alpha. When  alpha is
           zero then  A is not referenced and  B need not be set before
           entry.
[in]A
          A is COMPLEX array, dimension ( LDA, k ),
           where k is m when SIDE = 'L' or 'l'
             and k is n when SIDE = 'R' or 'r'.
           Before entry  with  UPLO = 'U' or 'u',  the  leading  k by k
           upper triangular part of the array  A must contain the upper
           triangular matrix  and the strictly lower triangular part of
           A is not referenced.
           Before entry  with  UPLO = 'L' or 'l',  the  leading  k by k
           lower triangular part of the array  A must contain the lower
           triangular matrix  and the strictly upper triangular part of
           A is not referenced.
           Note that when  DIAG = 'U' or 'u',  the diagonal elements of
           A  are not referenced either,  but are assumed to be  unity.
[in]LDA
          LDA is INTEGER
           On entry, LDA specifies the first dimension of A as declared
           in the calling (sub) program.  When  SIDE = 'L' or 'l'  then
           LDA  must be at least  max( 1, m ),  when  SIDE = 'R' or 'r'
           then LDA must be at least max( 1, n ).
[in,out]B
          B is COMPLEX array, dimension ( LDB, N )
           Before entry,  the leading  m by n part of the array  B must
           contain  the  right-hand  side  matrix  B,  and  on exit  is
           overwritten by the solution matrix  X.
[in]LDB
          LDB is INTEGER
           On entry, LDB specifies the first dimension of B as declared
           in  the  calling  (sub)  program.   LDB  must  be  at  least
           max( 1, m ).
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Further Details:
  Level 3 Blas routine.

  -- Written on 8-February-1989.
     Jack Dongarra, Argonne National Laboratory.
     Iain Duff, AERE Harwell.
     Jeremy Du Croz, Numerical Algorithms Group Ltd.
     Sven Hammarling, Numerical Algorithms Group Ltd.

Definition at line 179 of file ctrsm.f.

180*
181* -- Reference BLAS level3 routine --
182* -- Reference BLAS is a software package provided by Univ. of Tennessee, --
183* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
184*
185* .. Scalar Arguments ..
186 COMPLEX ALPHA
187 INTEGER LDA,LDB,M,N
188 CHARACTER DIAG,SIDE,TRANSA,UPLO
189* ..
190* .. Array Arguments ..
191 COMPLEX A(LDA,*),B(LDB,*)
192* ..
193*
194* =====================================================================
195*
196* .. External Functions ..
197 LOGICAL LSAME
198 EXTERNAL lsame
199* ..
200* .. External Subroutines ..
201 EXTERNAL xerbla
202* ..
203* .. Intrinsic Functions ..
204 INTRINSIC conjg,max
205* ..
206* .. Local Scalars ..
207 COMPLEX TEMP
208 INTEGER I,INFO,J,K,NROWA
209 LOGICAL LSIDE,NOCONJ,NOUNIT,UPPER
210* ..
211* .. Parameters ..
212 COMPLEX ONE
213 parameter(one= (1.0e+0,0.0e+0))
214 COMPLEX ZERO
215 parameter(zero= (0.0e+0,0.0e+0))
216* ..
217*
218* Test the input parameters.
219*
220 lside = lsame(side,'L')
221 IF (lside) THEN
222 nrowa = m
223 ELSE
224 nrowa = n
225 END IF
226 noconj = lsame(transa,'T')
227 nounit = lsame(diag,'N')
228 upper = lsame(uplo,'U')
229*
230 info = 0
231 IF ((.NOT.lside) .AND. (.NOT.lsame(side,'R'))) THEN
232 info = 1
233 ELSE IF ((.NOT.upper) .AND. (.NOT.lsame(uplo,'L'))) THEN
234 info = 2
235 ELSE IF ((.NOT.lsame(transa,'N')) .AND.
236 + (.NOT.lsame(transa,'T')) .AND.
237 + (.NOT.lsame(transa,'C'))) THEN
238 info = 3
239 ELSE IF ((.NOT.lsame(diag,'U')) .AND.
240 + (.NOT.lsame(diag,'N'))) THEN
241 info = 4
242 ELSE IF (m.LT.0) THEN
243 info = 5
244 ELSE IF (n.LT.0) THEN
245 info = 6
246 ELSE IF (lda.LT.max(1,nrowa)) THEN
247 info = 9
248 ELSE IF (ldb.LT.max(1,m)) THEN
249 info = 11
250 END IF
251 IF (info.NE.0) THEN
252 CALL xerbla('CTRSM ',info)
253 RETURN
254 END IF
255*
256* Quick return if possible.
257*
258 IF (m.EQ.0 .OR. n.EQ.0) RETURN
259*
260* And when alpha.eq.zero.
261*
262 IF (alpha.EQ.zero) THEN
263 DO 20 j = 1,n
264 DO 10 i = 1,m
265 b(i,j) = zero
266 10 CONTINUE
267 20 CONTINUE
268 RETURN
269 END IF
270*
271* Start the operations.
272*
273 IF (lside) THEN
274 IF (lsame(transa,'N')) THEN
275*
276* Form B := alpha*inv( A )*B.
277*
278 IF (upper) THEN
279 DO 60 j = 1,n
280 IF (alpha.NE.one) THEN
281 DO 30 i = 1,m
282 b(i,j) = alpha*b(i,j)
283 30 CONTINUE
284 END IF
285 DO 50 k = m,1,-1
286 IF (b(k,j).NE.zero) THEN
287 IF (nounit) b(k,j) = b(k,j)/a(k,k)
288 DO 40 i = 1,k - 1
289 b(i,j) = b(i,j) - b(k,j)*a(i,k)
290 40 CONTINUE
291 END IF
292 50 CONTINUE
293 60 CONTINUE
294 ELSE
295 DO 100 j = 1,n
296 IF (alpha.NE.one) THEN
297 DO 70 i = 1,m
298 b(i,j) = alpha*b(i,j)
299 70 CONTINUE
300 END IF
301 DO 90 k = 1,m
302 IF (b(k,j).NE.zero) THEN
303 IF (nounit) b(k,j) = b(k,j)/a(k,k)
304 DO 80 i = k + 1,m
305 b(i,j) = b(i,j) - b(k,j)*a(i,k)
306 80 CONTINUE
307 END IF
308 90 CONTINUE
309 100 CONTINUE
310 END IF
311 ELSE
312*
313* Form B := alpha*inv( A**T )*B
314* or B := alpha*inv( A**H )*B.
315*
316 IF (upper) THEN
317 DO 140 j = 1,n
318 DO 130 i = 1,m
319 temp = alpha*b(i,j)
320 IF (noconj) THEN
321 DO 110 k = 1,i - 1
322 temp = temp - a(k,i)*b(k,j)
323 110 CONTINUE
324 IF (nounit) temp = temp/a(i,i)
325 ELSE
326 DO 120 k = 1,i - 1
327 temp = temp - conjg(a(k,i))*b(k,j)
328 120 CONTINUE
329 IF (nounit) temp = temp/conjg(a(i,i))
330 END IF
331 b(i,j) = temp
332 130 CONTINUE
333 140 CONTINUE
334 ELSE
335 DO 180 j = 1,n
336 DO 170 i = m,1,-1
337 temp = alpha*b(i,j)
338 IF (noconj) THEN
339 DO 150 k = i + 1,m
340 temp = temp - a(k,i)*b(k,j)
341 150 CONTINUE
342 IF (nounit) temp = temp/a(i,i)
343 ELSE
344 DO 160 k = i + 1,m
345 temp = temp - conjg(a(k,i))*b(k,j)
346 160 CONTINUE
347 IF (nounit) temp = temp/conjg(a(i,i))
348 END IF
349 b(i,j) = temp
350 170 CONTINUE
351 180 CONTINUE
352 END IF
353 END IF
354 ELSE
355 IF (lsame(transa,'N')) THEN
356*
357* Form B := alpha*B*inv( A ).
358*
359 IF (upper) THEN
360 DO 230 j = 1,n
361 IF (alpha.NE.one) THEN
362 DO 190 i = 1,m
363 b(i,j) = alpha*b(i,j)
364 190 CONTINUE
365 END IF
366 DO 210 k = 1,j - 1
367 IF (a(k,j).NE.zero) THEN
368 DO 200 i = 1,m
369 b(i,j) = b(i,j) - a(k,j)*b(i,k)
370 200 CONTINUE
371 END IF
372 210 CONTINUE
373 IF (nounit) THEN
374 temp = one/a(j,j)
375 DO 220 i = 1,m
376 b(i,j) = temp*b(i,j)
377 220 CONTINUE
378 END IF
379 230 CONTINUE
380 ELSE
381 DO 280 j = n,1,-1
382 IF (alpha.NE.one) THEN
383 DO 240 i = 1,m
384 b(i,j) = alpha*b(i,j)
385 240 CONTINUE
386 END IF
387 DO 260 k = j + 1,n
388 IF (a(k,j).NE.zero) THEN
389 DO 250 i = 1,m
390 b(i,j) = b(i,j) - a(k,j)*b(i,k)
391 250 CONTINUE
392 END IF
393 260 CONTINUE
394 IF (nounit) THEN
395 temp = one/a(j,j)
396 DO 270 i = 1,m
397 b(i,j) = temp*b(i,j)
398 270 CONTINUE
399 END IF
400 280 CONTINUE
401 END IF
402 ELSE
403*
404* Form B := alpha*B*inv( A**T )
405* or B := alpha*B*inv( A**H ).
406*
407 IF (upper) THEN
408 DO 330 k = n,1,-1
409 IF (nounit) THEN
410 IF (noconj) THEN
411 temp = one/a(k,k)
412 ELSE
413 temp = one/conjg(a(k,k))
414 END IF
415 DO 290 i = 1,m
416 b(i,k) = temp*b(i,k)
417 290 CONTINUE
418 END IF
419 DO 310 j = 1,k - 1
420 IF (a(j,k).NE.zero) THEN
421 IF (noconj) THEN
422 temp = a(j,k)
423 ELSE
424 temp = conjg(a(j,k))
425 END IF
426 DO 300 i = 1,m
427 b(i,j) = b(i,j) - temp*b(i,k)
428 300 CONTINUE
429 END IF
430 310 CONTINUE
431 IF (alpha.NE.one) THEN
432 DO 320 i = 1,m
433 b(i,k) = alpha*b(i,k)
434 320 CONTINUE
435 END IF
436 330 CONTINUE
437 ELSE
438 DO 380 k = 1,n
439 IF (nounit) THEN
440 IF (noconj) THEN
441 temp = one/a(k,k)
442 ELSE
443 temp = one/conjg(a(k,k))
444 END IF
445 DO 340 i = 1,m
446 b(i,k) = temp*b(i,k)
447 340 CONTINUE
448 END IF
449 DO 360 j = k + 1,n
450 IF (a(j,k).NE.zero) THEN
451 IF (noconj) THEN
452 temp = a(j,k)
453 ELSE
454 temp = conjg(a(j,k))
455 END IF
456 DO 350 i = 1,m
457 b(i,j) = b(i,j) - temp*b(i,k)
458 350 CONTINUE
459 END IF
460 360 CONTINUE
461 IF (alpha.NE.one) THEN
462 DO 370 i = 1,m
463 b(i,k) = alpha*b(i,k)
464 370 CONTINUE
465 END IF
466 380 CONTINUE
467 END IF
468 END IF
469 END IF
470*
471 RETURN
472*
473* End of CTRSM
474*
subroutine xerbla(srname, info)
Definition cblat2.f:3285
logical function lsame(ca, cb)
LSAME
Definition lsame.f:48
Here is the call graph for this function:
Here is the caller graph for this function: