sparse_pwc_sum
- Graph.sparse_pwc_sum(terms)
Create the sum of multiple sparse-matrix-valued piecewise-constant functions.
- Parameters
terms (list[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
See also
constant_sparse_pwc_operator
Create constant SparsePwcs.
pwc_sum
Corresponding operation for Pwcs.
sparse_pwc_operator
Create SparsePwc operators.
Examples
Sum two sparse PWC operators.
>>> 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 user guide.