remove classical results from HHL algorithm
@@ -300,16 +300,12 @@ class HHL(QuantumAlgorithm):
return ret
def _hhl_results(self, vec):
- self._ret["output_hhl"] = vec
- # Calculating the fidelity with the classical solution
- theo = np.linalg.solve(self._matrix, self._vector)
- theo = theo/np.linalg.norm(theo)
- self._ret["fidelity_hhl_to_classical"] = state_fidelity(theo, vec)
+ self._ret["output"] = vec
# Rescaling the output vector to the real solution vector
tmp_vec = self._matrix.dot(vec)
f1 = np.linalg.norm(self._vector)/np.linalg.norm(tmp_vec)
f2 = sum(np.angle(self._vector*tmp_vec.conj()-1+1))/self._num_q # "-1+1" to fix angle error for -0.-0.j
- self._ret["solution_hhl"] = f1*vec*np.exp(-1j*f2)
+ self._ret["solution"] = f1*vec*np.exp(-1j*f2)
def _run(self):
if self._quantum_instance.is_statevector:
@@ -319,10 +315,8 @@ class HHL(QuantumAlgorithm):
self.construct_circuit(measurement=True)
self._state_tomography()
# Adding a bit of general result information
- self._ret["input_matrix"] = self._matrix
- self._ret["input_vector"] = self._vector
- self._ret["eigenvalues_classical"] = np.linalg.eig(self._matrix)[0]
- self._ret["solution_classical"] = list(np.linalg.solve(self._matrix, self._vector))
+ self._ret["matrix"] = self._matrix
+ self._ret["vector"] = self._vector
dag = circuit_to_dag(self._circuit)
self._ret["circuit_width"] = dag.width()
self._ret["circuit_depth"] = dag.depth()
