qat.experimental.waveforms.shapes.rounded_square module

Implements the sampling definitions for a Rounded Square waveform shape.

The Rounded Square waveform shape is implemented by ERF functions that has the consequence of being roughly square in the center fractional_top_width region, which is the “top width”, with fractional_rise and fall edges at the tails that have a sharpness determined by the fractional_rise parameter. Note that the function isn’t actually square in the center, but has the appearance of being so. The function is actually continuously differentiable.

The Rounded Square waveform is defined by the function

\[f(x) = \frac{1}{N}\left[ \text{erf}\left(\frac{x + w_t}{r}\right) - \text{erf}\left(\frac{x - w_t}{r}\right) - C \right],\]

where \(w_t\) is fractional_top_width and \(r\) is fractional_rise. The shift \(C\) and regularize constant \(N\) are

\[C = \text{erf}\left(\frac{1 + w_t}{r}\right) - \text{erf}\left(\frac{1 - w_t}{r}\right),\]

and

\[N = \left[ \text{erf}\left(\frac{w_t}{r}\right) - \text{erf}\left(-\frac{w_t}{r}\right) \right] - C.\]

This implements the legacy RoundedSquareWaveform shape with the following parameterisations: fractional_rise = 2 * fractional_rise / width, fractional_top_width = std_dev / width.

class RoundedSquareWaveformShape(fractional_top_width=0.5, fractional_rise=0.1)

Bases: WaveformShape

Waveform-shape wrapper for rounded-square sampling functions.

derivative(x, order=1)

Evaluates the derivative of the rounded-square waveform shape.

Return type:

ndarray[tuple[int, ...], dtype[complexfloating]]

evaluate(x)

Evaluates the rounded-square waveform shape at the sample points.

Return type:

ndarray[tuple[int, ...], dtype[complexfloating]]

fractional_rise: float = 0.1
fractional_top_width: float = 0.5
classmethod from_absolute(width, absolute_top_width, absolute_rise)

Constructs from absolute parameters.

Parameters:
  • width (float) – The waveform width.

  • absolute_top_width (float) – The “top width” of the Rounded Square function.

  • absolute_rise (float) – The sharpness of the fractional_rise and fall edges of the Rounded Square function.

Return type:

RoundedSquareWaveformShape

classmethod from_legacy(rise, std_dev, width)

Constructs from legacy RoundedSquareWaveform parameters.

Parameters:
  • rise (float) – The rise parameter from the legacy implementation.

  • std_dev (float) – The std_dev parameter from the legacy implementation.

  • width (float) – The waveform width.

Return type:

RoundedSquareWaveformShape

sample_rounded_square_waveform(x, *, fractional_top_width=0.5, fractional_rise=0.1)

Samples a Rounded Square waveform shape.

Parameters:
  • x (ndarray[tuple[int, ...], dtype[floating]] | list[float]) – The list of values in the range [-1, 1] to sample the waveform for.

  • fractional_top_width (float) – The “top width” of the Rounded Square function, default is 0.5.

  • fractional_rise (float) – The sharpness of the fractional_rise and fall edges of the Rounded Square function, default is 0.1.

Return type:

ndarray[tuple[int, ...], dtype[complexfloating]]

Returns:

The sampled Rounded Square waveform as a complex-valued array.

sample_rounded_square_waveform_derivative(x, order=1, *, fractional_top_width=0.5, fractional_rise=0.1)

Samples the derivative of a Rounded Square waveform shape.

Parameters:
  • x (ndarray[tuple[int, ...], dtype[floating]] | list[float]) – The list of values in the range [-1, 1] to sample the waveform for.

  • fractional_top_width (float) – The “top width” of the Rounded Square function, default is 0.5.

  • fractional_rise (float) – The sharpness of the fractional_rise and fall edges of the Rounded Square function, default is 0.1.

  • order (int) – The order of the derivative to sample, default is 1.

Return type:

ndarray[tuple[int, ...], dtype[complexfloating]]

Returns:

The sampled derivative of the Rounded Square waveform as a complex-valued array.