I have a 2D numpy array, A.
I want to subtract each rows, one by one, from A, and store the row-wise absolute sum in an array.
Is there a way to carry out the operation without using the for loop ? Below is the code with for loop.
import numpy as np
A = np.random.randint(5,size=(8,9))
b = np.zeros(A.shape[1]);
for i in xrange(A.shape[0]):
b = b + np.sum(np.absolute(A - A[i,:]), axis=0)