LAPACK  3.10.0
LAPACK: Linear Algebra PACKage

◆ 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. (.NOT.lsame(diag,'N'))) THEN
240  info = 4
241  ELSE IF (m.LT.0) THEN
242  info = 5
243  ELSE IF (n.LT.0) THEN
244  info = 6
245  ELSE IF (lda.LT.max(1,nrowa)) THEN
246  info = 9
247  ELSE IF (ldb.LT.max(1,m)) THEN
248  info = 11
249  END IF
250  IF (info.NE.0) THEN
251  CALL xerbla('CTRSM ',info)
252  RETURN
253  END IF
254 *
255 * Quick return if possible.
256 *
257  IF (m.EQ.0 .OR. n.EQ.0) RETURN
258 *
259 * And when alpha.eq.zero.
260 *
261  IF (alpha.EQ.zero) THEN
262  DO 20 j = 1,n
263  DO 10 i = 1,m
264  b(i,j) = zero
265  10 CONTINUE
266  20 CONTINUE
267  RETURN
268  END IF
269 *
270 * Start the operations.
271 *
272  IF (lside) THEN
273  IF (lsame(transa,'N')) THEN
274 *
275 * Form B := alpha*inv( A )*B.
276 *
277  IF (upper) THEN
278  DO 60 j = 1,n
279  IF (alpha.NE.one) THEN
280  DO 30 i = 1,m
281  b(i,j) = alpha*b(i,j)
282  30 CONTINUE
283  END IF
284  DO 50 k = m,1,-1
285  IF (b(k,j).NE.zero) THEN
286  IF (nounit) b(k,j) = b(k,j)/a(k,k)
287  DO 40 i = 1,k - 1
288  b(i,j) = b(i,j) - b(k,j)*a(i,k)
289  40 CONTINUE
290  END IF
291  50 CONTINUE
292  60 CONTINUE
293  ELSE
294  DO 100 j = 1,n
295  IF (alpha.NE.one) THEN
296  DO 70 i = 1,m
297  b(i,j) = alpha*b(i,j)
298  70 CONTINUE
299  END IF
300  DO 90 k = 1,m
301  IF (b(k,j).NE.zero) THEN
302  IF (nounit) b(k,j) = b(k,j)/a(k,k)
303  DO 80 i = k + 1,m
304  b(i,j) = b(i,j) - b(k,j)*a(i,k)
305  80 CONTINUE
306  END IF
307  90 CONTINUE
308  100 CONTINUE
309  END IF
310  ELSE
311 *
312 * Form B := alpha*inv( A**T )*B
313 * or B := alpha*inv( A**H )*B.
314 *
315  IF (upper) THEN
316  DO 140 j = 1,n
317  DO 130 i = 1,m
318  temp = alpha*b(i,j)
319  IF (noconj) THEN
320  DO 110 k = 1,i - 1
321  temp = temp - a(k,i)*b(k,j)
322  110 CONTINUE
323  IF (nounit) temp = temp/a(i,i)
324  ELSE
325  DO 120 k = 1,i - 1
326  temp = temp - conjg(a(k,i))*b(k,j)
327  120 CONTINUE
328  IF (nounit) temp = temp/conjg(a(i,i))
329  END IF
330  b(i,j) = temp
331  130 CONTINUE
332  140 CONTINUE
333  ELSE
334  DO 180 j = 1,n
335  DO 170 i = m,1,-1
336  temp = alpha*b(i,j)
337  IF (noconj) THEN
338  DO 150 k = i + 1,m
339  temp = temp - a(k,i)*b(k,j)
340  150 CONTINUE
341  IF (nounit) temp = temp/a(i,i)
342  ELSE
343  DO 160 k = i + 1,m
344  temp = temp - conjg(a(k,i))*b(k,j)
345  160 CONTINUE
346  IF (nounit) temp = temp/conjg(a(i,i))
347  END IF
348  b(i,j) = temp
349  170 CONTINUE
350  180 CONTINUE
351  END IF
352  END IF
353  ELSE
354  IF (lsame(transa,'N')) THEN
355 *
356 * Form B := alpha*B*inv( A ).
357 *
358  IF (upper) THEN
359  DO 230 j = 1,n
360  IF (alpha.NE.one) THEN
361  DO 190 i = 1,m
362  b(i,j) = alpha*b(i,j)
363  190 CONTINUE
364  END IF
365  DO 210 k = 1,j - 1
366  IF (a(k,j).NE.zero) THEN
367  DO 200 i = 1,m
368  b(i,j) = b(i,j) - a(k,j)*b(i,k)
369  200 CONTINUE
370  END IF
371  210 CONTINUE
372  IF (nounit) THEN
373  temp = one/a(j,j)
374  DO 220 i = 1,m
375  b(i,j) = temp*b(i,j)
376  220 CONTINUE
377  END IF
378  230 CONTINUE
379  ELSE
380  DO 280 j = n,1,-1
381  IF (alpha.NE.one) THEN
382  DO 240 i = 1,m
383  b(i,j) = alpha*b(i,j)
384  240 CONTINUE
385  END IF
386  DO 260 k = j + 1,n
387  IF (a(k,j).NE.zero) THEN
388  DO 250 i = 1,m
389  b(i,j) = b(i,j) - a(k,j)*b(i,k)
390  250 CONTINUE
391  END IF
392  260 CONTINUE
393  IF (nounit) THEN
394  temp = one/a(j,j)
395  DO 270 i = 1,m
396  b(i,j) = temp*b(i,j)
397  270 CONTINUE
398  END IF
399  280 CONTINUE
400  END IF
401  ELSE
402 *
403 * Form B := alpha*B*inv( A**T )
404 * or B := alpha*B*inv( A**H ).
405 *
406  IF (upper) THEN
407  DO 330 k = n,1,-1
408  IF (nounit) THEN
409  IF (noconj) THEN
410  temp = one/a(k,k)
411  ELSE
412  temp = one/conjg(a(k,k))
413  END IF
414  DO 290 i = 1,m
415  b(i,k) = temp*b(i,k)
416  290 CONTINUE
417  END IF
418  DO 310 j = 1,k - 1
419  IF (a(j,k).NE.zero) THEN
420  IF (noconj) THEN
421  temp = a(j,k)
422  ELSE
423  temp = conjg(a(j,k))
424  END IF
425  DO 300 i = 1,m
426  b(i,j) = b(i,j) - temp*b(i,k)
427  300 CONTINUE
428  END IF
429  310 CONTINUE
430  IF (alpha.NE.one) THEN
431  DO 320 i = 1,m
432  b(i,k) = alpha*b(i,k)
433  320 CONTINUE
434  END IF
435  330 CONTINUE
436  ELSE
437  DO 380 k = 1,n
438  IF (nounit) THEN
439  IF (noconj) THEN
440  temp = one/a(k,k)
441  ELSE
442  temp = one/conjg(a(k,k))
443  END IF
444  DO 340 i = 1,m
445  b(i,k) = temp*b(i,k)
446  340 CONTINUE
447  END IF
448  DO 360 j = k + 1,n
449  IF (a(j,k).NE.zero) THEN
450  IF (noconj) THEN
451  temp = a(j,k)
452  ELSE
453  temp = conjg(a(j,k))
454  END IF
455  DO 350 i = 1,m
456  b(i,j) = b(i,j) - temp*b(i,k)
457  350 CONTINUE
458  END IF
459  360 CONTINUE
460  IF (alpha.NE.one) THEN
461  DO 370 i = 1,m
462  b(i,k) = alpha*b(i,k)
463  370 CONTINUE
464  END IF
465  380 CONTINUE
466  END IF
467  END IF
468  END IF
469 *
470  RETURN
471 *
472 * End of CTRSM
473 *
subroutine xerbla(SRNAME, INFO)
XERBLA
Definition: xerbla.f:60
logical function lsame(CA, CB)
LSAME
Definition: lsame.f:53
Here is the call graph for this function:
Here is the caller graph for this function: