qml.qinfo.transforms.reduced_dm

reduced_dm(qnode, wires)[source]

Compute the reduced density matrix from a QNode returning state().

Parameters
  • qnode (QNode) – A QNode returning state().

  • wires (Sequence(int)) – List of wires in the considered subsystem.

Returns

Function which wraps the QNode and accepts the same arguments. When called, this function will return the density matrix.

Return type

func

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()
>>> reduced_dm(circuit, wires=[0])(np.pi/2)
 [[0.5+0.j 0.+0.j]
  [0.+0.j 0.5+0.j]]