1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT license.
*/
/// An overloadable, 2-argument distance function with a parameterized return type.
///
/// Pure distance functions depend only on the values of the argument and the type of the
/// return value.
/// An overloadable, 2-argument distance function with a parameterized return type.
///
/// Unlike `PureDistanceFunction`, this takes a functor as the receiver. This allows
/// distance functors to contain auxiliary state required to do their job
/// (for example, access to some shared quantization tables).
/// A mutable version of [`DistanceFunction`] that allows mutation of `Self`.
///
/// This trait is useful for computing distances where the distance functor holds
/// mutable state (e.g., a buffer to accumulate per-vector scores).
/// A distance function where one argument is static and interned within `Self`.
///
/// The method `self.evaluate_similarity` can then be invoked for arbitrarily many values of
/// `changing`.
///
/// The main idea behind this trait is to enable distance functions where some amount of
/// preprocessing on a query can be used to accelerate distance computations.
/// Evaluate a norm of the argument `x` and return the result as the requested type.
///
/// Note that while this has a similar signature to `PreprocessedDistanceFunction`, the
/// semantics of this trait are different. Implementations are expected to be light-weight
/// types that implement some kind of reduction on on `x`.