f_lin_manhattan_core Function

public pure function f_lin_manhattan_core(x, y) result(dist)

Compute Manhattan (L1) distance between vectors x and y.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x(:)

input vector 1

real(kind=wp), intent(in) :: y(:)

input vector 2

Return Value real(kind=wp)

Manhattan distance


Called by

proc~~f_lin_manhattan_core~~CalledByGraph proc~f_lin_manhattan_core f_lin_manhattan_core proc~f_lin_manhattan f_lin_manhattan proc~f_lin_manhattan->proc~f_lin_manhattan_core interface~fsml_manhattan fsml_manhattan interface~fsml_manhattan->proc~f_lin_manhattan

Source Code

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