[IPython-User] idiom or elegant way to fill array with function values
Mon Feb 10 11:59:14 CST 2014
This question is probably more appropriately asked on the numpy mailing
list. You will get a swifter answer, and your question (and the answer)
will be more easily found by others with the same question in the future.
In general, you first construct an array of the values on which you'd
like the function to be evaluated.
input_values = linspace(-pi, pi, 100)
Then, you call your function on the array, if it is a ufunc.
output_values = sin(input_values)
You can turn a regular function into a ufunc using vectorize, which you
can use as a function decorator.
Again, please re-ask on the numpy list. My answer above is rather
simplistic and likely incomplete. The real numpy experts are there.
On 02/10/2014 03:06 AM, Krischu wrote:
> I'm seeking for away to fill an array more or less elegantly with values:
> lambda expression perhaps? I just found numpy.fromfunction
> View this message in context: http://python.6.x6.nabble.com/idiom-or-elegant-way-to-fill-array-with-function-values-tp5046877.html
> Sent from the IPython - User mailing list archive at Nabble.com.
> IPython-User mailing list
More information about the IPython-User