Reputation: 445
If I have a multivariable function such as
F= lambda x,y: x**2+y**2
and if I need to use the input x0=np.array([1,1])
May I know how I should use x0
to get the value from F
?
I understand that I could use something like F(x0[0],x0[1])
But I would like to know whether there is a way that I can directly use x0
rather than calling each cordinate manually
Appreciate your help
Upvotes: 2
Views: 362
Reputation: 535
Python lets you do this by doing F(*x0)
, which expands the array into the parameters. In other languages this is sometimes called "splatting".
Upvotes: 4