The main documentation of the DotProduct_Mathematic_Vector Procedure contains additional explanation of this code listing.
function DotProduct_Mathematic_Vector (MV1, MV2) result(DotProduct)
! Input variables.
! Mathematic Vectors to be dotted.
type(Mathematic_Vector_type), intent(in) :: MV1, MV2
! Output variable.
type(real) :: DotProduct ! Result of dot product.
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
! Verify requirements.
VERIFY(Valid_State(MV1),5) ! MV1 is valid.
VERIFY(Valid_State(MV2),5) ! MV2 is valid.
! Calculate the global dot product.
DotProduct = Global_Dot_Product(MV1%Values, MV2%Values)
! Verify guarantees.
! Cauchy-Schwartz inequality must be satisfied
! (only checked if the Two Norms have already been calculated).
if (MV1%Two_Norm_is_Updated .and. MV2%Two_Norm_is_Updated) then
VERIFY(ABS(DotProduct) <= MV1%Two_Norm*MV2%Two_Norm,5)
end if
return
end function DotProduct_Mathematic_Vector