symmetrize_pwc
- Graph.symmetrize_pwc(pwc, *, name=None)
Create the symmetrization of a piecewise-constant function.
- Parameters:
pwc (Pwc) – The piecewise-constant function \(v(t)\) to symmetrize.
name (str or None, optional) – The name of the node.
- Returns:
The piecewise-constant function \(w(t)\) defined by \(w(t)=v(t)\) for \(0\leq t\leq \tau\) and \(w(t)=v(2\tau-t)\) for \(\tau\leq t\leq 2\tau\), where \(\tau\) is the duration of \(v(t)\).
- Return type:
See also
pwc_signal
Create Pwc signals from (possibly complex) values.
time_reverse_pwc
Reverse Pwcs in time.
Notes
For more information on Pwc nodes see the Working with time-dependent functions in Boulder Opal topic.
Examples
Create a symmetric piecewise-constant function.
>>> x = graph.pwc(durations=np.array([0.1, 0.3]), values=np.array([1, 2])) >>> graph.symmetrize_pwc(x, name="symmetrize") <Pwc: name="symmetrize", operation_name="symmetrize_pwc", value_shape=(), batch_shape=()> >>> result = qctrl.functions.calculate_graph(graph=graph, output_node_names=["symmetrize"]) >>> result.output["symmetrize"] [ {"value": 1.0, "duration": 0.1}, {"value": 2.0, "duration": 0.3}, {"value": 2.0, "duration": 0.3}, {"value": 1.0, "duration": 0.1}, ]
See more examples in the How to optimize controls with time symmetrization user guide.