项目作者: insysbio

项目描述 :
Utilites for manipulation of mathjs expressions.
高级语言: JavaScript
项目地址: git://github.com/insysbio/mathjs-translate.git
创建时间: 2018-06-04T18:04:55Z
项目社区:https://github.com/insysbio/mathjs-translate

开源协议:Apache License 2.0

下载


Autotests
GitHub npm
GitHub license

mathjs-translate

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

Installation

  1. npm install mathjs-translate

Usage

  1. const math = require('mathjs');
  2. math.import(require('mathsjs-translate'));
  3. // translations
  4. let matlabExpr = math
  5. .parse('min(x1,x2,x3) + log(x,b)')
  6. .translate(math.expression.translate.to.matlab)
  7. .toString();
  8. console.log(matlabExpr);
  9. // min([x1, x2, x3]) + log(x) / log(b)
  10. // get
  11. let functions = math
  12. .parse('min(x1,x2,x3) + log(x,b)')
  13. .getFunctions();
  14. console.log(functions);
  15. // ['min', 'log']

Browser

Browser version located in /dist

Structure of translator

  1. let translator = {
  2. functionName: {
  3. exp: "exp1", // change name
  4. log: function(expression){ // change by function
  5. ...
  6. return node;
  7. }
  8. },
  9. symbolName: {
  10. x: "x1", // change name
  11. y: function(expression){ // change by function
  12. ...
  13. return node;
  14. }
  15. },
  16. operatorName: {
  17. pow: "pow1", // change name
  18. add: function(expression){ // change by function
  19. ...
  20. return node;
  21. }
  22. },
  23. constant: function(expression){ // change by function
  24. ...
  25. return node;
  26. },
  27. conditionalType: {
  28. larger: function(expression){ // change by function
  29. ...
  30. return node;
  31. }
  32. }
  33. };

Author

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