- 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 TypeMethodDescriptiondouble
Calculates the distance of two vector elements at the givenindex
.default <T> ElementDistance
<T> Return an element distance function for the mapped typeT
.default ToDoubleBiFunction
<V, V> ofIndex
(int index) Return a function which calculates the distance of two vector elements at a givenindex
.
-
Method Details
-
distance
Calculates the distance of two vector elements at the givenindex
. E.g.final ElementDistance<double[]> dist = (u, v, i) -> u[i] - v[i];
- Parameters:
u
- the first vectorv
- the second vectorindex
- the vector index- Returns:
- the distance of the two element vectors
-
map
Return an element distance function for the mapped typeT
.- Type Parameters:
T
- the new distance type- Parameters:
mapper
- the mapper function- Returns:
- an element distance function for the mapped type
T
-
ofIndex
Return a function which calculates the distance of two vector elements at a givenindex
.- Parameters:
index
- the vector index- Returns:
- a function which calculates the distance of two vector elements
-