[SciPy-user] Sparse indexing workarounds

Bill Baxter wbaxter at gmail.com
Sat Apr 14 00:21:52 EDT 2007


Thanks for the suggestion.
Is there any easy way to print out a pysparse spmatrix or convert it
to a numpy dense matrix?

It seems like the functionality is there in pysparse, but the
interface is a bit maddening.  A little more flexibility would be
nice.   I guess the interface is unforgiving because it's implemented
in C/C++?  But there are lots of little issues like matvec insisting
on having a return parameter, and refusing to work with anything
besides 1D arrays (no automatic conversion of python lists to arrays,
or forgiving treatment of (N,1) or (1,N) arrays as "close enough".

Documentation is quite minimal too... but anyway, if I can get it to
solve my system, and if it's fast, I'll be a happy camper.   :-)

--bb

On 4/10/07, Håkan Jakobsson <hakan.jakobsson at gmail.com> wrote:
> You can use pysparse instead of sparse. The update_add_mask function will do
> the trick.
> /Håkan J
>
>
> On 4/10/07, Robert Cimrman < cimrman3 at ntc.zcu.cz> wrote:
> > Bill Baxter wrote:
> > > Does anyone have an easy (and efficient way) to update a submatrix of
> > > a big sparse matrix?
> > >
> > >   K = scipy.sparse.lil_matrix(bigN,bigN)
> > >   ...
> > >   conn = [1,4,11,12]
> > >   K[ix_(conn,conn)] += elemK
> > >
> > > where elemK is a 4x4 dense matrix.
> > >
> > > This kind of thing is very commonly needed in FEM codes for assembling
> > > the global stiffness matrix.  But sparse doesn't seem to support
> > > either += or indexing with the open grid of indices returned by ix_.
> >
> > You may have a look at
> > http://ui505p06-mbs.ntc.zcu.cz/sfe/FEUtilsExample
> > it uses CSR matrix though...
> >
> > r.
> > _______________________________________________
> > SciPy-user mailing list
> > SciPy-user at scipy.org
> > http://projects.scipy.org/mailman/listinfo/scipy-user
> >
>
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
>
>



More information about the SciPy-User mailing list