Let A1 and A2 be numpy arrays of the same shape, say ((d1,d2)). I want to build ((d1,d1)) array from it such that its [i,j]th entry is defined by applying a function to the tuple A1[i],A2[j]. I use np.fromfunction in the form
f=lambda i,j: np.inner(A1[i],A2[j])
A=np.fromfunction(f, shape=(d1, d1))
(as suggested in Fastest way to initialize numpy array with values given by function) .
However I get the error ''IndexError: arrays used as indices must be of integer (or boolean) type''. This is strange because changing the lambda function to for example
f=lambda i,j: i*j
works fine! It seems calling another function in the lambda function leads to trouble with
np.fromfunction
(np.inner is just an example and I'd like to be able to replace it by other such functions).