[SciPy-user] Sparse matrix: division by vector
Nathan Bell
wnbell@gmail....
Tue Apr 29 18:41:07 CDT 2008
On Tue, Apr 29, 2008 at 6:05 PM, Anne Archibald
<peridot.faceted@gmail.com> wrote:
> Is there any way to make the OP's approach work? Or even A /=
> colsum[newaxis,:]?
There is backend support for this operation in sparsetools for CSR,CSC
and BSR matrices. I occasionally use it directly, but I haven't
exposed it through SciPy yet.
Ideally sparse would expose this in a manner consistent with numpy matrices.
A safer approach is to use a diagonal matrix (e.g. D = spdiags(....))
to rescale rows or columns. With this approach, you don't need to
worry whether the matrix is dense or sparse (or in which format it is
stored).
> This seems like a basic expectation from sparse
> matrices... Is there a document describing which basic numpy
> operations work on sparse matrices and which don't?
Not currently.
--
Nathan Bell wnbell@gmail.com
http://graphics.cs.uiuc.edu/~wnbell/
More information about the SciPy-user
mailing list