Vector functions
VECTOR_MANHATTAN_DISTANCE
Reference material for VECTOR_MANHATTAN_DISTANCE function
VECTOR_MANHATTAN_DISTANCE
Returns the Manhattan, or L1 distance, between two vectors. The Manhattan distance measures the total distance by moving strictly along orthogonal axes, similar to navigating streets in a city grid. It is calculated as the sum of absolute differences between corresponding elements of two vectors.
Syntax
Parameters
Parameter | Description | Supported input types |
---|---|---|
<array> | The first array used in the distance calculation. | Any array of numeric data types. |
<array> | The second array used in the distance calculation. | Any array of numeric data types. |
Notes
Both input array
arguments must have the same number of elements.
Return Type
DOUBLE
Examples
Example
The following code returns the Manhattan distance between two vectors: The Manhattan distance is calculated as the sum of absolute differences: |3 - 1| + |2 - 4| = 4.
Returns
distance (DOUBLE PRECISION) |
---|
4 |