Shared in-memory cosine maths for the vector query functions.
Used by evaluate/1 in AshNeo4j.Functions.VectorSimilarity and
AshNeo4j.Functions.VectorCosineDistance so the data layer's in-memory
correctness re-filter (Ash.Filter.Runtime) produces the same values as the
Cypher pushdown. Neo4j normalises cosine similarity to [0, 1] as
(1 + raw_cosine) / 2; the callers derive their results from raw_cosine/2
accordingly.
Summary
Functions
True when a and b are equal-length, non-empty numeric lists.
Raw cosine similarity in [-1.0, 1.0] — dot(a, b) / (‖a‖ · ‖b‖).
Functions
True when a and b are equal-length, non-empty numeric lists.
Raw cosine similarity in [-1.0, 1.0] — dot(a, b) / (‖a‖ · ‖b‖).
Returns 0.0 if either vector has zero magnitude. Assumes
comparable_vectors?/2 already held.