-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Labels
bugSomething isn't workingSomething isn't workingmod: algorithmsRelated to the Algorithms moduleRelated to the Algorithms module
Description
Environment
- Qiskit Terra version: latest
- Python version:
- Operating system:
What is happening?
The example code for HHL from the docs
import numpy as np
from qiskit import QuantumCircuit
from qiskit.algorithms.linear_solvers.hhl import HHL
from qiskit.algorithms.linear_solvers.matrices import TridiagonalToeplitz
from qiskit.algorithms.linear_solvers.observables import MatrixFunctional
matrix = TridiagonalToeplitz(2, 1, 1 / 3, trotter_steps=2)
right_hand_side = [1.0, -2.1, 3.2, -4.3]
observable = MatrixFunctional(1, 1 / 2)
rhs = right_hand_side / np.linalg.norm(right_hand_side)
# Initial state circuit
num_qubits = matrix.num_state_qubits
qc = QuantumCircuit(num_qubits)
qc.isometry(rhs, list(range(num_qubits)), None)
hhl = HHL()
solution = hhl.solve(matrix, qc, observable)
approx_result = solution.observable
approx_result = solution.observable
works if a backend (quantum_instance
) is not passed toHHL()
. It says explicitly that a statevector simulation is done in this case:
quantum_instance: Quantum Instance or Backend. If None, a Statevector calculation is
done.
However if one passes a statevector simulator sim = Aer.get_backend('statevector_simulator')
then the example above fails with: ValueError: Expectations of Mixed Operators not yet supported.
.
How can we reproduce the issue?
do the above
What should happen?
it should work
Any suggestions?
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingmod: algorithmsRelated to the Algorithms moduleRelated to the Algorithms module