From 428fc7b354f329fb084003aa8169dd821209345e Mon Sep 17 00:00:00 2001 From: Robert K <robertk@posteo.org> Date: Sat, 20 Feb 2021 14:54:27 +0100 Subject: [PATCH] [cleanup][rk.py] Enable numexpr since we already have it. --- python/dune/femdg/rk.py | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/python/dune/femdg/rk.py b/python/dune/femdg/rk.py index 48f8f3db..41559fbc 100644 --- a/python/dune/femdg/rk.py +++ b/python/dune/femdg/rk.py @@ -111,22 +111,19 @@ class HelmholtzShuOsher: # x = self.op.space.function("tmp", dofVector=x_coeff) self.x.as_numpy[:] = x_coeff[:] self.op(self.x, self.res) - # compute alpha*res -x + rhs (by calling routines on discrete functions) - self.res *= self.alpha - self.res -= self.x - self.res += self.rhs # needs speedup, e.g. # - 2011: https://technicaldiscovery.blogspot.com/2011/06/speeding-up-python-numpy-cython-and.html - #try: - # import numpy, numexpr - # a = numpy.array([self.alpha]) - # res = self.res.as_numpy - # rhs = self.rhs.as_numpy - # self.res.as_numpy[:] = numexpr.evaluate('a*res-x_coeff+rhs') - #except ModuleNotFoundError: - # self.res.as_numpy[:] *= self.alpha - # self.res.as_numpy[:] -= x_coeff[:] - # self.res.as_numpy[:] += self.rhs.as_numpy[:] + try: + import numexpr, numpy + a = numpy.array([self.alpha]) + res = self.res.as_numpy + rhs = self.rhs.as_numpy + self.res.as_numpy[:] = numexpr.evaluate('a*res-x_coeff+rhs') + except ModuleNotFoundError: + # compute alpha*res -x + rhs (by calling routines on discrete functions) + self.res *= self.alpha + self.res -= self.x + self.res += self.rhs return self.res.as_numpy def solve(self,rhs,target): -- GitLab