3 ms·
Three separate passes over JavaScript arrays are quite costly, especially for high-dimensional vectors. I'd recommend using `TypedArray` with vanilla `for` loop
by ashvardanian 2y ago
Three separate passes over JavaScript arrays are quite costly, especially for high-dimensional vectors. I'd recommend using `TypedArray` with vanilla `for` loops. It will make things faster, and will allow using C extensions, if you want to benefit from modern hardware features, while still implementing the logic in JavaScript: https://ashvardanian.com/posts/javascript-ai-vector-search/ https://ashvardanian.com/posts/javascript-ai-vector-search/