Hardware SIMD Math

In traditional Node.js environments, doing mathematical operations on Javascript Arrays requires V8's Just-In-Time (JIT) compiler to step element-by-element, leading to horrible memory thrashing.

Sofuu rewrites the rules. Hand-written SIMD kernels (AVX2 on x86_64, NEON on ARM) operate on your TypedArrays directly on the CPU's vector units. Cosine similarity, dot products, and L2 distances run practically instantaneously — no interpreter stepping between elements.

1
2
3
4
5
6
const v1 = new Float32Array([0.1, 0.5, 0.8]);
const v2 = new Float32Array([0.2, 0.4, 0.9]);
// Runs on the CPU's vector units — hand-written AVX2 / NEON kernels
const sim = sofuu.ai.similarity(v1, v2);
console.log(`Cosine Similarity: ${sim}`);
View full API specs