josdejong/mathjs

Simplify not working with matrix multiplication?

Open

#2.614 geöffnet am 1. Juli 2022

Auf GitHub ansehen
 (3 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)JavaScript (1.298 Forks)batch import
bughelp wanted

Repository-Metriken

Stars
 (13.832 Stars)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

Shouldn't the following produce the same result?

import * as math from 'mathjs'

let scope = {
  A: math.matrix([
    [1, 2],
    [3, 4],
  ]),
  v: math.matrix([5, 6]),
}

const r0 = math.evaluate('A * v', scope)
console.log('Evaluate:', r0) // Evaluate: DenseMatrix {_data: [17, 39]}

//const A = new math.SymbolNode('A')
//const v = new math.SymbolNode('v')
//const expr = new math.OperatorNode('*', 'multiply', [A, v])
const expr = math.parse('A * v')

const r1 = math.simplify(expr, scope)
console.log('Simplify:', r1) // Simplify: ConstantNode {value: 0}

When I run the code, evaluate produces the expected output ([17, 39]), but simplify does not (it instead produces 0 which doesn't seem right).

Contributor Guide