[SciPy-user] dense versus sparse

Nils Wagner nwagner@iam.uni-stuttgart...
Thu Apr 26 06:58:38 CDT 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