Compute Manhattan (L1) distance between vectors x and y.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=wp), | intent(in) | :: | x(:) |
input vector 1 |
||
| real(kind=wp), | intent(in) | :: | y(:) |
input vector 2 |
Manhattan distance
pure function f_lin_manhattan_core(x, y) result(dist) ! ==== Description !! Compute Manhattan (L1) distance between vectors x and y. ! ==== Declarations real(wp), intent(in) :: x(:) !! input vector 1 real(wp), intent(in) :: y(:) !! input vector 2 real(wp) :: dist !! Manhattan distance integer(i4) :: m !! vector length integer(i4) :: i ! ==== Instructions ! get dims m = size(x) ! calculate distance dist = 0.0_wp do i = 1, m dist = dist + abs(x(i) - y(i)) enddo end function f_lin_manhattan_core