JSPM

ginac-wasm

0.5.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 6
  • Score
    100M100P100Q48062F
  • License GPL-2.0-only

WebAssembly bindings for the GiNaC computer algebra system

Package Exports

  • ginac-wasm

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ginac-wasm) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

GiNaC-WASM

WebAssembly bindings for the GiNaC computer algebra system

Demo frontend: https://daninet.github.io/ginac-wasm

Usage

const { initGiNaC, getFactory } = require('ginac-wasm');

(async () => {
  const GiNaC = await initGiNaC('ginac-wasm/dist/ginac.wasm');
  const g = getFactory();

  console.log(
    GiNaC([
      // 2 * 3 = 6
      g.mul(g.numeric('2'), g.numeric('3')),
      // x + 2x = 3x
      g.add(g.symbol('x'), g.mul(g.numeric('2'), g.symbol('x'))),
      // (2*sin(x))' = 2*cos(x)
      g.diff(g.mul(g.numeric('2'), g.sin(g.symbol('x'))), g.symbol('x')),
      // internal parser of GiNaC
      g.parse('x^3 + 3*x + 1') 
    ]),
  );

  console.log(
    GiNaC([
      g.numeric('2'),
      g.numeric('3'),
      // reference first and second items from the array => 2*3 = 6
      g.mul(g.ref(0), g.ref(1))
    ]),
  );

  // besides the string output format,
  // it can also generate traversable json structures
  console.dir(
    GiNaC([
      // 2*sin(x)
      g.mul(g.numeric('2'), g.sin(g.symbol('x'))),
    ], { json: true }),
    { depth: null }
  );
})();

For more details, see the source code of the demo frontend app.