Skip to content
Snippets Groups Projects
Commit 40cceccc authored by Jean-Baptiste Keck's avatar Jean-Baptiste Keck
Browse files

Merge branch 'mpi-operators' of gricad-gitlab.univ-grenoble-alpes.fr:keckj/hysop into mpi-operators

parents d6acd372 51b17389
No related branches found
No related tags found
1 merge request!16MPI operators
......@@ -142,16 +142,19 @@ class Assignment(BinaryRelation):
return '='
@classmethod
def assign(cls, lhs, rhs):
def assign(cls, lhs, rhs, skip_zero_rhs=False):
exprs = ()
def create_expr(rhs):
return (not skip_zero_rhs) or (rhs!=0)
if isinstance(lhs, npw.ndarray) and isinstance(rhs, npw.ndarray):
assert isinstance(lhs, npw.ndarray), type(lhs)
assert isinstance(rhs, npw.ndarray), type(rhs)
assert (rhs.size == lhs.size)
assert (rhs.shape == lhs.shape)
for (l,r) in zip(lhs.ravel().tolist(), rhs.ravel().tolist()):
e = cls(l, r)
exprs += (e,)
if create_expr(r):
e = cls(l, r)
exprs += (e,)
elif isinstance(lhs, npw.ndarray) or isinstance(rhs, npw.ndarray):
if isinstance(lhs, npw.ndarray):
lhss = lhs.ravel().tolist()
......@@ -160,13 +163,15 @@ class Assignment(BinaryRelation):
rhss = rhs.ravel().tolist()
lhss = (lhs,)*len(rhss)
for (l,r) in zip(lhss, rhss):
e = cls(l, r)
exprs += (e,)
if create_expr(r):
e = cls(l, r)
exprs += (e,)
elif isinstance(lhs, sm.Basic) and isinstance(rhs, sm.Basic):
assert isinstance(lhs, sm.Basic), type(lhs)
assert isinstance(rhs, sm.Basic), type(rhs)
e = cls(lhs, rhs)
exprs += (e,)
if create_expr(rhs):
exprs += (e,)
else:
msg='Cannot handle operand types:\n *lhs: {}\n *rhs: {}\n'
msg=msg.format(type(lhs), type(rhs))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment