subbak Subroutine

subroutine subbak(w, ipivot, nrow, ncol, last, x)

************80

! SUBBAK carries out back substitution for the current block.

Modified:

14 February 2007

Author:

Carl DeBoor

Reference:

Carl DeBoor,
A Practical Guide to Splines,
Springer, 2001,
ISBN: 0387953663,
LC: QA1.A647.v27.

Parameters:

Input, real ( kind = 8 ) W(NROW,NCOL), integer IPIVOT(NROW), integer
NROW, integer NCOL, integer LAST, are as on return from FACTRB.

Input/output, real ( kind = 8 ) X(NCOL).
On input, the right hand side for the equations in this block after
back substitution has been carried out up to, but not including,
equation IPIVOT(LAST).  This means that X(1:LAST) contains the right hand
sides of equation IPIVOT(1:LAST) as modified during elimination,
while X(LAST+1:NCOL) is already a component of the solution vector.
On output, the components of the solution corresponding to the present
block.

Arguments

Type IntentOptional Attributes Name
real(kind=8) :: w(nrow,ncol)
integer(kind=4) :: ipivot(nrow)
integer(kind=4) :: nrow
integer(kind=4) :: ncol
integer(kind=4) :: last
real(kind=8) :: x(ncol)

Source Code

subroutine subbak ( w, ipivot, nrow, ncol, last, x )

  !*****************************************************************************80
  !
  !! SUBBAK carries out back substitution for the current block.
  !
  !  Modified:
  !
  !    14 February 2007
  !
  !  Author:
  !
  !    Carl DeBoor
  !
  !  Reference:
  !
  !    Carl DeBoor,
  !    A Practical Guide to Splines,
  !    Springer, 2001,
  !    ISBN: 0387953663,
  !    LC: QA1.A647.v27.
  !
  !  Parameters:
  !
  !    Input, real ( kind = 8 ) W(NROW,NCOL), integer IPIVOT(NROW), integer
  !    NROW, integer NCOL, integer LAST, are as on return from FACTRB.
  !
  !    Input/output, real ( kind = 8 ) X(NCOL).
  !    On input, the right hand side for the equations in this block after 
  !    back substitution has been carried out up to, but not including,
  !    equation IPIVOT(LAST).  This means that X(1:LAST) contains the right hand
  !    sides of equation IPIVOT(1:LAST) as modified during elimination,
  !    while X(LAST+1:NCOL) is already a component of the solution vector.
  !    On output, the components of the solution corresponding to the present
  !    block.
  !
  implicit none

  integer ( kind = 4 ) ncol
  integer ( kind = 4 ) nrow

  integer ( kind = 4 ) ip
  integer ( kind = 4 ) ipivot(nrow)
  integer ( kind = 4 ) k
  integer ( kind = 4 ) last
  real ( kind = 8 ) w(nrow,ncol)
  real ( kind = 8 ) x(ncol)

  do k = last, 1, -1

     ip = ipivot(k)

     x(k) = ( x(k) - dot_product ( w(ip,k+1:ncol), x(k+1:ncol) ) ) / w(ip,k)

  end do

  return
end subroutine subbak