tril Subroutine

public subroutine tril(a, n, alower)

Routine to extract the lower triangular part of a square matrix author: P J Knight, CCFE, Culham Science Centre a(n,n) : input real array : input matrix n : input integer : number of rows and columns in A a(n,n) : output real array : lower triangular part of A This routine extracts the lower triangular part of a square matrix, excluding the diagonal, into a new square matrix. The remainder of this matrix contains zeroes on exit. None

Arguments

Type IntentOptional AttributesName
real(kind=dp), intent(in), dimension(n,n):: a
integer, intent(in) :: n
real(kind=dp), intent(out), dimension(n,n):: alower

Contents

Source Code


Source Code

  subroutine tril(a,n,alower)

    !! Routine to extract the lower triangular part of a square matrix
    !! author: P J Knight, CCFE, Culham Science Centre
    !! a(n,n) : input real array : input matrix
    !! n      : input integer : number of rows and columns in A
    !! a(n,n) : output real array : lower triangular part of A
    !! This routine extracts the lower triangular part of a square matrix,
    !! excluding the diagonal, into a new square matrix. The remainder
    !! of this matrix contains zeroes on exit.
    !! None
    !
    ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    implicit none

    !  Arguments

    integer, intent(in) :: n
    real(dp), dimension(n,n), intent(in) :: a
    real(dp), dimension(n,n), intent(out) :: alower

    !  Local variables

    integer :: row,col

    ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    alower = 0.0D0
    do col = 1,n-1
       do row = col+1,n
          alower(row,col) = a(row,col)
       end do
    end do

  end subroutine tril