How can I calculate an outer function in python?

后端 未结 3 2137
醉酒成梦
醉酒成梦 2021-01-07 06:18

If I have a random function like func(x,y) = cos(x) + sen(y) + x*y how can I apply it to all the pairs of elements in 2 arrays?

I found https://docs.scipy.org/doc/nu

3条回答
  •  旧巷少年郎
    2021-01-07 06:53

    You could do this using a nested loop. Using a single element in one array, iterate through all the elements in the other array, then proceed to the next element in the first array and repeat.

    This would be simple if you just want to print the result, if you want to store the results into another array, this would still work, it just uses a lot of resources.

提交回复
热议问题