Function for row reduction.