constant_pwc_operator
- Graph.constant_pwc_operator(duration, operator, *, name=None)
Create a constant piecewise-constant operator over a specified duration.
- Parameters:
duration (float) – The duration \(\tau\) for the resulting piecewise-constant operator.
operator (np.ndarray or Tensor) – The operator \(A\), or a batch of operators. It must have at least two dimensions, and its last two dimensions must be equal.
name (str or None, optional) – The name of the node.
- Returns:
The constant operator \(t\mapsto A\) (for \(0\leq t\leq\tau\)) (or a batch of constant operators, if you provide a batch of operators).
- Return type:
See also
Graph.constant_stf_operator
Corresponding operation for Stfs.
Graph.hermitian_part
Hermitian part of an operator.
Graph.pwc_operator
Create Pwc operators.
Notes
For more information on Pwc nodes see the Working with time-dependent functions in Boulder Opal topic.
Examples
Create a Hamiltonian from a batched constant operator.
>>> sigma_x = np.array([[0.0, 1.0], [1.0, 0.0]]) >>> sigma_z = np.array([[1.0, 0.0], [0.0, -1.0]]) >>> batched_operators = np.asarray([sigma_x, sigma_z]) >>> graph.constant_pwc_operator(duration=0.1, operator=batched_operators, name="op") <Pwc: name="op", operation_name="constant_pwc_operator", value_shape=(2, 2), batch_shape=(2,)> >>> result = bo.execute_graph(graph=graph, output_node_names="op") >>> result["output"]["op"] { 'durations': array([0.1]), 'values': array([ [[[ 0., 1.], [ 1., 0.]]], [[[ 1., 0.], [ 0., -1.]]] ]), 'time_dimension': 1 }
See more examples in the How to represent quantum systems using graphs user guide.