From 2f69b0624f29b95b488b347ea76f975bc10e3c31 Mon Sep 17 00:00:00 2001 From: astock Date: Fri, 7 May 2010 15:50:25 -0400 Subject: [PATCH] Differentiate numpy arrays properly. --- pymbolic/mapper/differentiator.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pymbolic/mapper/differentiator.py b/pymbolic/mapper/differentiator.py index 8f613f5..0d79b92 100644 --- a/pymbolic/mapper/differentiator.py +++ b/pymbolic/mapper/differentiator.py @@ -123,6 +123,14 @@ class DifferentiationMapper(pymbolic.mapper.RecursiveMapper): Polynomial(expr.base, tuple(deriv_coeff), expr.unit) + \ Polynomial(expr.base, tuple(deriv_base), expr.unit) + def map_numpy_array(self, expr): + import numpy + result = numpy.empty(expr.shape, dtype=object) + from pytools import indices_in_shape + for i in indices_in_shape(expr.shape): + result[i] = self.rec(expr[i]) + return result + -- GitLab