cosine-fast 0.1.0

Hot-loop cosine similarity for f32 slices. Auto-vectorized scalar core, optional precompute-norms helper. Zero deps.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# cosine-fast

[![crates.io](https://img.shields.io/crates/v/cosine-fast.svg)](https://crates.io/crates/cosine-fast)

Hot-loop cosine similarity for f32 slices. Scalar core that the
compiler auto-vectorizes well; `precompute_norm` for cheap repeated
queries.

```rust
use cosine_fast::{cosine, batch_cosine};
let a = vec![1.0f32, 2.0, 3.0];
let b = vec![2.0, 4.0, 6.0];
assert!((cosine(&a, &b) - 1.0).abs() < 1e-5);
```

Zero deps. MIT or Apache-2.0.