public Matrix rref()
	{
		Double[][] mat = new Double[row][col];
		matrixCopy(matrix, mat);
		
		int j = 0;
		for (int i = 0; i < row && j < col; i++)
		{
			for (; j < col; j++)
			{
				if (mat[i][j] == 0) // pivot can't be 0
				{
					int swap = determineRowSwap(mat, i, j);
					if (swap == -1) // no pivot in this column
						continue;
					else
						rowInterchange(mat, i, swap); // swap with row with pivot in this column
				}
				rowScale(mat, i, 1 / mat[i][j]); // make pivot 1
				mat[i][j] = 1.0; // ensure it is one, regardless of rounding error
				for (int k = 0; k < row; k++) // eliminate all other values in this column
				{
					if (k == i)	// don't alter current row
						continue;
					rowAdd(mat, k, i, -mat[k][j]);
					mat[k][j] = 0.0; // Ensure it is 0, regardless of rounding error. 
				}
				break;
			}
			j++;
		}
		
		return new Matrix(mat);
	}