This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Evaluating a function on multiple points

0 votes

Is it possible to evaluate a function on a numpy array of points, or do I just need to loop through and compute the value at each point?

asked May 17, 2015 by gideonsimpson FEniCS Novice (510 points)

1 Answer

0 votes

Maybe this helps you:
http://fenicsproject.org/qa/6374/what-is-the-best-way-to-evaluate-function-in-list-coordinates

It is basically the same question. But it seems that without extra tools a for-loop is necessary to evaluate a function.

answered May 18, 2015 by multigrid202 FEniCS User (3,780 points)

Not exactly. I was hoping for some kind of vectorized operation, without any explicit for looping. Right now I'm doing, in 1D:

xx = np.linspace(0, 1, num=100)
uu = np.zeros_like(xx)

for i in np.arange(0, xx.size):
    uu[i] = u(xx[i])
...