
![]() | Python class:
class Grid2D:
def __init__(self,
xmin=0, xmax=1, dx=0.5,
ymin=0, ymax=1, dy=0.5):
self.xcoor = sequence(xmin, xmax, dx)
self.ycoor = sequence(ymin, ymax, dy)
# make two-dim. versions of these arrays:
# (needed for vectorization in __call__)
self.xcoorv = self.xcoor[:,newaxis]
self.ycoorv = self.ycoor[newaxis,:]
def __call__(self, f):
# vectorized code:
return f(self.xcoorv, self.ycoorv)
|