public Matrix[] LUextended()
	{
		Double[][] L = new Double[row][row];
		Double[][] U = new Double[row][col];
		ArrayList<Integer[]> swaps = new ArrayList<Integer[]>();
		
		matrixCopy(matrix, U); //init U
		for (int i = 0; i < row; i++)
		{
			L[i][i] = 1.0;
			for (int j = i + 1; j < row; j++)
			{
				L[i][j] = 0.0;
			}
		}
		
		for (int i = 0, j = 0; i < row && j < col; i++, j++)
		{
			if (U[i][j] == 0) // pivot can't be 0
			{
				int swap = determineRowSwap(U, i, j);
				if (swap == -1) // no pivot in this column
				{
					i--;
					continue; // Essentially just go to next column in same row and try agian.
				}
				else
				{
					Integer[] temp = {i, swap};
					swaps.add(temp);
					rowInterchange(U, i, swap); // swap with row with pivot in this column
				}
			}
			for (int k = i + 1; k < row; k++) // eliminate all other values in this column below this row
			{
				L[k][j] = U[k][j] / U[i][j];
				rowAdd(U, k, i, -U[k][j] / U[i][j]);
				U[k][j] = 0.0; // Ensure it is 0, regardless of rounding error.
			}
		}
		
		for (int i = 0; i < swaps.size(); i++)
		{
			Integer[] temp = swaps.get(i);
			rowInterchange(L, temp[0], temp[1]);
		}
		
		Matrix[] LU = new Matrix[2];
		LU[0] = new Matrix(L);
		LU[1] = new Matrix(U);
		return LU;
	}