STRSM solves one of the matrix equations op( A )X = alphaB, or Xop( A ) = alphaB, 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. The matrix X is overwritten on B.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=1), | intent(in) | :: | side | |||
character(len=1), | intent(in) | :: | uplo | |||
character(len=1), | intent(in) | :: | transa | |||
character(len=1), | intent(in) | :: | diag | |||
integer(kind=ilp), | intent(in) | :: | m | |||
integer(kind=ilp), | intent(in) | :: | n | |||
real(kind=sp), | intent(in) | :: | alpha | |||
real(kind=sp), | intent(in) | :: | a(lda,*) | |||
integer(kind=ilp), | intent(in) | :: | lda | |||
real(kind=sp), | intent(inout) | :: | b(ldb,*) | |||
integer(kind=ilp), | intent(in) | :: | ldb |
pure subroutine stdlib_strsm(side,uplo,transa,diag,m,n,alpha,a,lda,b,ldb) !! STRSM 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. !! The matrix X is overwritten on B. ! -- reference blas level3 routine -- ! -- reference blas is a software package provided by univ. of tennessee, -- ! -- univ. of california berkeley, univ. of colorado denver and nag ltd..-- ! Scalar Arguments real(sp), intent(in) :: alpha integer(ilp), intent(in) :: lda, ldb, m, n character, intent(in) :: diag, side, transa, uplo ! Array Arguments real(sp), intent(in) :: a(lda,*) real(sp), intent(inout) :: b(ldb,*) ! ===================================================================== ! Intrinsic Functions intrinsic :: max ! Local Scalars real(sp) :: temp integer(ilp) :: i, info, j, k, nrowa logical(lk) :: lside, nounit, upper ! test the input parameters. lside = stdlib_lsame(side,'L') if (lside) then nrowa = m else nrowa = n end if nounit = stdlib_lsame(diag,'N') upper = stdlib_lsame(uplo,'U') info = 0 if ((.not.lside) .and. (.not.stdlib_lsame(side,'R'))) then info = 1 else if ((.not.upper) .and. (.not.stdlib_lsame(uplo,'L'))) then info = 2 else if ((.not.stdlib_lsame(transa,'N')) .and.(.not.stdlib_lsame(transa,'T')) .and.(& .not.stdlib_lsame(transa,'C'))) then info = 3 else if ((.not.stdlib_lsame(diag,'U')) .and. (.not.stdlib_lsame(diag,'N'))) & then info = 4 else if (m<0) then info = 5 else if (n<0) then info = 6 else if (lda<max(1,nrowa)) then info = 9 else if (ldb<max(1,m)) then info = 11 end if if (info/=0) then call stdlib_xerbla('STRSM ',info) return end if ! quick return if possible. if (m==0 .or. n==0) return ! and when alpha.eq.zero. if (alpha==zero) then do j = 1,n do i = 1,m b(i,j) = zero end do end do return end if ! start the operations. if (lside) then if (stdlib_lsame(transa,'N')) then ! form b := alpha*inv( a )*b. if (upper) then do j = 1,n if (alpha/=one) then do i = 1,m b(i,j) = alpha*b(i,j) end do end if do k = m,1,-1 if (b(k,j)/=zero) then if (nounit) b(k,j) = b(k,j)/a(k,k) do i = 1,k - 1 b(i,j) = b(i,j) - b(k,j)*a(i,k) end do end if end do end do else do j = 1,n if (alpha/=one) then do i = 1,m b(i,j) = alpha*b(i,j) end do end if do k = 1,m if (b(k,j)/=zero) then if (nounit) b(k,j) = b(k,j)/a(k,k) do i = k + 1,m b(i,j) = b(i,j) - b(k,j)*a(i,k) end do end if end do end do end if else ! form b := alpha*inv( a**t )*b. if (upper) then do j = 1,n do i = 1,m temp = alpha*b(i,j) do k = 1,i - 1 temp = temp - a(k,i)*b(k,j) end do if (nounit) temp = temp/a(i,i) b(i,j) = temp end do end do else do j = 1,n do i = m,1,-1 temp = alpha*b(i,j) do k = i + 1,m temp = temp - a(k,i)*b(k,j) end do if (nounit) temp = temp/a(i,i) b(i,j) = temp end do end do end if end if else if (stdlib_lsame(transa,'N')) then ! form b := alpha*b*inv( a ). if (upper) then do j = 1,n if (alpha/=one) then do i = 1,m b(i,j) = alpha*b(i,j) end do end if do k = 1,j - 1 if (a(k,j)/=zero) then do i = 1,m b(i,j) = b(i,j) - a(k,j)*b(i,k) end do end if end do if (nounit) then temp = one/a(j,j) do i = 1,m b(i,j) = temp*b(i,j) end do end if end do else do j = n,1,-1 if (alpha/=one) then do i = 1,m b(i,j) = alpha*b(i,j) end do end if do k = j + 1,n if (a(k,j)/=zero) then do i = 1,m b(i,j) = b(i,j) - a(k,j)*b(i,k) end do end if end do if (nounit) then temp = one/a(j,j) do i = 1,m b(i,j) = temp*b(i,j) end do end if end do end if else ! form b := alpha*b*inv( a**t ). if (upper) then do k = n,1,-1 if (nounit) then temp = one/a(k,k) do i = 1,m b(i,k) = temp*b(i,k) end do end if do j = 1,k - 1 if (a(j,k)/=zero) then temp = a(j,k) do i = 1,m b(i,j) = b(i,j) - temp*b(i,k) end do end if end do if (alpha/=one) then do i = 1,m b(i,k) = alpha*b(i,k) end do end if end do else do k = 1,n if (nounit) then temp = one/a(k,k) do i = 1,m b(i,k) = temp*b(i,k) end do end if do j = k + 1,n if (a(j,k)/=zero) then temp = a(j,k) do i = 1,m b(i,j) = b(i,j) - temp*b(i,k) end do end if end do if (alpha/=one) then do i = 1,m b(i,k) = alpha*b(i,k) end do end if end do end if end if end if return end subroutine stdlib_strsm