0.2.2 • Published 3 years ago

mathjs-translate v0.2.2

Weekly downloads
69
License
Apache-2.0
Repository
github
Last release
3 years ago

Autotests GitHub npm GitHub license

mathjs-translate

Utilities for manipulation of mathjs http://mathjs.org/ expressions.

Installation

npm install mathjs-translate

Usage

const math = require('mathjs');
math.import(require('mathsjs-translate'));

// translations
let matlabExpr = math
    .parse('min(x1,x2,x3) + log(x,b)')
    .translate(math.expression.translate.to.matlab)
    .toString();
console.log(matlabExpr);
// min([x1, x2, x3]) + log(x) / log(b)

// get
let functions = math
    .parse('min(x1,x2,x3) + log(x,b)')
    .getFunctions();
console.log(functions);
// ['min', 'log']

Browser

Browser version located in /dist

Structure of translator

let translator = {
    functionName: {
        exp: "exp1", // change name
        log: function(expression){ // change by function
            ...
            return node;
        }
    },
    symbolName: {
        x: "x1", // change name
        y: function(expression){ // change by function
            ...
            return node;
        }
    },
    operatorName: {
        pow: "pow1", // change name
        add: function(expression){ // change by function
            ...
            return node;
        }
    },
    constant: function(expression){ // change by function
        ...
        return node;
    },
    conditionalType: {
        larger: function(expression){ // change by function
            ...
            return node;
        }
    }
};

Author

  • Evgeny Metelkin @metelkin

Copyright

InSysBio, Moscow, 2017-2021 http://insysbio.com

0.2.1

3 years ago

0.2.2

3 years ago

0.2.0

3 years ago

0.1.10

3 years ago

0.1.9

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

6 years ago

0.1.0

6 years ago