Skip to main content

Getting Started

The goal of this project is to provide a fast, easy-to-use linear algebra Javascript library powered by WebAssembly, written in Rust.

Quick Start#

Here, to demonstrate, we'll be using vite to scaffold a project:

npm init vite@latest  # choose a simple vanilla js projectnpm i @ml.wasm/linalg

And add this to main.js:

main.js
import init, {  initThreadPool,  IntegersVector,  FloatsVector,  StringsVector,  IntegersMatrix,  FloatsMatrix,  StringsMatrix,} from '@ml.wasm/linalg';
(async () => {  // This init function sets up everything you need to use this library  await init();
  // This sets up the concurrency  await initThreadPool(navigator.hardwareConcurrency);
  // All your code goes here...})();

Note that you'll have to create a vite.config.js:

vite.config.js
export default {  server: {    fs: {      // Allow serving files from one level up to the project root      allow: ['..']    }  }}
Proper error handling not implemented yet

If you are familiar with Rust, currently all the functions just "panic". This will be fixed in the future.

For more information on how to work with one dimensional arrays or vectors go here. For two dimensional arrays or matrices go here.