I have a function that takes two arguments. I want to run the function for every possible combination of my inputs, and store each returned value. For example:
def foo(a, b):
return (a + b)
if __name__ == "__main__":
a = np.array([1., 2., 3.])
b = np.array([5., 6.])
f1 = foo(a[0], b[0]) #6
f2 = foo(a[0], b[1]) #7
f3 = foo(a[1], b[0]) #etc
f4 = foo(a[1], b[1])
f5 = foo(a[2], b[0])
f6 = foo(a[2], b[1])
How can I call f1 through f6 in a more elegant way, like a loop? It can't be a direct loop, because a and b have differing numbers of elements.