Git Product home page Git Product logo

ginac-wasm's Introduction

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(require.resolve('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.

ginac-wasm's People

Contributors

daninet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

spacedreams

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.