l1Distance.php
Table of Contents
Functions
- l1Distance() : string
- Return the L1 (Manhattan / taxicab) distance between two vectors.
Functions
l1Distance()
Return the L1 (Manhattan / taxicab) distance between two vectors.
l1Distance(string|int $x, string|int $y) : string
This helper wraps the ArangoDB AQL function L1_DISTANCE(x, y) which
calculates the sum of the absolute differences between the components of
two equally-sized numeric vectors. The smaller the value, the closer the
vectors are.
Unlike approxNearL2(), this computes the exact distance and does not require (nor benefit from) a vector index.
Example AQL usage:
L1_DISTANCE([1, 2], [4, 6]) // returns 7 (|1-4| + |2-6|)
L1_DISTANCE([0, 0], [0, 0]) // returns 0 (identical vectors)
Parameters
- $x : string|int
-
First input array (vector).
- $y : string|int
-
Second input array (vector).
Tags
Return values
string —The formatted AQL expression.