Interface ElementDistance<V>

Type Parameters:
V - the vector type
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

Defines the distance of two elements of a given vector type V. The following example creates an ElementDistance function for a double[] array:
final ElementDistance<double[]> dist = (u, v, i) -> u[i] - v[i];
Since:
4.1
Version:
4.1
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    distance(V u, V v, int index)
    Calculates the distance of two vector elements at the given index.
    default <T> ElementDistance<T>
    map(Function<? super T,? extends V> mapper)
    Return an element distance function for the mapped type T.
    ofIndex(int index)
    Return a function which calculates the distance of two vector elements at a given index.
  • Method Details

    • distance

      double distance(V u, V v, int index)
      Calculates the distance of two vector elements at the given index. E.g.
      final ElementDistance<double[]> dist = (u, v, i) -> u[i] - v[i];
      
      Parameters:
      u - the first vector
      v - the second vector
      index - the vector index
      Returns:
      the distance of the two element vectors
    • map

      default <T> ElementDistance<T> map(Function<? super T,? extends V> mapper)
      Return an element distance function for the mapped type T.
      Type Parameters:
      T - the new distance type
      Parameters:
      mapper - the mapper function
      Returns:
      an element distance function for the mapped type T
    • ofIndex

      default ToDoubleBiFunction<V,V> ofIndex(int index)
      Return a function which calculates the distance of two vector elements at a given index.
      Parameters:
      index - the vector index
      Returns:
      a function which calculates the distance of two vector elements