Asssume I have a function in python which returns the power of 2 of its input
def f(x):
return x**2
Assume also I have a vector of integers 1,2,3,4,5
I = asarray(list(range(1,6)))
Now I want to evaluate the function f with all inputs from I and the results should be in a vector of dimensions 5 (A 1x5 array in Python). My desired result is then: [1,4,9,16,25].
Can I get this result WITHOUT the use of a for or any other loop?
I have used array package