Skip to content

dotDivide changes to denseMatrix when the inputs are sparseMatrix #3219

@dvd101x

Description

@dvd101x

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions