Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1332633 - Part 1: Implement ComputeDistance trait.
Introduce ComputeDistance trait, which implement compute_distance and compute_squared_distance. For vector, compute_squared_distance is necessary because we use Euclidean distance as the distance between two values. The easier way to implement compute_squared_distance is to square the result from compute_distance, but for some property values, they may have many components, e.g. (v1, v2, v3). If we just square the result from compute_distance, the computation is (sqrt(v1^2 + v2^2 + v3^2))^2. There are two redundant operators: "square-root" and then "square". In order to avoid this, we should implement compute_squared_distance separately for these types. MozReview-Commit-ID: LmmrUXYlDb6
- Loading branch information