linear_ramp_stf
signals.linear_ramp_stf(slope, shift=0.0)
Create an Stf representing a linear ramp.
Parameters
- slope (float or complex or Tensor) – The slope of the ramp, a. It must either be a scalar or contain a single element.
- shift (float or complex or Tensor , optional) – The value of the ramp at t=0, b. It must either be a scalar or contain a single element. Defaults to 0.
Returns
The sampleable linear ramp.
Return type
SEE ALSO
boulderopal.signals.linear_ramp
: Create a Signal object representing a linear ramp.
Graph.signals.linear_ramp_pwc
: Corresponding operation with Pwc output.
Graph.signals.tanh_ramp_stf
: Create an Stf representing a hyperbolic tangent ramp.
Notes
The linear ramp is defined as
Linear(t)=at+b.Examples
Define a linear STF ramp.
>>> linear = graph.signals.linear_ramp_stf(slope=4.0, shift=-2.0)
>>> graph.discretize_stf(linear, duration=1, segment_count=5, name="linear")
<Pwc: name="linear", operation_name="discretize_stf", value_shape=(), batch_shape=()>
>>> result = bo.execute_graph(graph=graph, output_node_names="linear")
>>> result["output"]["linear"]
{'durations': array([0.2, 0.2, 0.2, 0.2, 0.2]),
'values': array([-1.6, -0.8, 0. , 0.8, 1.6]),
'time_dimension': 0}
Define a linear STF ramp with an optimizable slope and root.
>>> slope = graph.optimizable_scalar(
... lower_bound=-4, upper_bound=4, name="slope"
... )
>>> root = graph.optimizable_scalar(
... lower_bound=-4, upper_bound=4, name="slope"
... )
>>> shift = - slope * root
>>> graph.signals.linear_ramp_stf(slope=slope, shift=shift)
<Stf: operation_name="add", value_shape=(), batch_shape=()>