wigner_transform
Graph.wigner_transform(density_matrix, position, momentum, offset=0, *, name=None)
Transform a density matrix into a Wigner function (or a batch of them).
Parameters
- density_matrix (Tensor or np.ndarray) – The density matrix ρ in the Fock basis.
Must be of shape
(..., D, D)
. - position (np.ndarray) – The dimensionless position vector q. Must be a 1D array of shape
(L,)
. - momentum (np.ndarray) – The dimensionless momentum vector p. Must be a 1D array of shape
(K,)
. - offset (int , optional) – The lowest Fock state. Defaults to 0.
- name (str or None , optional) – The name of the node.
Returns
The Wigner function with shape (..., L, K)
.
Return type
WARNING
This function currently does not support calculating a gradient with respect to its inputs. Therefore, it cannot be used in a graph for a run_optimization or run_stochastic_optimization call, which will raise a RuntimeError. Please use gradient-free optimization if you want to perform an optimization task with this function. You can learn more about it in the How to optimize controls using gradient-free optimization user guide.
SEE ALSO
Graph.coherent_state
: Create a coherent state (or a batch of them).
Graph.fock_state
: Create a Fock state (or a batch of them).
Notes
The Wigner transform is defined as:
W(q,p)=2π1∫−∞∞eisp⟨q−s/2∣ρ∣q+s/2⟩ds.For more information about the Wigner transform, see Wigner function on Wikipedia.
Examples
Create a Wigner function.
>>> graph.wigner_transform(np.array([[1]]), [-1, 0, 1], np.zeros(1), name="wigner")
<Tensor: name="wigner", operation_name="wigner_transform", shape=(3, 1)>
>>> result = bo.execute_graph(graph=graph, output_node_names="wigner")
>>> result["output"]["wigner"]["value"]
array([[ 0.11709966+0.j],
[ 0.31830989+0.j],
[ 0.11709966+0.j]])
Create a batch of Wigner function.
>>> graph.wigner_transform(
np.array([[[1, 0], [0, 0]], [[0, 0], [0, 1]]]),
np.array([-1, 0, 1]),
np.zeros(1),
name="wigner_batch",
)
<Tensor: name="wigner_batch", operation_name="wigner_transform", shape=(2, 3, 1)>
>>> result = bo.execute_graph(graph=graph, output_node_names="wigner_batch")
>>> result["output"]["wigner_batch"]["value"]
array([[[ 0.11709966+0.j],
[ 0.31830989+0.j],
[ 0.11709966+0.j]],
[[ 0.11709966+0.j],
[-0.31830989+0.j],
[ 0.11709966+0.j]]])