The main documentation of the Residual_ELL_Matrix Procedure contains additional explanation of this code listing.
subroutine Residual_ELL_Matrix (Residual_MV, A_ELLM, X_MV, B_MV)
! Input variables.
! ELL Matrix to be multiplied.
type(ELL_Matrix_type), intent(inout) :: A_ELLM
! Mathematic Vector to be multiplied.
type(Mathematic_Vector_type), intent(inout) :: X_MV
! Mathematic Vector to be subtracted.
type(Mathematic_Vector_type), intent(inout) :: B_MV
! Output variable.
! Residual vector.
type(Mathematic_Vector_type), intent(inout) :: Residual_MV
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
! Verify requirements.
VERIFY(Valid_State(A_ELLM),5) ! A_ELLM is valid.
VERIFY(Valid_State(X_MV),5) ! X_MV is valid.
VERIFY(Valid_State(B_MV),5) ! B_MV is valid.
VERIFY(Valid_State(Residual_MV),5) ! Residual_MV is valid.
! X_MV has same Structure as A_ELLM Column_Structure.
VERIFY(ASSOCIATED(A_ELLM%Column_Structure,X_MV%Structure),5)
! B_MV and Residual_MV have same Structure as A_ELLM Row_Structure.
VERIFY(ASSOCIATED(A_ELLM%Row_Structure,B_MV%Structure),5)
VERIFY(ASSOCIATED(A_ELLM%Row_Structure,Residual_MV%Structure),5)
! Do the MatVec, store in the Residual (Residual = A x).
call MatVec (A_ELLM, X_MV, Residual_MV)
! Subtract B. (Residual = Residual - B).
Residual_MV%Values = Residual_MV%Values - B_MV%Values
! Unset the updated? variables.
call Set_Not_Up_to_Date (Residual_MV)
! Verify guarantees - none.
return
end subroutine Residual_ELL_Matrix