#3658·mathjs

mapping a matrix with matrices

Author: dvd101xCreated Apr 26, 2026Updated Apr 26, 2026

Currently when mapping a function that returns a matrix. The result is a matrix of matrices.

javascript
math.matrix([1]).map( a => math.matrix([a]))
// DenseMatrix [DenseMatrix [1]]

Previously it returned a singe matrix. The change was introduced in v13.2.0 at in an attempt to increase performance #3256

This is the issue found at #3654.

The fix is simple, but probably will affect performance, and if the matrix function returns matrices of different sizes it will fail.

I can work in the fix, just please validate if this is an issue.