# sparse_pwc_operator

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

```python
Graph.sparse_pwc_operator(signal, operator)
```

Create a sparse piecewise-constant operator (sparse-matrix-valued function of time).

Each of the piecewise-constant segments (time periods) is a scalar multiple
of the operator.

### Parameters
* **signal** ([*Pwc*](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Pwc.md#boulderopal.graph.Pwc)) – The scalar-valued piecewise-constant function of time $a(t)$.
* **operator** (*numpy.ndarray* *or* *scipy.sparse.spmatrix* *or* [*Tensor*](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Tensor.md#boulderopal.graph.Tensor)) – The sparse operator $A$ to be scaled over time.
  If you pass a Tensor or NumPy array, it will be internally
  converted into a sparse representation.
### Returns
The piecewise-constant sparse operator $a(t)A$.
### Return type
[SparsePwc](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/SparsePwc.md#boulderopal.graph.SparsePwc)

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

[`Graph.density_matrix_evolution_pwc`](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Graph/density_matrix_evolution_pwc.md#boulderopal.graph.Graph.density_matrix_evolution_pwc)
: Evolve a quantum state in an open system.

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

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

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

[`Graph.state_evolution_pwc`](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Graph/state_evolution_pwc.md#boulderopal.graph.Graph.state_evolution_pwc)
: Evolve a quantum state.

## Examples

Create a sparse PWC operator.

```pycon
>>> from scipy.sparse import coo_matrix
>>> sigma_x = np.array([[0, 1], [1, 0]])
>>> signal = graph.pwc_signal(values=np.array([1, 2, 3]), duration=0.1)
>>> graph.sparse_pwc_operator(signal=signal, operator=coo_matrix(sigma_x))
<SparsePwc: operation_name="sparse_pwc_operator", value_shape=(2, 2)>
```

See more examples in the [How to simulate large open system dynamics](https://docs.q-ctrl.com/boulder-opal/user-guides/how-to-simulate-large-open-system-dynamics)
user guide.
