# constant_pwc_operator

Source: https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Graph/constant_pwc_operator

```python
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*](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Tensor.md#boulderopal.graph.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](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Pwc.md#boulderopal.graph.Pwc)

### SEE ALSO
[`Graph.constant_stf_operator`](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Graph/constant_stf_operator.md#boulderopal.graph.Graph.constant_stf_operator)
: Corresponding operation for Stfs.

[`Graph.hermitian_part`](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Graph/hermitian_part.md#boulderopal.graph.Graph.hermitian_part)
: Hermitian part of an operator.

[`Graph.pwc_operator`](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Graph/pwc_operator.md#boulderopal.graph.Graph.pwc_operator)
: Create Pwc operators.

## Notes

For more information on Pwc nodes see the [Working with time-dependent functions in
Boulder Opal](https://docs.q-ctrl.com/boulder-opal/topics/working-with-time-dependent-functions-in-boulder-opal) topic.

## Examples

Create a Hamiltonian from a batched constant operator.

```pycon
>>> 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](https://docs.q-ctrl.com/boulder-opal/user-guides/how-to-represent-quantum-systems-using-graphs) user guide.
