[SciPy-dev] sparse comments and questions

Nathan Bell wnbell at gmail.com
Fri Jul 13 05:37:17 EDT 2007


On 7/9/07, Peter Skomoroch <peter.skomoroch at gmail.com> wrote:
> In Matlab and some C++ libraries, I've used the following "sparse division"
> functionality :
>
> When you attempt to divide one sparse matrix by another of the same size,
> return the result of elementwise division of the entries in the matrices.
> This assumes that the two input matrices have the same sparsity structure.
>
> This is useful when implementing some algorithms like NMF using sparse
> matrices.  Right now in scipy, only division of a sparse matrix by a scalar
> is supported.

I've added support for elementwise division in the latest SVN.  I
designed it so you get the same result as a dense A/B on the union of
the sparsity structures.  For example, if A[i.j] is nonzero while
B[i.j] is zero, you get +/- inf.  If A[i,j] is zero while B[i,j] is
nonzero you'll get an implicit 0 in the result (i.e. it will not
appear in the output matrix).  This holds true for explicit zeros in
the matrices as well.  I think this is the most faithful analog of the
dense case.

Let me know if you discover any problems.

-- 
Nathan Bell wnbell at gmail.com



More information about the SciPy-Dev mailing list