Suppose I have the following numpy array.
A = [1,2,3,4,5,6]
Question Is there a quick way to multiply or add every nth element in A to yield the following arrays?
B = [3*1, 2*4, 3*5, 4*6]
C = [3+1, 2+4, 3+5, 4+6]
I can accomplish this by rolling A and then adding or multiplying it to the original A.
T = np.roll(A,-2)
B = (A*T)[0:4]
C = (A*T)[0:4]
Just wondering if there is a more pythonic/efficient way to accomplish this? I have also looked at np.add.reduceat and np.multiply.reduceat but they do not seem to allow for skipping values.