check if the triangle inequality for 3 variables hols
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=int32), | intent(in) | :: | x |
variables to check the triangle inequality |
||
integer(kind=int32), | intent(in) | :: | y |
variables to check the triangle inequality |
||
integer(kind=int32), | intent(in) | :: | z |
variables to check the triangle inequality |
(out) result: true/false
function triangle_inequality_holds(x, y, z) result(holds)
!! check if the triangle inequality for 3 variables hols
!---------------------------------------------------------------------!
integer(int32), intent(in) :: x, y, z
!! variables to check the triangle inequality
logical :: holds
!! (out) result: true/false
!---------------------------------------------------------------------!
holds = ( (x + y >= z) .and. (x + z >= y) .and. (y + z >= x) )
!---------------------------------------------------------------------!
end function triangle_inequality_holds