Code Monkey home page Code Monkey logo

eigen-js's Introduction

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 (optional, see below), 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 

If you are not interested in the OSQP functionality, you can build without installing it with

emcc -D NO_OSQP -I lib/eigen  -Isrc -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

eigen-js's People

Contributors

bertrandbev avatar lawsonfulton avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.