[Scipy-svn] r2898 - trunk/Lib/sparse

scipy-svn at scipy.org scipy-svn at scipy.org
Thu Apr 5 14:41:58 EDT 2007


Author: wnbell
Date: 2007-04-05 13:41:56 -0500 (Thu, 05 Apr 2007)
New Revision: 2898

Modified:
   trunk/Lib/sparse/sparse.py
Log:
faster implementation of spidentity()



Modified: trunk/Lib/sparse/sparse.py
===================================================================
--- trunk/Lib/sparse/sparse.py	2007-04-04 17:27:42 UTC (rev 2897)
+++ trunk/Lib/sparse/sparse.py	2007-04-05 18:41:56 UTC (rev 2898)
@@ -2620,8 +2620,7 @@
     spidentity( n ) returns the identity matrix of shape (n, n) stored
     in CSC sparse matrix format.
     """
-    diags = ones( (1, n), dtype = dtype )
-    return spdiags( diags, 0, n, n )
+    return csc_matrix((ones(n,dtype=dtype),arange(n),arange(n+1)),(n,n))
 
 
 def speye(n, m, k = 0, dtype = 'd'):




More information about the Scipy-svn mailing list