Generalize scale to handle also shift (e.g., subtracting out the mean) and use bsxfun. See merge request !62