[SciPy-user] broadcasting elementwise on sparse matrix

Robin robince at gmail.com
Wed Oct 1 12:11:12 EDT 2008


On Wed, Oct 1, 2008 at 4:52 PM, Nathan Bell <wnbell at gmail.com> wrote:
> On Wed, Oct 1, 2008 at 9:50 AM, Robin <robince at gmail.com> wrote:
> That particular operation is just scaling of the columns, right?  If
> so, you can use:
>>>> As * spdiags([x],[0], n,n,)

Yes - I realised that and was using spdiags, which is a lot quicker.

> If As is already a CSR matrix, then you can cheat a little and do the
> operation in place:
>>>> As.data *= x[As.indices]

That's quite tricky... :)
It is a CSC matrix - not sure why, but I am saving and loading it from
Matlab files, and when I first started (a year or so again) it seemed
CSC was the most reliable (or at least I always got a CSC from .mat
files).
Presumably the same thing the same thing will work though.

Thanks very much,

Robin



More information about the SciPy-User mailing list