rAs algorithm for matrix balancing in R