public Matrix backSubstitution(Matrix y) {
		if(rows != cols) {
			throw new IllegalArgumentException("Matrica nije kvadratna!");
		}
		
		if(y.rows != rows || y.cols != 1) {
			throw new IllegalArgumentException("Krivi format vektora!");
		}
		
		double[] x = new double[rows];
		
		for(int i = rows - 1; i >= 0; i--) {
			x[i] = y.get(i, 0);
			
			for(int j = i + 1; j < rows; j++) {
				x[i] -= x[j] * matrix[i][j];
			}
			
			x[i] /= matrix[i][i];
		}
		
		return new Matrix(x);
	}