Added sdInv to utils.

This commit is contained in:
Dave Marchant committed 2014-02-05 21:49:39 -08:00
1 parent c128be8af3
commit e56ca4fcbb
2 files changed
+4 -1

No files matched your search

+1 -1
View File
@@ -1,5 +1,5 @@
from matutils import getSubArray, mkvc, ndgrid, ind2sub, sub2ind
from sputils import spzeros, kron3, speye, sdiag, ddx, av, avExtrap
from sputils import spzeros, kron3, speye, sdiag, sdInv, ddx, av, avExtrap
from meshutils import exampleLomGird, meshTensors
from lomutils import volTetra, faceInfo, inv2X2BlockDiagonal, inv3X3BlockDiagonal, indexCube
from interputils import interpmat
+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"""