Skip to content

Operations

This is a list of the operations that are built-in in Qmod. For more information regarding classical types see the Statements section in the language reference.

operations

Functions:

Name Description
assign

Initialize a scalar quantum variable using an arithmetic expression.

assign_amplitude

Perform an amplitude-encoding assignment operation on a quantum variable and a

bind
control
if_
inplace_add

Add an arithmetic expression to a quantum variable.

inplace_xor

Bitwise-XOR a quantum variable with an arithmetic expression.

invert
phase
power
repeat
within_apply

assign

assign(
    expression: SymbolicExpr, target_var: QScalar
) -> None

Initialize a scalar quantum variable using an arithmetic expression. If specified, the variable numeric properties (size, signedness, and fraction digits) must match the expression properties.

Equivalent to <target_var> |= <expression>.

Parameters:

Name Type Description Default
expression SymbolicExpr

A classical or quantum arithmetic expression

required
target_var QScalar

An uninitialized scalar quantum variable

required

assign_amplitude

assign_amplitude(
    expression: SymbolicExpr, target_var: QScalar
) -> None

Perform an amplitude-encoding assignment operation on a quantum variable and a quantum expression.

Equivalent to <target_var> *= <expression>.

Parameters:

Name Type Description Default
expression SymbolicExpr

A quantum arithmetic expression

required
target_var QScalar

A scalar quantum variable

required

bind

bind(
    source: Union[Input[QVar], list[Input[QVar]]],
    destination: Union[Output[QVar], list[Output[QVar]]],
) -> None

control

control(
    ctrl: Union[SymbolicExpr, QBit, QArray[QBit]],
    stmt_block: Union[QCallable, Callable[[], None]],
    else_block: Union[
        QCallable, Callable[[], None], None
    ] = None,
) -> None

if_

if_(
    condition: Union[SymbolicExpr, bool],
    then: Union[QCallable, Callable[[], None]],
    else_: Union[
        QCallable, Callable[[], None], int
    ] = _MISSING_VALUE,
) -> None

inplace_add

inplace_add(
    expression: SymbolicExpr, target_var: QScalar
) -> None

Add an arithmetic expression to a quantum variable.

Equivalent to <target_var> += <expression>.

Parameters:

Name Type Description Default
expression SymbolicExpr

A classical or quantum arithmetic expression

required
target_var QScalar

A scalar quantum variable

required

inplace_xor

inplace_xor(
    expression: SymbolicExpr, target_var: QScalar
) -> None

Bitwise-XOR a quantum variable with an arithmetic expression.

Equivalent to <target_var> ^= <expression>.

Parameters:

Name Type Description Default
expression SymbolicExpr

A classical or quantum arithmetic expression

required
target_var QScalar

A scalar quantum variable

required

invert

invert(
    stmt_block: Union[QCallable, Callable[[], None]]
) -> None

phase

phase(expr: SymbolicExpr, theta: float = 1.0) -> None

power

power(
    exponent: Union[SymbolicExpr, int],
    stmt_block: Union[QCallable, Callable[[], None]],
) -> None

repeat

repeat(
    count: Union[SymbolicExpr, int],
    iteration: Callable[[int], None],
) -> None

within_apply

within_apply(
    within: Callable[[], None], apply: Callable[[], None]
) -> None