eigen

Eigen-js is a port of the [Eigen](https://eigen.tuxfamily.org/) C++ linear algebra library

Usage no npm install needed!

<script type="module">
  import eigen from 'https://cdn.skypack.dev/eigen';
</script>

README

npm version Website shields.io Made with emscripten GitHub license

Eigen.js

Eigen.js is a port of the Eigen C++ linear algebra library

It uses a WebAssembly compiled subset of the Eigen library, and implements a garbage collection mechanism to manage memory

HomeDocumentationBenchmarks

Usage

Eigen.js can be installed via npm or yarn

npm install eigen
yarn add eigen

In a node (v14) application or in the browser (using webpack)

// test.mjs
import eig from 'eigen'

(async () => {
  await eig.ready
  const M = new eig.Matrix([[1, 2], [3, 4]])
  M.print("M");
  M.inverse();
  M.print("Minv");
  eig.GC.flush();
})();

This minimal example can be found under ./example

Documentation

The documentation is available at eigen.js

Build

Make sure Emscripten is intalled & activated in your terminal session

source path/to/emsdk/emsdk_env.sh
emcc -v

Dowload the latest versions of Eigen and OSPQ, and put then in the lib directory

lib/eigen
lib/ospq

Now compile osqp for a Webassembly target

cd lib/ospq
mkdir build; cd build
emcmake cmake ..
emmake make

Once done, eigen.js can be compile to a wasm binary

# From the root directory
mkdir build
emcc -I lib/eigen -I lib/osqp/include -Isrc lib/osqp/build/out/libosqp.a -s DISABLE_EXCEPTION_CATCHING=0 -s ASSERTIONS=0 -O3 -s ALLOW_MEMORY_GROWTH=1 -s MODULARIZE=1 --bind -o build/eigen_gen.js src/cpp/embind.cc 

Generate the documentation

The documentation is generated from classes descriptions using documentation.js

documentation build src/classes/ -f json -o docs/doc.json