From 5e49cdc501a3154099c873db5be8cb146d4939b8 Mon Sep 17 00:00:00 2001 From: Martin Donk Date: Sat, 21 Mar 2020 19:48:00 -0500 Subject: [PATCH] Fix diff for matrices --- Calculus.js | 9 ++++++++- all.js | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Calculus.js b/Calculus.js index 182bafca..af24dee2 100644 --- a/Calculus.js +++ b/Calculus.js @@ -368,10 +368,17 @@ if((typeof module) !== 'undefined' && typeof nerdamer === 'undefined') { if(core.Utils.isVector(symbol)) { var vector = new core.Vector([]); symbol.each(function(x) { - vector.elements.push(__.diff(x, wrt)); + vector.elements.push(__.diff(x, wrt, nth)); }); return vector; } + else if(core.Utils.isMatrix(symbol)) { + var matrix = new core.Matrix(); + symbol.each(function(x, j, i) { + matrix.set(i, j, __.diff(x, wrt, nth)); + }); + return matrix; + } var d = isSymbol(wrt) ? wrt.text() : wrt; //the nth derivative diff --git a/all.js b/all.js index a6f74196..5c996164 100644 --- a/all.js +++ b/all.js @@ -13,4 +13,4 @@ require('./Solve.js'); require('./Extra.js'); //export nerdamer -module.exports = nerdamer; +module.exports = nerdamer; \ No newline at end of file