# sparse_pwc_sum

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

```python
Graph.sparse_pwc_sum(terms)
```

Create the sum of multiple sparse-matrix-valued piecewise-constant functions.

### Parameters
**terms** (*list* *[*[*SparsePwc*](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/SparsePwc.md#boulderopal.graph.SparsePwc) *]*) – The individual piecewise-constant terms $\{v_j(t)\}$ to sum.
All terms must be sparse, have values of the same shape,
and have the same total duration
but may have different numbers of segments of different durations.
### Returns
The piecewise-constant function of time $\sum_j v_j(t)$. It
has the same shape as each of the terms that you provided.
### 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.pwc_sum`](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Graph/pwc_sum.md#boulderopal.graph.Graph.pwc_sum)
: Corresponding operation for Pwcs.

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

## Examples

Sum two sparse PWC operators.

```pycon
>>> from scipy.sparse import coo_matrix
>>> sigma_x = np.array([[0, 1], [1, 0]])
>>> sigma_y = np.array([[0, -1j], [1j, 0]])
>>> sp_x = graph.constant_sparse_pwc_operator(duration=0.1, operator=coo_matrix(sigma_x))
>>> sp_y = graph.constant_sparse_pwc_operator(duration=0.1, operator=coo_matrix(sigma_y))
>>> graph.sparse_pwc_sum([sp_x, sp_y])
<SparsePwc: operation_name="sparse_pwc_sum", 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.
