[KeldyshGF-svncheckins] [svn commit /var/www/svn/KeldyshGF] r273 - trunk/kgf/exact_diagonalization

svn at fysik.dtu.dk svn at fysik.dtu.dk
Sun Nov 18 19:55:26 CET 2012


Author: strange
Date: 2012-11-18 19:55:26 +0100 (Sun, 18 Nov 2012)
New Revision: 273

Modified:
   trunk/kgf/exact_diagonalization/sparsetools.py
Log:
faster version, 12 sites now possible

Modified: trunk/kgf/exact_diagonalization/sparsetools.py
===================================================================
--- trunk/kgf/exact_diagonalization/sparsetools.py	2012-11-17 16:05:54 UTC (rev 272)
+++ trunk/kgf/exact_diagonalization/sparsetools.py	2012-11-18 18:55:26 UTC (rev 273)
@@ -1,7 +1,17 @@
 from scipy import sparse as sp
+from numpy import int8
 
 def get_subspace(A, indices, form='csr'):
     n = len(indices)
+    vec = sp.lil_matrix((A.shape[0], len(indices)), dtype=int8)
+    for j, i in enumerate(indices):
+        vec[i,j] = 1
+
+    vec = vec.tocsr()
+    return vec.T.dot(A).dot(vec)
+
+def get_subspace2(A, indices, form='csr'):
+    n = len(indices)
     At = A.tolil()
     B = sp.lil_matrix((n,n), dtype=A.dtype)
     for i in range(n):
@@ -13,7 +23,7 @@
     B.setdiag(diag)
     return B.asformat(form)
 
-def get_subspace2(A, indices, form='csr'):
+def get_subspace3(A, indices, form='csr'):
     n = len(indices)
     At = A.tolil()
     B = sp.lil_matrix((n,n), dtype=A.dtype)



More information about the KeldyshGF-svncheckins mailing list