evaluate expressions at many points at once (vectorization)

Issue #1011 duplicate
Nico Schlömer created an issue

Elementary numpy functions can be evaluated at one or many points at once, e.g.,

def fun(x):
    return 3 * x[0] + numpy.sqrt(x[1])

X = numpy.random.rand(2)
fun(X)

X = numpy.random.rand(2, 77, 5)
fun(X)

Right now, FEniCS function can only be evaluated point-by-point, which is a bottleneck for some applications (see here or here). The documentation says:

A longer values array may be passed. In this way one can fast fill up an array with different evaluations.

values = numpy.zeros(9)
for i in xrange(0,10,3):
    fv(x[i:i+3], values = values[i:i+3])

Perhaps it'll be easier with pybind11 to support vectorized evaluation.

Comments (3)

  1. Log in to comment