# 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:

Pwc

constant_stf_operator

Corresponding operation for Stfs.

hermitian_part

Hermitian part of an operator.

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 = qctrl.functions.calculate_graph(graph=graph, output_node_names=["op"])
>>> result.output["op"]
[
[{"value": array([[0.0, 1.0], [1.0, 0.0]]), "duration": 0.1}],
[{"value": array([[1.0, 0.0], [0.0, -1.0]]), "duration": 0.1}],
]


See more examples in the How to represent quantum systems using graphs user guide.