# pwc_operator

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

```python
Graph.pwc_operator(signal, operator, *, name=None)
```

Create a constant operator multiplied by a piecewise-constant signal.

### Parameters
* **signal** ([*Pwc*](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Pwc.md#boulderopal.graph.Pwc)) – The piecewise-constant signal $a(t)$, or a batch of
  piecewise-constant signals.
* **operator** (*np.ndarray* *or* [*Tensor*](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Tensor.md#boulderopal.graph.Tensor)) – The operator $A$. It must have two equal dimensions.
* **name** (*str* *or* *None* *,* *optional*) – The name of the node.
### Returns
The piecewise-constant operator $a(t)A$ (or a batch of
piecewise-constant operators, if you provide a batch of
piecewise-constant signals).
### Return type
[Pwc](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Pwc.md#boulderopal.graph.Pwc)

### SEE ALSO
[`Graph.complex_pwc_signal`](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Graph/complex_pwc_signal.md#boulderopal.graph.Graph.complex_pwc_signal)
: Create complex Pwc signals from their moduli and phases.

[`Graph.constant_pwc_operator`](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Graph/constant_pwc_operator.md#boulderopal.graph.Graph.constant_pwc_operator)
: Create constant Pwcs.

[`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`](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Graph/pwc.md#boulderopal.graph.Graph.pwc)
: Create piecewise-constant functions.

[`Graph.pwc_signal`](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Graph/pwc_signal.md#boulderopal.graph.Graph.pwc_signal)
: Create Pwc signals from (possibly complex) values.

[`Graph.pwc_sum`](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Graph/pwc_sum.md#boulderopal.graph.Graph.pwc_sum)
: Sum multiple Pwcs.

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

## 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 piecewise-constant operator with non-uniform segment durations.

```pycon
>>> sigma_z = np.array([[1.0, 0.0],[0.0, -1.0]])
>>> graph.pwc_operator(
...     signal=graph.pwc(durations=np.array([0.1, 0.2]), values=np.array([1, 2])),
...     operator=sigma_z,
...     name="operator",
... )
<Pwc: name="operator", operation_name="pwc_operator", value_shape=(2, 2), batch_shape=()>
>>> result = bo.execute_graph(graph=graph, output_node_names="operator")
>>> result["output"]["operator"]
{
    'durations': array([0.1, 0.2]),
    'values': array([
        [[ 1.,  0.], [ 0., -1.]],
        [[ 2.,  0.], [ 0., -2.]]
    ]),
    'time_dimension': 0
}
```

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.
