From what I know of numpy, it's a bad idea to apply an operation to each row of an array one at a time. Broadcasting is clearly the prefered method. Given that, how do I take data with a shape (N,3)
and translate it to the center of mass? Below is the 'bad method' I'm using. This works, but I suspect it will have a performance hit for large N
:
CM = R.sum(0)/R.shape[0]
for i in xrange(R.shape[0]): R[i,:] -= CM