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

Function magnitude

org/src/main.rs:357–359  ·  view source on GitHub ↗
(vec: &[f32])

Source from the content-addressed store, hash-verified

355}
356
357fn magnitude(vec: &[f32]) -> f32 {
358 vec.iter().map(|&x| x * x).sum::<f32>().sqrt()
359}
360
361pub fn cosine_similarity(a: &[f32], b: &[f32]) -> f32 {
362 let dp = dot_product(a, b);

Callers 1

cosine_similarityFunction · 0.70

Calls 1

iterMethod · 0.45

Tested by

no test coverage detected