How to use the chain function from mathjs
Find comprehensive JavaScript mathjs.chain code examples handpicked from public code repositorys.
492 493 494 495 496 497 498 499 500 501
function getNextPath(cy, cy2, intermediateCities, startingCity, seconds) { // if permutations to do if (!stopPathFinding) { // start timer var timer = setTimeout(function() {getNextPath(cy, cy2, intermediateCities, startingCity, seconds);}, 100); seconds = Mathjs.chain(seconds).subtract(1).done(); formatTime(seconds); computeAndDisplayNextRoute(cy, cy2, intermediateCities, startingCity); } if (stopPathFinding && !stoppedMidExecution) {
75
325
0
GitHub: mljs/matrix
23 24 25 26 27 28 29 30 31 32
}) .add('numeric', () => { numeric.abs(numeric.muleq(numeric.subeq(matrixNum, 5), Math.PI)); }) .add('mathjs', () => { math.chain(matrixMath).subtract(5).multiply(Math.PI).abs().done(); }) .on('cycle', (event) => { console.log(String(event.target)); })
51
321
14
+ 3 other calls in file
13 14 15 16 17 18 19 20 21
math.evaluate('sin(45 deg) ^ 2') // 0.5 math.evaluate('9 / 3 + 2i') // 3 + 2i math.evaluate('det([-1, 2; 3, 1])') // -7 // chaining const res = math.chain(3) .add(4) .multiply(2) .done() // 14
4
48
5
+ 3 other calls in file
51 52 53 54 55 56 57 58 59 60
$ cat ./demo.js ``` ```javascript const math = require('mathjs'); module.exports = function (context, payload) { return { myField: math.chain(payload.val).add(4).divide(4).done() } }; ``` ```bash
5
3
5
+ 9 other calls in file
44 45 46 47 48 49 50 51 52 53
jx.push(_jx_1 - _jx_2); } let _bes = q.map(val => BESSEL.besselj(val*h,0)); let bes = maths.chain(q).dotMultiply(h).dotMultiply(_bes).done(); let oros = maths.chain(jx).dotDivide(q).dotDivide(maths.dotPow(bes, 2)).done(); const j2 = maths.complex('i'); var dz = [];
2
3
0
+ 5 other calls in file
GitHub: jly36963/notes
8 9 10 11 12 13 14 15 16 17 18
//--- // Chaining //--- const basicChain = () => { math.chain(3) .add(4) .subtract(2) .done() // 5 }
0
3
0
+ 6 other calls in file
GitHub: SSDWGG/sop
45 46 47 48 49 50 51 52 53 54 55
function comp(_func, args) { for (let i=0; i<args.length; i++) { if(!args[i]) args[i] = 0 } let t = $math.chain($math.bignumber(args[0])); for (let i=1; i<args.length; i++) { t = t[_func]($math.bignumber(args[i])) } // 防止超过6位使用科学计数法
0
0
0
GitHub: OrghoN/hillCipher
14 15 16 17 18 19 20 21 22 23 24 25 26
// }); function adjugate(matrix) { var det = math.det(matrix); return math.chain(matrix).inv().map(function(val) { return (math.round(val * det)); }).done(); }
0
0
0
+ 3 other calls in file
mathjs.evaluate is the most popular function in mathjs (87200 examples)