Skip to content

Waveform

Add

Bases: Waveform

<add> ::= <waveform> '+' <waveform>

AlignedWaveform

Bases: Waveform

<padded waveform> ::= <waveform> | <waveform> <alignment> <value>

<alignment> ::= 'left aligned' | 'right aligned'
<value> ::= 'left value' | 'right value' | <scalar expr>

Append

Bases: AppendTrait, Waveform

<append> ::= <waveform>+

Constant

Constant(value, duration)

Bases: Instruction

<constant> ::= 'constant' <scalar expr>

f(t=0:duration) = value

Parameters:

Name Type Description Default
value Scalar

the constant value

required
duration Scalar

the time span of the constant waveform.

required
Source code in src/bloqade/ir/control/waveform.py
@beartype
def __init__(self, value: ScalarType, duration: ScalarType):
    object.__setattr__(self, "value", cast(value))
    object.__setattr__(self, "duration", cast(duration))

Instruction

Bases: Waveform

Instruction node in the IR.

<instruction> ::= <linear>
    | <constant>
    | <poly>
    | <python-fn>

Linear

Linear(start, stop, duration)

Bases: Instruction

<linear> ::= 'linear' <scalar expr> <scalar expr>

f(t=0:duration) = start + (stop-start)/duration * t

Parameters:

Name Type Description Default
start Scalar

start value

required
stop Scalar

stop value

required
duration Scalar

the time span of the linear waveform.

required
Source code in src/bloqade/ir/control/waveform.py
@beartype
def __init__(self, start: ScalarType, stop: ScalarType, duration: ScalarType):
    object.__setattr__(self, "start", cast(start))
    object.__setattr__(self, "stop", cast(stop))
    object.__setattr__(self, "duration", cast(duration))

Negative

Bases: Waveform

<negative> ::= '-' <waveform>

Poly

Poly(coeffs, duration)

Bases: Instruction

<poly> ::= <scalar>+

f(t=0:duration) = c[0] + c[1]t + c[2]t^2 + ... + c[n-1]t^n-1 + c[n]t^n

Parameters:

Name Type Description Default
coeffs Tuple[Scalar]

the coefficients c[] of the polynomial.

required
duration Scalar

the time span of the waveform.

required
Source code in src/bloqade/ir/control/waveform.py
@beartype
def __init__(self, coeffs: Container[ScalarType], duration: ScalarType):
    object.__setattr__(self, "coeffs", tuple(map(cast, coeffs)))
    object.__setattr__(self, "duration", cast(duration))

PythonFn

Bases: Instruction

<python-fn> ::= 'python-fn' <python function def> <scalar expr>

Record

Bases: Waveform

<record> ::= 'record' <waveform> <var> <side>

Sample

Bases: Waveform

<sample> ::= 'sample' <waveform> <interpolation> <scalar>

Scale

Scale(scalar, waveform)

Bases: Waveform

<scale> ::= <scalar expr> '*' <waveform>
Source code in src/bloqade/ir/control/waveform.py
def __init__(self, scalar, waveform: Waveform):
    object.__setattr__(self, "scalar", cast(scalar))
    object.__setattr__(self, "waveform", waveform)

Slice

Bases: SliceTrait, Waveform

<slice> ::= <waveform> <scalar.interval>

Smooth

Smooth(radius, kernel, waveform)

Bases: Waveform

<smooth> ::= 'smooth' <kernel> <waveform>
Source code in src/bloqade/ir/control/waveform.py
def __init__(self, radius, kernel, waveform):
    if isinstance(kernel, str):
        if kernel == "Gaussian":
            kernel = GaussianKernel
        elif kernel == "Logistic":
            kernel = LogisticKernel
        elif kernel == "Sigmoid":
            kernel = SigmoidKernel
        elif kernel == "Triangle":
            kernel = TriangleKernel
        elif kernel == "Uniform":
            kernel = UniformKernel
        elif kernel == "Parabolic":
            kernel = ParabolicKernel
        elif kernel == "Biweight":
            kernel = BiweightKernel
        elif kernel == "Triweight":
            kernel = TriweightKernel
        elif kernel == "Tricube":
            kernel = TricubeKernel
        elif kernel == "Cosine":
            kernel = CosineKernel
        else:
            raise ValueError(f"Invalid kernel: {kernel}")

    object.__setattr__(self, "radius", cast(radius))
    object.__setattr__(self, "kernel", kernel)
    object.__setattr__(self, "waveform", waveform)

Waveform

Bases: HashTrait, CanonicalizeTrait

Waveform node in the IR.

<waveform> ::= <instruction>
    | <smooth>
    | <slice>
    | <append>
    | <negative>
    | <scale>
    | <add>
    | <record>
    | <sample>

figure

figure(**assignments)

get figure of the plotting the waveform.

Returns:

Name Type Description
figure

a bokeh figure

Source code in src/bloqade/ir/control/waveform.py
def figure(self, **assignments):
    """get figure of the plotting the waveform.

    Returns:
        figure: a bokeh figure
    """
    return get_ir_figure(self, **assignments)