Move method to matrixUtilities and fix it (bug for negative number).