public static float[] rref2(float[] matrix, int matrixSize){
			int i = 0;
			int j = 0;

			for(;j < matrixSize; j++){
				float lastValue = 0;
				int largestRow = i;
				for(int k = i; k < matrixSize; k++){
					final int pos = getPosistion(k, j, matrixSize+1);
					if(Math.abs(matrix[pos]) > lastValue){
						lastValue = matrix[pos];
						largestRow = k;
					}
				}
				/**
				 * If found largest value in a row, swamp the row
				 */
				if(largestRow != i){
					matrix = swapRows(matrix, matrixSize +1, i, largestRow);
				}

				/**
				 * Multiple row i by 1/mij
				 */
				matrix = multipleRow(matrix, matrixSize+1, i, 1 / matrix[getPosistion(i, j, matrixSize+1)]);

				/**
				 * For each row r, where 1≤r≤n and r≠i, add -Mrj times row i it row r
				 */
				for(int r = 0; r < matrixSize; r++){
					if(r != i){
						final float mrj = -matrix[getPosistion(r, j, matrixSize+1)];
						for(int l = 0; l < matrixSize+1; l++){
							matrix[getPosistion(r, l, matrixSize+1)] += mrj * matrix[getPosistion(i, l, matrixSize+1)];
						}
					}
				}
				i++;
			}

			return matrix;
		}