[SciPy-user] dense versus sparse

Nils Wagner nwagner at iam.uni-stuttgart.de
Thu Apr 26 07:58:38 EDT 2007


Hi,

How can I "translate" the last line of the dense version

#S=-diag(ones(n))
S=-identity(n)
S[:,-1] = S[:,-1] + ones(n)


into a sparse version

#S= -sparse.spdiags([ones(n)],[0],n,n)
S= -sparse.speye(n,n)

...

Nils
 



More information about the SciPy-User mailing list