time_concatenate_pwc
- Graph.time_concatenate_pwc(pwc_list, *, name=None)
Concatenate multiple piecewise-constant functions in the time dimension.
- Parameters:
pwc_list (list[Pwc]) – The individual piecewise-constant functions \(\{A_i(t)\}\) to concatenate. All the functions must have the same value shape, and can have broadcastable batch shapes.
name (str or None, optional) – The name of the node.
- Returns:
The concatenated piecewise-constant function (or batch of functions).
- Return type:
See also
pwc
Create piecewise-constant functions.
pwc_sum
Sum multiple Pwcs.
symmetrize_pwc
Symmetrize Pwcs.
time_reverse_pwc
Reverse Pwcs in time.
Notes
The function resulting from the concatenation is
\[\begin{split}C(t) = \begin{cases} A_0(t) & \mathrm{for} & 0 < t < \tau_0 \\ A_1(t - \tau_0) & \mathrm{for} & \tau_0 < t < \tau_0 + \tau_1 \\ A_2(t - \tau_0 - \tau_1) & \mathrm{for} & \tau_0 + \tau_1 < t < \tau_0 + \tau_1 + \tau_2 \\ & \vdots & \end{cases}\end{split}\]where \(\tau_i\) is the duration of the i-th function.
For more information on Pwc nodes see the Working with time-dependent functions in Boulder Opal topic.
Examples
Concatenate two piecewise-constant functions.
>>> pwc1 = graph.pwc(durations=np.array([0.2, 0.5]), values=np.array([1, 2])) >>> pwc2 = graph.pwc(durations=np.array([0.7, 0.9]), values=np.array([3, 4])) >>> graph.time_concatenate_pwc([pwc1, pwc2], name="concat") <Pwc: name="concat", operation_name="time_concatenate_pwc", value_shape=(), batch_shape=()> >>> result = qctrl.functions.calculate_graph(graph=graph, output_node_names=["concat"]) >>> result.output["concat"] [ {'value': 1.0, 'duration': 0.2}, {'value': 2.0, 'duration': 0.5}, {'value': 3.0, 'duration': 0.7}, {'value': 4.0, 'duration': 0.9}, ]