(
&self,
x: &VectorData,
y: &VectorData,
is_indexing: bool,
)
| 472 | impl DistanceFunction for DistanceMetric { |
| 473 | type Item = MetricResult; |
| 474 | fn calculate( |
| 475 | &self, |
| 476 | x: &VectorData, |
| 477 | y: &VectorData, |
| 478 | is_indexing: bool, |
| 479 | ) -> Result<Self::Item, DistanceError> { |
| 480 | match self { |
| 481 | Self::Cosine => { |
| 482 | let value = CosineSimilarity(0.0).calculate(x, y, is_indexing)?; |
| 483 | Ok(MetricResult::CosineSimilarity(value)) |
| 484 | } |
| 485 | Self::Euclidean => { |
| 486 | let value = EuclideanDistance(0.0).calculate(x, y, is_indexing)?; |
| 487 | Ok(MetricResult::EuclideanDistance(value)) |
| 488 | } |
| 489 | Self::Hamming => { |
| 490 | let value = HammingDistance(0.0).calculate(x, y, is_indexing)?; |
| 491 | Ok(MetricResult::HammingDistance(value)) |
| 492 | } |
| 493 | Self::DotProduct => { |
| 494 | let value = DotProductDistance(0.0).calculate(x, y, is_indexing)?; |
| 495 | Ok(MetricResult::DotProductDistance(value)) |
| 496 | } |
| 497 | } |
| 498 | } |
| 499 | } |
| 500 | |
| 501 | #[derive(Debug, Clone, Serialize, Deserialize)] |
no test coverage detected