MCPcopy Create free account
hub / github.com/cosdata/cosdata / dot_product

Function dot_product

org/src/main.rs:353–355  ·  view source on GitHub ↗
(a: &[f32], b: &[f32])

Source from the content-addressed store, hash-verified

351}
352
353fn dot_product(a: &[f32], b: &[f32]) -> f32 {
354 a.iter().zip(b.iter()).map(|(&x, &y)| x * y).sum()
355}
356
357fn magnitude(vec: &[f32]) -> f32 {
358 vec.iter().map(|&x| x * x).sum::<f32>().sqrt()

Callers 1

cosine_similarityFunction · 0.70

Calls 1

iterMethod · 0.45

Tested by

no test coverage detected