`dotDivide` changes to denseMatrix when the inputs are sparseMatrix
dvd101x opened this issue · comments
Hi,
I found an odd behavior of sparse matrices in dotDivide
on 13.0.0
math.dotDivide([1, 2], [1, 1])
// [1, 2]
// OK
math.dotDivide(math.sparse([1,2]), 1)
// SparseMatrix [1, 2]
// OK
math.dotDivide(math.sparse([1, 2]), math.sparse([1, 1]))
// DenseMatrix [[1], [2]]
// it's odd that the shape changes and it returns a DenseMatrix
math.dotDivide(math.sparse([1, 2]), math.sparse([1]))
// TypeError: undefined is not an object (evaluating 's[t]')
The implementation of matrixAlgorithmSuite
in dotDivide
seems different than the one in dotMultiply
maybe it has something to do with the issue.
I found this while working on #3196, found that for sparse matrices broadcasting isn't working very well and went into a rabbit hole to find this separate issue.
Thanks for reporting! We should indeed align this and make sure the output is a SparseMatrix for sparse inputs. I think we should mark it as a breaking change, since the current behavior may be depended upon.