qml.qinfo.transforms.reduced_dm¶
-
reduced_dm
(tape, wires, **kwargs)[source]¶ Compute the reduced density matrix from a
QNode
returningstate()
.- Parameters
tape (QuantumTape or QNode or Callable)) – A quantum circuit returning
state()
.wires (Sequence(int)) – List of wires in the considered subsystem.
- Returns
The transformed circuit as described in
qml.transform
. Executing this circuit will provide the reduced density matrix in the form of a tensor.- Return type
qnode (QNode) or quantum function (Callable) or tuple[List[QuantumTape], function]
Example
import numpy as np dev = qml.device("default.qubit", wires=2) @qml.qnode(dev) def circuit(x): qml.IsingXX(x, wires=[0,1]) return qml.state()
>>> transformed_circuit = reduced_dm(circuit, wires=[0]) >>> transformed_circuit(np.pi/2) tensor([[0.5+0.j, 0. +0.j], [0. +0.j, 0.5+0.j]], requires_grad=True)
See also
code/api/pennylane.qinfo.transforms.reduced_dm
Download Python script
Download Notebook
View on GitHub