What is an efficient numpy way of achieving an array of results based on a pair of index datasets?
So, lets say there are 2 arrays these are the row and column headers in the table underneath:
a = [1,3,4,6]
b = [2,7,8,10,15]
The resultant matrix I am looking for is a function based on a and b: f(a,b) So assuming the function is simply a+b thus:
a || 1 | 3 | 4 | 6
=========================
b 2 || 3 | 5 | 6 | 8 <-- ie 2+1=3, 2+3=5 etc
7 || 8 | 10 | 11 | 13
8 || 9 | 11 | 12 | 14
10 || 11 | 13 | 14 | 16
15 || 16 | 18 | 19 | 21
Obviously I could loop through each array and update the results of say a np.zeros() but I am assuming there should be a more efficient way of achieving this? TIA