Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
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
357
fn magnitude(vec: &[f32]) -> f32 {
358
vec.iter().map(|&x| x * x).sum::<f32>().sqrt()
359
}
360
361
pub fn cosine_similarity(a: &[f32], b: &[f32]) -> f32 {
362
let dp = dot_product(a, b);
Callers
1
cosine_similarity
Function · 0.70
Calls
1
iter
Method · 0.45
Tested by
no test coverage detected