mirror of
https://github.com/wassname/simpeg.git
synced 2026-09-11 12:44:29 +08:00
give Zero a transpose
This commit is contained in:
@@ -26,6 +26,9 @@ def mkvc(x, numDims=1):
|
||||
if hasattr(x, 'tovec'):
|
||||
x = x.tovec()
|
||||
|
||||
if isinstance(x, Zero):
|
||||
return x
|
||||
|
||||
assert isinstance(x, np.ndarray), "Vector must be a numpy array"
|
||||
|
||||
if numDims == 1:
|
||||
@@ -37,6 +40,9 @@ def mkvc(x, numDims=1):
|
||||
|
||||
def sdiag(h):
|
||||
"""Sparse diagonal matrix"""
|
||||
if isinstance(h, Zero):
|
||||
return h
|
||||
|
||||
return sp.spdiags(mkvc(h), 0, h.size, h.size, format="csr")
|
||||
|
||||
def sdInv(M):
|
||||
@@ -417,6 +423,12 @@ class Zero(object):
|
||||
def __ge__(self, v):return 0 >= v
|
||||
def __gt__(self, v):return 0 > v
|
||||
|
||||
@property
|
||||
def transpose(self): return Zero()
|
||||
|
||||
@property
|
||||
def T(self): return Zero()
|
||||
|
||||
class Identity(object):
|
||||
_positive = True
|
||||
def __init__(self, positive=True):
|
||||
|
||||
Reference in New Issue
Block a user