Isolate code from sklearn for normalization of a two-dimensional matrix as used here
I tried to copy the sklearn method here but did not have time to finish, because it has also some code for checking the validity of the matrix, which is not needed.
This normalization could be also rewritten in C++.