Added sdInv to utils.

This commit is contained in:
Dave Marchant
2014-02-05 21:49:39 -08:00
parent c128be8af3
commit e56ca4fcbb
2 changed files with 4 additions and 1 deletions
+3
View File
@@ -7,6 +7,9 @@ def sdiag(h):
"""Sparse diagonal matrix"""
return sp.spdiags(mkvc(h), 0, h.size, h.size, format="csr")
def sdInv(M):
"Inverse of a sparse diagonal matrix"
return sdiag(1/M.diagonal())
def speye(n):
"""Sparse identity"""