Is there a fast way in numpy to add array A to array B at a specified location?
For instance, if
B = [
[0, 1, 2],
[2, 3, 4],
[5, 6, 7]
]
and
A = [
[2, 2],
[2, 2]
]
and I want to add A to B starting from point (0, 0) to get
C = [
[2, 3, 2],
[4, 5, 4],
[5, 6, 7],
]
Of course I can do that via extending the array A to match the shape of B and then using numpy.roll, but it seems unnecessarily slow if the size of A is much much smaller then size of B.
EDIT:
potentially with wrapping around - ie such that bottom row of A is added to the top row of B and top row of A is added to the bottom row of B