Suppose the matrix is M=
[[.10, .32, .20, .40, .80],
[.23, .18, .56, .61, .12],
[.90, .30, .60, .50, .30],
[.34, .75, .91, .19, .21]]
The average row vector is rav=
[ 0.3925 0.3875 0.5675 0.425 0.3575]
I want to subtract average row vector (rav) from each row vector in the above matrix (M)
i.e M(i)-rav.
How can I do that in an efficient way?
In pure Python
It will be faster to use numpy if you are doing a bunch of matrix operations. Converting to and from numpy matrices is fairly expensive.