josdejong/mathjs

Matrix sum along a dimension is defined to return a `MathScalarType`, but might return higher dimension

Open

#3,202 建立於 2024年5月12日

在 GitHub 查看
 (5 留言) (0 反應) (1 負責人)JavaScript (1,298 fork)batch import
bughelp wantedtypescript

倉庫指標

Star
 (13,832 star)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

Describe the bug When summing over an axis of a matrix, we always lose just one dimension. If the matrix is 2D, we'll get a 1D array. If the matrix is 3D, we'll get a 2D matrix. What happens now, is that math.sum declares that it returns a MathScalarType, instead of optionally returning a matrix.

To Reproduce

const mat = math.matrix([[1,2,3],[4,5,6]])
console.log(math.sum(mat, 0))

> DenseMatrix { _data: [ 5, 7, 9 ], _size: [ 3 ], _datatype: undefined }

貢獻者指南