-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Describe the bug
At least as of version 15.1, mathjs refuses to add a BigNumber scalar to a matrix that has been typed as containing number entries.
To Reproduce
In the mathjs.org REPL:
> matrix([[1, 2]], 'dense', 'number') + bignumber(3)
Error: Cannot convert 3 to number
Expected behavior
I would expect the above operation to produce a 1×2 dense matrix with entries number(1) + bignumber(3) and number(2) + bignumber(3), respectively, which would be [[bigumber(4), bignumber(5)]] by current mathjs promotion rules. Ideally, the resulting matrix would be typed as containing bignumber entries, but that might have to wait for something like the nanomath engine that records return types (unless for now we just assume that since the input was homogeneous in type the output will be, too, and test just one entry. But that kind of assumption could break down for bigint divided by bigint, say -- the result might be a mix of bigints and fractions...