Skip to content
Snippets Groups Projects
Unverified Commit 5b54cc25 authored by Andreas Klöckner's avatar Andreas Klöckner Committed by GitHub
Browse files

Merge pull request #9 from inducer/eager-norm-support-obj-array

Eager norm support obj array
parents 4349e299 af898f13
No related branches found
No related tags found
No related merge requests found
Pipeline #52305 passed
...@@ -166,6 +166,18 @@ class EagerDGDiscretization(DGDiscretizationWithBoundaries): ...@@ -166,6 +166,18 @@ class EagerDGDiscretization(DGDiscretizationWithBoundaries):
return bind(self, sym.norm(p, sym.var("arg")), local_only=True) return bind(self, sym.norm(p, sym.var("arg")), local_only=True)
def norm(self, vec, p=2): def norm(self, vec, p=2):
if (isinstance(vec, np.ndarray)
and vec.dtype.char == "O"
and not isinstance(vec, DOFArray)):
if p == 2:
return sum(
self.norm(vec[idx])**2
for idx in np.ndindex(vec.shape))**0.5
elif p == np.inf:
return max(self.norm(vec[idx]) for idx in np.ndindex(vec.shape))
else:
raise ValueError("unsupported norm order")
return self._norm(p)(arg=vec) return self._norm(p)(arg=vec)
@memoize_method @memoize_method
......
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