Skip to content

Index

operations

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]],
) -> 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(value: QNum, target: QNum) -> None

inplace_xor

inplace_xor(value: QNum, target: QNum) -> None

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

functions

BUILTIN_FUNCTION_DECLARATIONS

BUILTIN_FUNCTION_DECLARATIONS = {name: _62IYyhSafor func_decl in STD_QMOD_OPERATORS + OPEN_LIB_DECLS + CORE_LIB_DECLS}

Input

Input = _Q

OPEN_LIB_DECLS

OPEN_LIB_DECLS = [
    func_decl
    for func in (
        qpe_flexible,
        qpe,
        _single_pauli,
        linear_pauli_rotations,
        amplitude_estimation,
        phase_oracle,
        reflect_about_zero,
        grover_diffuser,
        grover_operator,
        grover_search,
        hadamard_transform,
        apply_to_all,
        qft_no_swap,
        qft_space_add_const,
        cc_modular_add,
        c_modular_multiply,
        multiswap,
        inplace_c_modular_multiply,
        modular_exp,
        qsvt_step,
        qsvt,
        projector_controlled_phase,
        qsvt_inversion,
        allocate_num,
        qaoa_mixer_layer,
        qaoa_cost_layer,
        qaoa_layer,
        qaoa_init,
        qaoa_penalty,
        full_hea,
        swap_test,
        prepare_uniform_trimmed_state,
        prepare_uniform_interval_state,
        prepare_ghz_state,
        prepare_exponential_state,
        prepare_bell_state,
        inplace_prepare_int,
        prepare_int,
        switch,
        qct_qst_type1,
        qct_qst_type2,
        qct_type2,
        qst_type2,
        modular_increment,
        qft,
        _ctrl_x,
        _prepare_uniform_trimmed_state_step,
        _qct_d_operator,
        _qct_pi_operator,
        _check_msb,
    )
]

Output

Output = _Q

STD_QMOD_OPERATORS

STD_QMOD_OPERATORS = [
    func_decl for func in (apply, permute)
]

CArray

CArray(expr: str)

Bases: CParam, ArrayBase[_P]

len

len: int

CBool

CBool(expr: str)

Bases: CParam

CInt

CInt(expr: str)

Bases: CParam

CReal

CReal(expr: str)

Bases: CParam

FinanceFunction

FinanceFunction(
    f: CInt,
    threshold: CReal,
    larger: CBool,
    polynomial_degree: CInt,
    use_chebyshev_polynomial_approximation: CBool,
    tail_probability: CReal,
)

f

f: CInt

larger

larger: CBool

polynomial_degree

polynomial_degree: CInt

tail_probability

tail_probability: CReal

threshold

threshold: CReal

use_chebyshev_polynomial_approximation

use_chebyshev_polynomial_approximation: CBool

FockHamiltonianProblem

FockHamiltonianProblem(
    mapping: CInt,
    z2_symmetries: CBool,
    terms: CArray[LadderTerm],
    num_particles: CArray[CInt],
)

mapping

mapping: CInt

num_particles

num_particles: CArray[CInt]

terms

z2_symmetries

z2_symmetries: CBool

GaussianModel

GaussianModel(
    num_qubits: CInt,
    normal_max_value: CReal,
    default_probabilities: CArray[CReal],
    rhos: CArray[CReal],
    loss: CArray[CInt],
    min_loss: CInt,
)

default_probabilities

default_probabilities: CArray[CReal]

loss

loss: CArray[CInt]

min_loss

min_loss: CInt

normal_max_value

normal_max_value: CReal

num_qubits

num_qubits: CInt

rhos

rhos: CArray[CReal]

LogNormalModel

LogNormalModel(num_qubits: CInt, mu: CReal, sigma: CReal)

mu

mu: CReal

num_qubits

num_qubits: CInt

sigma

sigma: CReal

MoleculeProblem

MoleculeProblem(
    mapping: CInt,
    z2_symmetries: CBool,
    molecule: Molecule,
    freeze_core: CBool,
    remove_orbitals: CArray[CInt],
)

freeze_core

freeze_core: CBool

mapping

mapping: CInt

molecule

molecule: Molecule

remove_orbitals

remove_orbitals: CArray[CInt]

z2_symmetries

z2_symmetries: CBool

Pauli

Bases: IntEnum

Enumeration for the Pauli matrices used in quantum computing.

The Pauli matrices are fundamental operations in quantum computing, and this enum assigns integer values to represent each matrix.

I

I = 0

I (int): Identity matrix, represented by the integer 0.

\(I = \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix}\)

X

X = 1

X (int): Pauli-X matrix, represented by the integer 1.

\(X = \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}\)

Y

Y = 2

Y (int): Pauli-Y matrix, represented by the integer 2.

\(Y = \begin{bmatrix} 0 & -i \\ i & 0 \end{bmatrix}\)

Z

Z = 3

Z (int): Pauli-Z matrix, represented by the integer 3.

\(Z = \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix}\)

PauliTerm

PauliTerm(pauli: CArray[Pauli], coefficient: CReal)

A term in a Hamiltonian, represented as a product of Pauli operators.

Attributes:

Name Type Description
pauli CArray[Pauli]

The list of the chosen Pauli operators in the term, corresponds to a product of them.

coefficient CReal

The coefficient of the term (floating number).

coefficient

coefficient: CReal

pauli

pauli: CArray[Pauli]

QArray

QArray(
    name: Union[str, HandleBinding],
    element_type: Union[_GenericAlias, QuantumType] = QBit,
    length: Optional[
        Union[int, SymbolicExpr, Expression]
    ] = None,
    _expr_str: Optional[str] = None,
)

Bases: ArrayBase[_P], QVar

len

len: Union[CParamScalar, int]

get_qmod_type

get_qmod_type() -> QuantumBitvector

to_qmod_quantum_type

to_qmod_quantum_type(type_hint: Any) -> QuantumType

to_qvar

to_qvar(
    origin: Union[str, HandleBinding],
    type_hint: Any,
    expr_str: Optional[str],
) -> QArray

QBit

QBit(
    origin: Union[str, HandleBinding],
    *,
    _expr_str: Optional[str] = None,
    depth: int = 2
)

Bases: QScalar

get_qmod_type

get_qmod_type() -> QuantumType

to_qmod_quantum_type

to_qmod_quantum_type(type_hint: Any) -> QuantumType

to_qvar

to_qvar(
    origin: Union[str, HandleBinding],
    type_hint: Any,
    expr_str: Optional[str],
) -> QBit

QCallable

Bases: Generic[P], ABC

CURRENT_EXPANDABLE

CURRENT_EXPANDABLE: Optional[QExpandableInterface] = None

FRAME_DEPTH

FRAME_DEPTH = 1

func_decl

func_decl: AnonQuantumFunctionDeclaration

create_quantum_function_call

create_quantum_function_call(
    source_ref_: SourceReference, *args: Any, **kwargs: Any
) -> QuantumFunctionCall

QCallableList

Bases: QCallable, Generic[P], ABC

len

len: int

QNum

QNum(
    name: Union[str, HandleBinding],
    size: Union[int, CInt, Expression, None] = None,
    is_signed: Union[
        bool, Expression, SymbolicExpr, None
    ] = None,
    fraction_digits: Union[
        int, CInt, Expression, None
    ] = None,
    _expr_str: Optional[str] = None,
)

Bases: Generic[_P], QScalar

fraction_digits

fraction_digits: Union[CParamScalar, int]

is_signed

is_signed: Union[CParamScalar, bool]

get_qmod_type

get_qmod_type() -> QuantumType

to_qmod_quantum_type

to_qmod_quantum_type(type_hint: Any) -> QuantumType

to_qvar

to_qvar(
    origin: Union[str, HandleBinding],
    type_hint: Any,
    expr_str: Optional[str],
) -> QNum

QSVMFeatureMapPauli

QSVMFeatureMapPauli(
    feature_dimension: CInt,
    reps: CInt,
    entanglement: CInt,
    alpha: CReal,
    paulis: CArray[CArray[Pauli]],
)

alpha

alpha: CReal

entanglement

entanglement: CInt

feature_dimension

feature_dimension: CInt

paulis

paulis: CArray[CArray[Pauli]]

reps

reps: CInt

CCX

CCX(
    control: QArray[QBit, Literal[2]], target: QBit
) -> None

[Qmod core-library function]

Applies the Pauli-X gate to the target qubit, conditioned on the two control qubits (Toffoli).

This operation is represented by the following matrix:

\[ CCX = \begin{bmatrix} 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 \end{bmatrix} \]

More information can be found on Wikipedia.

Parameters:

Name Type Description Default
control QArray[QBit, Literal[2]]

The control qubits.

required
target QBit

The qubit to apply the conditioned Pauli-X gate on.

required

Link: Reference Manual

CH

CH(control: QBit, target: QBit) -> None

[Qmod core-library function]

Applies the Hadamard gate to the target qubit, conditioned on the control qubit.

This operation is represented by the following matrix:

\[ CH = \frac{1}{\sqrt{2}} \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 1 \\ 0 & 0 & 1 & -1 \end{bmatrix} \]

Parameters:

Name Type Description Default
control QBit

The control qubit.

required
target QBit

The qubit to apply the Hadamard gate on.

required

Link: Reference Manual

CPHASE

CPHASE(theta: CReal, control: QBit, target: QBit) -> None

[Qmod core-library function]

Applies the PHASE gate to the target qubit, conditioned on the control qubit.

This operation is represented by the following matrix:

\[ CPHASE = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & e^{i\theta} \end{bmatrix} \]

Parameters:

Name Type Description Default
theta CReal

The rotation angle in radians.

required
control QBit

The control qubit.

required
target QBit

The qubit to apply the PHASE gate on.

required

Link: Reference Manual

CRX

CRX(theta: CReal, control: QBit, target: QBit) -> None

[Qmod core-library function]

Applies the RX gate to the target qubit, conditioned on the control qubit.

This operation is represented by the following matrix:

\[ CRX = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & cos(\frac{\theta}{2}) & -i*sin(\frac{\theta}{2}) \\ 0 & 0 & -i*sin(\frac{\theta}{2}) & cos(\frac{\theta}{2}) \end{bmatrix} \]

Parameters:

Name Type Description Default
theta CReal

The rotation angle in radians.

required
control QBit

The control qubit.

required
target QBit

The qubit to apply the RX gate on.

required

Link: Reference Manual

CRY

CRY(theta: CReal, control: QBit, target: QBit) -> None

[Qmod core-library function]

Applies the RY gate to the target qubit, conditioned on the control qubit.

This operation is represented by the following matrix:

\[ CRY = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & cos(\frac{\theta}{2}) & -sin(\frac{\theta}{2}) \\ 0 & 0 & sin(\frac{\theta}{2}) & cos(\frac{\theta}{2}) \end{bmatrix} \]

Parameters:

Name Type Description Default
theta CReal

The rotation angle in radians.

required
control QBit

The control qubit.

required
target QBit

The qubit to apply the RY gate on.

required

Link: Reference Manual

CRZ

CRZ(theta: CReal, control: QBit, target: QBit) -> None

[Qmod core-library function]

Applies the RZ gate to the target qubit, conditioned on the control qubit.

This operation is represented by the following matrix:

\[ CRZ = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & e^{-i\frac{\theta}{2}} & 0 \\ 0 & 0 & 0 & e^{i\frac{\theta}{2}} \end{bmatrix} \]

Parameters:

Name Type Description Default
theta CReal

The rotation angle in radians.

required
control QBit

The control qubit.

required
target QBit

The qubit to apply the RZ gate on.

required

Link: Reference Manual

CX

CX(control: QBit, target: QBit) -> None

[Qmod core-library function]

Applies the Pauli-X gate to the target qubit, conditioned on the control qubit.

This operation is represented by the following matrix:

\[ CX = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \end{bmatrix} \]

Parameters:

Name Type Description Default
control QBit

The control qubit.

required
target QBit

The qubit to apply the Pauli-X gate on.

required

Link: Reference Manual

CY

CY(control: QBit, target: QBit) -> None

[Qmod core-library function]

Applies the Pauli-Y gate to the target qubit, conditioned on the control qubit.

This operation is represented by the following matrix:

\[ CY = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & -i \\ 0 & 0 & i & 0 \end{bmatrix} \]

Parameters:

Name Type Description Default
control QBit

The control qubit.

required
target QBit

The qubit to apply the Pauli-Y gate on.

required

Link: Reference Manual

CZ

CZ(control: QBit, target: QBit) -> None

[Qmod core-library function]

Applies the Pauli-Z gate to the target qubit, conditioned on the control qubit.

This operation is represented by the following matrix:

\[ CZ = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & -1 \end{bmatrix} \]

Parameters:

Name Type Description Default
control QBit

The control qubit.

required
target QBit

The qubit to apply the Pauli-Z gate on.

required

Link: Reference Manual

H

H(target: QBit) -> None

[Qmod core-library function]

Performs the Hadamard gate on a qubit.

This operation is represented by the following matrix:

\[ H = \frac{1}{\sqrt{2}} \begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix} \]

More information on quantum logic gates can be found on Wikipedia.

Parameters:

Name Type Description Default
target QBit

The qubit to apply the Hadamard gate to.

required

Link: Reference Manual

I

I(target: QBit) -> None

[Qmod core-library function]

Performs the identity gate on a qubit.

This operation is represented by the following matrix:

\[ I = \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix} \]

More information on quantum logic gates can be found on Wikipedia.

Parameters:

Name Type Description Default
target QBit

The qubit to apply the identity gate to.

required

Link: Reference Manual

IDENTITY

IDENTITY(target: QArray[QBit]) -> None

[Qmod core-library function]

Does nothing.

This operation is represented by the following matrix:

\[ IDENTITY = {\begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix}} ^{\otimes n} \]

Parameters:

Name Type Description Default
target QArray[QBit]

The qubits to apply the IDENTITY gate on.

required

Link: Reference Manual

PHASE

PHASE(theta: CReal, target: QBit) -> None

[Qmod core-library function]

Performs the phase gate on a qubit.

This operation is represented by the following matrix:

\[ PHASE(\theta) = \begin{bmatrix} 1 & 0 \\ 0 & e^{i\theta} \end{bmatrix} \]

More information on quantum logic gates can be found on Wikipedia.

Parameters:

Name Type Description Default
theta CReal

The phase angle in radians.

required
target QBit

The qubit to apply the phase gate to.

required

Link: Reference Manual

R

R(theta: CReal, phi: CReal, target: QBit) -> None

[Qmod core-library function]

Performs a rotation of \(\theta\) around the \(cos(\phi)\hat{x} + sin(\phi)\hat{y}\) axis on a qubit.

This operation is represented by the following matrix:

\[ R(\theta, \phi) = e^{-i \frac{\theta}{2} (cos(\phi)X + sin(\phi)Y)} = \begin{bmatrix} cos(\frac{\theta}{2}) & -i e^{-i\phi} sin(\frac{\theta}{2}) \\ -i e^{i\phi} sin(\frac{\theta}{2}) & cos(\frac{\theta}{2}) \end{bmatrix} \]

More information on this gate can be found in the Qiskit documentation.

Parameters:

Name Type Description Default
theta CReal

The rotation angle in radians.

required
phi CReal

The phase angle in radians.

required
target QBit

The qubit to apply the general single-qubit rotation gate to.

required

Link: Reference Manual

RX

RX(theta: CReal, target: QBit) -> None

[Qmod core-library function]

Performs the Pauli-X rotation gate on a qubit.

This operation is represented by the following matrix:

\[ R_X(\theta) = e^{-i\frac{\theta}{2}X} = \begin{bmatrix} cos(\frac{\theta}{2}) & -i sin(\frac{\theta}{2}) \\ -i sin(\frac{\theta}{2}) & cos(\frac{\theta}{2}) \end{bmatrix} \]

More information on quantum logic gates can be found on Wikipedia.

Parameters:

Name Type Description Default
theta CReal

The rotation angle in radians.

required
target QBit

The qubit to apply the Pauli-X rotation gate to.

required

Link: Reference Manual

RXX

RXX(theta: CReal, target: QArray[QBit, Literal[2]]) -> None

[Qmod core-library function]

Performs the XX rotation gate on a pair of qubits.

This operation is represented by the following matrix:

\[ R_{XX}(\theta) = e^{-i\frac{\theta}{2}X \otimes X} = \begin{bmatrix} cos(\frac{\theta}{2}) & 0 & 0 & -i sin(\frac{\theta}{2}) \\ 0 & cos(\frac{\theta}{2}) & -i sin(\frac{\theta}{2}) & 0 \\ 0 & -i sin(\frac{\theta}{2}) & cos(\frac{\theta}{2}) & 0 \\ -i sin(\frac{\theta}{2}) & 0 & 0 & cos(\frac{\theta}{2}) \end{bmatrix} \]

For more information on quantum logic gates, see Wikipedia.

Parameters:

Name Type Description Default
theta CReal

The rotation angle in radians.

required
target QArray[QBit, Literal[2]]

The pair of qubits to apply the XX rotation gate to.

required

Link: Reference Manual

RY

RY(theta: CReal, target: QBit) -> None

[Qmod core-library function]

Performs the Pauli-Y rotation gate on a qubit.

This operation is represented by the following matrix:

\[ R_Y(\theta) = e^{-i\frac{\theta}{2}Y} = \begin{bmatrix} cos(\frac{\theta}{2}) & -sin(\frac{\theta}{2}) \\ -sin(\frac{\theta}{2}) & cos(\frac{\theta}{2}) \end{bmatrix} \]

More information on quantum logic gates can be found on Wikipedia.

Parameters:

Name Type Description Default
theta CReal

The rotation angle in radians.

required
target QBit

The qubit to apply the Pauli-Y rotation gate to.

required

Link: Reference Manual

RYY

RYY(theta: CReal, target: QArray[QBit, Literal[2]]) -> None

[Qmod core-library function]

Performs the YY rotation gate on a pair of qubits.

This operation is represented by the following matrix:

\[ R_{YY}(\theta) = e^{-i\frac{\theta}{2}Y \otimes Y} = \begin{bmatrix} cos(\frac{\theta}{2}) & 0 & 0 & -sin(\frac{\theta}{2}) \\ 0 & cos(\frac{\theta}{2}) & sin(\frac{\theta}{2}) & 0 \\ 0 & sin(\frac{\theta}{2}) & cos(\frac{\theta}{2}) & 0 \\ -sin(\frac{\theta}{2}) & 0 & 0 & cos(\frac{\theta}{2}) \end{bmatrix} \]

For more information on quantum logic gates, see Wikipedia.

Parameters:

Name Type Description Default
theta CReal

The rotation angle in radians.

required
target QArray[QBit, Literal[2]]

The pair of qubits to apply the YY rotation gate to.

required

Link: Reference Manual

RZ

RZ(theta: CReal, target: QBit) -> None

[Qmod core-library function]

Performs the Pauli-Z rotation gate on a qubit.

This operation is represented by the following matrix:

\[ R_Z(\theta) = e^{-i\frac{\theta}{2}Z} = \begin{bmatrix} e^{-i\frac{\theta}{2}} & 0 \\ 0 & e^{i\frac{\theta}{2}} \end{bmatrix} \]

More information on quantum logic gates can be found on Wikipedia.

Parameters:

Name Type Description Default
theta CReal

The rotation angle in radians.

required
target QBit

The qubit to apply the Pauli-Z rotation gate to.

required

Link: Reference Manual

RZZ

RZZ(theta: CReal, target: QArray[QBit, Literal[2]]) -> None

[Qmod core-library function]

Performs the ZZ rotation gate on a pair of qubits.

This operation is represented by the following matrix:

\[ R_{ZZ}(\theta) = e^{-i\frac{\theta}{2}Z \otimes Z} = \begin{bmatrix} e^{-i\frac{\theta}{2}} & 0 & 0 & 0 \\ 0 & e^{i\frac{\theta}{2}} & 0 & 0 \\ 0 & 0 & e^{i\frac{\theta}{2}} & 0 \\ 0 & 0 & 0 & e^{-i\frac{\theta}{2}} \end{bmatrix} \]

For more information on quantum logic gates, see Wikipedia.

Parameters:

Name Type Description Default
theta CReal

The rotation angle in radians.

required
target QArray[QBit, Literal[2]]

The pair of qubits to apply the ZZ rotation gate to.

required

Link: Reference Manual

S

S(target: QBit) -> None

[Qmod core-library function]

Performs the S gate on a qubit.

This operation is represented by the following matrix:

\[ S = \begin{bmatrix} 1 & 0 \\ 0 & i \end{bmatrix} \]

Parameters:

Name Type Description Default
target QBit

The qubit to apply the S gate to.

required

Link: Reference Manual

SDG

SDG(target: QBit) -> None

[Qmod core-library function]

Performs the S-dagger gate on a qubit.

This operation is represented by the following matrix:

\[ S^\dagger = \begin{bmatrix} 1 & 0 \\ 0 & -i \end{bmatrix} \]

Parameters:

Name Type Description Default
target QBit

The qubit to apply the S-dagger gate to.

required

Link: Reference Manual

SWAP

SWAP(qbit0: QBit, qbit1: QBit) -> None

[Qmod core-library function]

Swaps the states of two qubits.

This operation is represented by the following matrix:

\[ SWAP = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix} \]

Parameters:

Name Type Description Default
qbit0 QBit

The first qubit.

required
qbit1 QBit

The second qubit.

required

Link: Reference Manual

T

T(target: QBit) -> None

[Qmod core-library function]

Performs the T gate on a qubit.

This operation is represented by the following matrix:

\[ T = \begin{bmatrix} 1 & 0 \\ 0 & e^{i\frac{\pi}{4}} \end{bmatrix} \]

Parameters:

Name Type Description Default
target QBit

The qubit to apply the T gate to.

required

Link: Reference Manual

TDG

TDG(target: QBit) -> None

[Qmod core-library function]

Performs the T-dagger gate on a qubit.

This operation is represented by the following matrix:

\[ T^\dagger = \begin{bmatrix} 1 & 0 \\ 0 & e^{-i\frac{\pi}{4}} \end{bmatrix} \]

Parameters:

Name Type Description Default
target QBit

The qubit to apply the T-dagger gate to.

required

Link: Reference Manual

U

U(
    theta: CReal,
    phi: CReal,
    lam: CReal,
    gam: CReal,
    target: QBit,
) -> None

[Qmod core-library function]

Performs a general single-qubit unitary gate that applies phase and rotation with three Euler angles on a qubit.

This operation is represented by the following matrix:

\[ U(\theta, \phi, \lambda, \gamma) = e^{i \gamma} \begin{bmatrix} cos(\theta/2) & -e^{i(\lambda)} sin(\theta/2) \\ e^{i\phi} sin(\theta/2) & e^{i(\phi + \lambda)} cos(\theta/2) \end{bmatrix} \]

More information on this gate can be found on Wikipedia.

Parameters:

Name Type Description Default
theta CReal

The first Euler angle in radians.

required
phi CReal

The second Euler angle in radians.

required
lam CReal

The third Euler angle in radians.

required
gam CReal

The global phase angle in radians.

required
target QBit

The qubit to apply the general single-qubit unitary gate to.

required

Link: Reference Manual

X

X(target: QBit) -> None

[Qmod core-library function]

Performs the Pauli-X gate on a qubit.

This operation is represented by the following matrix:

\[ X = \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix} \]

More information on quantum logic gates can be found on Wikipedia.

Parameters:

Name Type Description Default
target QBit

The qubit to apply the Pauli-X gate to.

required

Link: Reference Manual

Y

Y(target: QBit) -> None

[Qmod core-library function]

Performs the Pauli-Y gate on a qubit.

This operation is represented by the following matrix:

\[ Y = \begin{bmatrix} 0 & -i \\ i & 0 \end{bmatrix} \]

More information on quantum logic gates can be found on Wikipedia.

Parameters:

Name Type Description Default
target QBit

The qubit to apply the Pauli-Y gate to.

required

Link: Reference Manual

Z

Z(target: QBit) -> None

[Qmod core-library function]

Performs the Pauli-Z gate on a qubit.

This operation is represented by the following matrix:

\[ Z = \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix} \]

More information on quantum logic gates can be found on Wikipedia.

Parameters:

Name Type Description Default
target QBit

The qubit to apply the Pauli-Z gate to.

required

Link: Reference Manual

add

add(
    left: QArray[QBit],
    right: QArray[QBit],
    result: Output[
        QArray[
            QBit,
            Literal[
                "Max(get_field(left, 'len'), get_field(right, 'len')) + 1"
            ],
        ]
    ],
) -> None

allocate

allocate(
    num_qubits: CInt,
    out: Output[QArray[QBit, Literal["num_qubits"]]],
) -> None

[Qmod core-library function]

Allocates the specified number of qubits to a given quantum variable and initializes them in the zero state:

\[ \left|\text{out}\right\rangle = \left|0\right\rangle^{\otimes \text{num_qubits}} \]

Parameters:

Name Type Description Default
num_qubits CInt

The number of qubits to allocate. Must be a positive integer.

required
out Output[QArray[QBit, Literal['num_qubits']]]

The quantum variable that will receive the allocated qubits. Must be uninitialized before allocation. For more information on quantum variable initialization, see here.

required
Notes
  1. If the output variable has been declared with a specific number of qubits, the number of qubits allocated must match the declared number.
  2. The synthesis engine automatically handles the allocation, either by drawing new qubits from the available pool or by reusing existing ones.

allocate_num

allocate_num(
    num_qubits: CInt,
    is_signed: CBool,
    fraction_digits: CInt,
    out: Output[
        QNum[
            Literal["num_qubits"],
            Literal["is_signed"],
            Literal["fraction_digits"],
        ]
    ],
) -> None

[Qmod Classiq-library function]

Initializes a quantum number with the given number of qubits, sign, and fractional digits.

Parameters:

Name Type Description Default
num_qubits CInt

The number of qubits to allocate.

required
is_signed CBool

Whether the number is signed or unsigned.

required
fraction_digits CInt

The number of fractional digits.

required

Further reading is available on the reference manual

amplitude_estimation

amplitude_estimation(
    oracle: QCallable[QArray[QBit]],
    space_transform: QCallable[QArray[QBit]],
    phase: QNum,
    packed_vars: QArray[QBit],
) -> None

[Qmod Classiq-library function]

Estimate the probability of a state being marked by the operand oracle as a "good state."

The algorithm prepares the state in the packed_vars register and estimates the probability of this state being marked by the oracle as a "good state." This is done using the Quantum Phase Estimation (QPE) algorithm, where the unitary for QPE is the Grover operator, which is composed of the oracle and space_transform operators.

Parameters:

Name Type Description Default
oracle QCallable[QArray[QBit]]

The oracle operator that marks the "good" state. This operator should flip the sign of the amplitude of the "good" state.

required
space_transform QCallable[QArray[QBit]]

The space transform operator (which is known also the state preparation operator), which is first applied to prepare the state before the QPE, and then used inside the Grover operator.

required
phase QNum

Assuming this variable starts from the zero state -this variable output holds the \(phase=\theta\) result in the [0,1] domain, which relates to the estimated probability \(a\) through \(a=\sin^2(\pi \theta)\).

required
packed_vars QArray[QBit]

The variable that holds the state to be estimated. Assumed to be in the zero state at the beginning of the algorithm.

required

apply

apply(operand: QCallable) -> None

apply_to_all

apply_to_all(
    gate_operand: QCallable[QBit], target: QArray[QBit]
) -> None

[Qmod Classiq-library function]

Applies the single-qubit operand gate_operand to each qubit in the qubit array target.

Parameters:

Name Type Description Default
gate_operand QCallable[QBit]

The single-qubit gate to apply to each qubit in the array.

required
target QArray[QBit]

The qubit array to apply the gate to.

required

bloch_sphere_feature_map

bloch_sphere_feature_map(
    feature_dimension: CInt,
    qbv: QArray[
        QBit, Literal["ceiling(feature_dimension / 2)"]
    ],
) -> None

c_modular_multiply

c_modular_multiply(
    n: CInt,
    a: CInt,
    b: QArray[QBit],
    x: QArray[QBit],
    ctrl: QBit,
) -> None

[Qmod Classiq-library function]

Performs out-of-place multiplication of a quantum number x by a classical number a modulo classical number n, controlled by a quantum bit ctrl and adds the result to a quantum array b. Applies \(b += xa \mod n\) if ctrl=1, and the identity otherwise.

Parameters:

Name Type Description Default
n CInt

The modulo number. Should be non-negative.

required
a CInt

The classical factor. Should be non-negative.

required
b QArray[QBit]

The quantum number added to the multiplication result. Stores the result of the multiplication.

required
x QArray[QBit]

The quantum factor.

required
ctrl QBit

The control bit.

required

cc_modular_add

cc_modular_add(
    n: CInt,
    a: CInt,
    phi_b: QArray[QBit],
    c1: QBit,
    c2: QBit,
) -> None

[Qmod Classiq-library function]

Adds a constant a to a quantum number phi_b modulo the constant n, controlled by 2 qubits. The quantum number phi_b and the constant a are assumed to be in the QFT space.

Parameters:

Name Type Description Default
n CInt

The modulo number.

required
a CInt

The constant to add to the quantum number.

required
phi_b QArray[QBit]

The quantum number to which the constant is added.

required
c1 QBit

a control qubit.

required
c2 QBit

a control qubit.

required

exponentiation_with_depth_constraint

exponentiation_with_depth_constraint(
    pauli_operator: CArray[PauliTerm],
    evolution_coefficient: CReal,
    max_depth: CInt,
    qbv: QArray[
        QBit,
        Literal[
            "get_field(get_field(pauli_operator[0], 'pauli'), 'len')"
        ],
    ],
) -> None

[Qmod core-library function]

Exponentiates a Pauli operator via the Suzuki-Trotter decomposition with a depth constraint. The Suzuki-Trotter decomposition is a method for approximating the exponential of a sum of operators by a product of exponentials of each operator. This function automatically determines the order and number of repetitions of the Suzuki-Trotter decomposition to minimize the error given a depth constraint.

See A. M. Childs et al., Toward the first quantum simulation with quantum speedup (2017).

Parameters:

Name Type Description Default
pauli_operator CArray[PauliTerm]

The Pauli operator to be exponentiated.

required
evolution_coefficient CReal

A global coefficient multiplying the Pauli operator.

required
max_depth CInt

The maximum depth of the exponentiation.

required
qbv QArray[QBit, Literal["get_field(get_field(pauli_operator[0], 'pauli'), 'len')"]]

The target quantum variable of the exponentiation.

required

fock_hamiltonian_hartree_fock

fock_hamiltonian_hartree_fock(
    fock_hamiltonian_problem: FockHamiltonianProblem,
    qbv: QArray[
        QBit,
        Literal[
            "get_field(get_field(fock_hamiltonian_problem_to_hamiltonian(fock_hamiltonian_problem)[0], 'pauli'), 'len')"
        ],
    ],
) -> None

fock_hamiltonian_hva

fock_hamiltonian_hva(
    fock_hamiltonian_problem: FockHamiltonianProblem,
    reps: CInt,
    qbv: QArray[
        QBit,
        Literal[
            "get_field(get_field(fock_hamiltonian_problem_to_hamiltonian(fock_hamiltonian_problem)[0], 'pauli'), 'len')"
        ],
    ],
) -> None

fock_hamiltonian_ucc

fock_hamiltonian_ucc(
    fock_hamiltonian_problem: FockHamiltonianProblem,
    excitations: CArray[CInt],
    qbv: QArray[
        QBit,
        Literal[
            "get_field(get_field(fock_hamiltonian_problem_to_hamiltonian(fock_hamiltonian_problem)[0], 'pauli'), 'len')"
        ],
    ],
) -> None

free

free(in_: Input[QArray[QBit]]) -> None

[Qmod core-library function]

Releases the qubits allocated to a quantum variable, allowing them to be reused.

Parameters:

Name Type Description Default
in_ Input[QArray[QBit]]

The quantum variable that will be freed. Must be initialized before. For more information on quantum variable initialization, see here.

required
Note

This operation does not uncompute the qubits. It is the responsibility of the user to ensure that the qubits are at the zero state before freeing them.

full_hea

full_hea(
    num_qubits: CInt,
    is_parametrized: CArray[CInt],
    angle_params: CArray[CReal],
    connectivity_map: CArray[CArray[CInt]],
    reps: CInt,
    operands_1qubit: QCallableList[CReal, QBit],
    operands_2qubit: QCallableList[CReal, QBit, QBit],
    x: QArray[QBit, Literal["num_qubits"]],
) -> None

[Qmod Classiq-library function]

Implements an ansatz on a qubit array x with the given 1-qubit and 2-qubit operations.

The number of ansatz layers is given in argument reps. Each layer applies the 1-qubit operands in operands_1qubit to all the qubits in x. Next, it applies the 2-qubit operands in operands_2qubit to qubits (i, j) for each pair of indices (i, j) in connectivity_map.

The list is_parametrized specifies whether the operands in operands_1qubit and operands_2qubit are parametric (expect a classical argument). is_parametrized is a list of flags (0 and 1 integers) of length len(operands_1qubit) + len(operands_2qubit). The first len(operands_1qubit) flags refer to the operands_1qubit operands and the next len(operands_2qubit) flags refer to the operands_2qubit operands.

The classical arguments to the parametric operands are given in argument angle_params. angle_params concatenates a set of arguments for each ansatz layer. Each set contains an argument for each qubit in x times the number of parametric operands in operands_1qubit. These are followed by an argument for each mapping pair in connectivity_map times the number of parametric operands in operands_2qubit.

Parameters:

Name Type Description Default
num_qubits CInt

The length of qubit array x

required
is_parametrized CArray[CInt]

A list of 0 and 1 flags

required
connectivity_map CArray[CArray[CInt]]

A list of pairs of qubit indices

required
reps CInt

The number of ansatz layers

required
operands_1qubit QCallableList[CReal, QBit]

A list of operations on a single qubit

required
operands_2qubit QCallableList[CReal, QBit, QBit]

A list of operations on two qubits

required
x QArray[QBit, Literal['num_qubits']]

The quantum object to be transformed by the ansatz

required

gaussian_finance

gaussian_finance(
    finance_model: GaussianModel,
    finance_function: FinanceFunction,
    func_port: QArray[
        QBit,
        Literal[
            "get_field(finance_model, 'num_qubits') + get_field(get_field(finance_model, 'rhos'), 'len') + floor(log(sum(get_field(finance_model, 'loss')), 2)) + 1"
        ],
    ],
    obj_port: QBit,
) -> None

grover_diffuser

grover_diffuser(
    space_transform: QCallable[QArray[QBit]],
    packed_vars: QArray[QBit],
) -> None

[Qmod Classiq-library function]

Reflects the given state about the A|0> state, where A is the space_transform parameter. It is defined as:

\[ egin{equation} D = A S_0 A^{\dagger} \end{equation} \]

where \(S_0\) is the reflection about the |0> state (see reflect_about_zero).

Parameters:

Name Type Description Default
space_transform QCallable[QArray[QBit]]

The operator which encodes the axis of reflection.

required
packed_vars QArray[QBit]

The state to which to apply the diffuser.

required

grover_operator

grover_operator(
    oracle: QCallable[QArray[QBit]],
    space_transform: QCallable[QArray[QBit]],
    packed_vars: QArray[QBit],
) -> None

[Qmod Classiq-library function]

Applies the grover operator, defined by:

\[ Q=S_{\psi_0}S_{\psi_1} \]

where \(S_{\psi_1}\) is a reflection about marked states, and \(S_{\psi_0}\) is a reflection about a given state defined by \(|\psi_0 angle = A|0 angle\).

Parameters:

Name Type Description Default
oracle QCallable[QArray[QBit]]

A unitary operator which adds a phase of (-1) to marked states.

required
space_transform QCallable[QArray[QBit]]

The operator which creates \(|\psi_0 angle\), the initial state, used by the diffuser to reflect about it.

required
packed_vars QArray[QBit]

The state to which to apply the grover operator.

required

For further reading, see:

grover_search(
    reps: CInt,
    oracle: QCallable[QArray[QBit]],
    packed_vars: QArray[QBit],
) -> None

[Qmod Classiq-library function]

Applies Grover search algorithm.

Parameters:

Name Type Description Default
reps CInt

Number of repetitions of the grover operator.

required
oracle QCallable[QArray[QBit]]

An oracle that marks the solution.

required
packed_vars QArray[QBit]

Packed form of the variable to apply the grover operator on.

required

Returns: None

hadamard_transform

hadamard_transform(target: QArray[QBit]) -> None

[Qmod Classiq-library function]

Applies Hadamard transform to the target qubits.

Corresponds to the braket notation:

\[ H^{\otimes n} |x angle = rac{1}{\sqrt{2^n}} \sum_{y=0}^{2^n - 1} (-1)^{x \cdot y} |y angle \]

Parameters:

Name Type Description Default
target QArray[QBit]

qubits to apply to Hadamard transform to.

required

inplace_c_modular_multiply

inplace_c_modular_multiply(
    n: CInt, a: CInt, x: QArray[QBit], ctrl: QBit
) -> None

[Qmod Classiq-library function]

Performs multiplication of a quantum number x by a classical number a modulo classical number n, controlled by a quantum bit ctrl. Applies \(x=xa \mod n\) if ctrl=1, and the identity otherwise.

Parameters:

Name Type Description Default
n CInt

The modulo number. Should be non-negative.

required
a CInt

The classical factor. Should be non-negative.

required
x QArray[QBit]

The quantum factor.

required
ctrl QBit

The control bit.

required

inplace_prepare_amplitudes

inplace_prepare_amplitudes(
    amplitudes: CArray[CReal],
    bound: CReal,
    target: QArray[
        QBit,
        Literal["log(get_field(amplitudes, 'len'), 2)"],
    ],
) -> None

[Qmod core-library function]

Transforms a given quantum variable in the state |0> to the state per the specified amplitudes (similar to prepare_amplitudes but preformed on an initialized variable).

Parameters:

Name Type Description Default
amplitudes CArray[CReal]

The amplitudes to initialize the quantum variable. Must be a valid real quantum state vector, i.e., the sum of squares should be 1. Must have a valid length (a power of 2).

required
bound CReal

An error bound, expressed as the \(L^{2}\) norm between the expected and actual distributions. A larger bound can reduce the circuit size at the expense of accuracy. Must be a positive real number.

required
target QArray[QBit, Literal["log(get_field(amplitudes, 'len'), 2)"]]

The quantum variable to act upon.

required

This is useful as part of quantum building blocks like the Grover diffuser operator, \(\left|\psi\right\rangle\left\langle\psi\right| \left( 2\left|0\right\rangle\left\langle0\right| - \mathcal{I} \right)\), where the output state of the oracle is reflected about this state.

inplace_prepare_int

inplace_prepare_int(
    value: CInt, target: QArray[QBit]
) -> None

[Qmod Classiq-library function]

Transitions a quantum variable in the zero state \(|0\rangle\) into the computational basis state \(|\text{value}\rangle\). In the general case, the function performs a bitwise-XOR, i.e. transitions the state \(|\psi\rangle\) into \(|\psi \oplus \text{value}\rangle\).

Parameters:

Name Type Description Default
value CInt

The value to assign to the quantum variable.

required
target QArray[QBit]

The quantum variable to act upon.

required
Note

If the value cannot fit into the quantum variable, it is truncated, i.e. treated as the value modulo \(2^\text{target.size}\).

inplace_prepare_state

inplace_prepare_state(
    probabilities: CArray[CReal],
    bound: CReal,
    target: QArray[
        QBit,
        Literal["log(get_field(probabilities, 'len'), 2)"],
    ],
) -> None

[Qmod core-library function]

Transforms a given quantum variable in the state |0> to the state per the specified probability distribution (similar to prepare_state but preformed on an initialized variable).

Parameters:

Name Type Description Default
probabilities CArray[CReal]

The probability distribution corresponding to the quantum variable state. Must be a valid probability distribution, i.e., a list of non-negative real numbers that sum to 1. Must have a valid length (a power of 2).

required
bound CReal

An error bound, expressed as the \(L^{2}\) norm between the expected and actual distributions. A larger bound can reduce the circuit size at the expense of accuracy. Must be a positive real number.

required
target QArray[QBit, Literal["log(get_field(probabilities, 'len'), 2)"]]

The quantum variable to act upon.

required

This is useful as part of quantum building blocks like the Grover diffuser operator, \(\left|\psi\right\rangle\left\langle\psi\right| \left( 2\left|0\right\rangle\left\langle0\right| - \mathcal{I} \right)\), where the output state of the oracle is reflected about this state.

integer_xor

integer_xor(
    left: QArray[QBit], right: QArray[QBit]
) -> None

linear_pauli_rotations

linear_pauli_rotations(
    bases: CArray[Pauli],
    slopes: CArray[CReal],
    offsets: CArray[CReal],
    x: QArray[QBit],
    q: QArray[QBit],
) -> None

[Qmod Classiq-library function]

Performs a rotation on a series of \(m\) target qubits, where the rotation angle is a linear function of an \(n\)-qubit control register.

Corresponds to the braket notation:

\[ \left|x ight angle _{n}\left|q ight angle _{m} ightarrow\left|x ight angle _{n}\prod_{k=1}^{m}\left(\cos\left( rac{a_{k}}{2}x+ rac{b_{k}}{2} ight)- i\sin\left( rac{a_{k}}{2}x+ rac{b_{k}}{2} ight)P_{k} ight)\left|q_{k} ight angle \]

where \(\left|x ight angle\) is the control register, \(\left|q ight angle\) is the target register, each \(P_{k}\) is one of the three Pauli matrices \(X\), \(Y\), or \(Z\), and \(a_{k}\), \(b_{k}\) are the user given slopes and offsets, respectively.

Parameters:

Name Type Description Default
bases CArray[Pauli]

List of Pauli Enums.

required
slopes CArray[CReal]

Rotation slopes for each of the given Pauli bases.

required
offsets CArray[CReal]

Rotation offsets for each of the given Pauli bases.

required
x QArray[QBit]

Quantum state to apply the rotation based on its value.

required
q QArray[QBit]

List of indicator qubits for each of the given Pauli bases.

required

Notice that bases, slopes, offset and q should be of the same size.

log_normal_finance

log_normal_finance(
    finance_model: LogNormalModel,
    finance_function: FinanceFunction,
    func_port: QArray[
        QBit,
        Literal["get_field(finance_model, 'num_qubits')"],
    ],
    obj_port: QBit,
) -> None

modular_add

modular_add(
    left: QArray[QBit], right: QArray[QBit]
) -> None

modular_exp

modular_exp(
    n: CInt, a: CInt, x: QArray[QBit], power: QArray[QBit]
) -> None

[Qmod Classiq-library function]

Raises a classical integer a to the power of a quantum number x modulo classical integer n times a quantum number power. Performs \(power=(a^x \mod n)*power\) in-place. (and specifically if at the input \(power=1\), at the output \(power=a^x \mod n\)).

Parameters:

Name Type Description Default
n CInt

The modulus number. Should be non-negative.

required
a CInt

The base of the exponentiation. Should be non-negative.

required
x QArray[QBit]

The power of the exponentiation.

required
power QArray[QBit]

A quantum number which multiplies the modular exponentiation and holds the output.

required

modular_increment

modular_increment(a: CInt, x: QNum) -> None

[Qmod Classiq-library function]

Adds \(a\) to \(x\) modulo the range of \(x\), assumed that \(x\) is a non-negative integer and \(a\) is an integer. Mathematically it is described as:

\[ x = (x+a)\ \mod \ 2^{x.size}-1 \]

Parameters:

Name Type Description Default
a CInt

A classical integer to be added to x.

required
x QNum

A quantum number that is assumed to be non-negative integer.

required

molecule_hartree_fock

molecule_hartree_fock(
    molecule_problem: MoleculeProblem,
    qbv: QArray[
        QBit,
        Literal[
            "get_field(get_field(molecule_problem_to_hamiltonian(molecule_problem)[0], 'pauli'), 'len')"
        ],
    ],
) -> None

molecule_hva

molecule_hva(
    molecule_problem: MoleculeProblem,
    reps: CInt,
    qbv: QArray[
        QBit,
        Literal[
            "get_field(get_field(molecule_problem_to_hamiltonian(molecule_problem)[0], 'pauli'), 'len')"
        ],
    ],
) -> None

molecule_ucc

molecule_ucc(
    molecule_problem: MoleculeProblem,
    excitations: CArray[CInt],
    qbv: QArray[
        QBit,
        Literal[
            "get_field(get_field(molecule_problem_to_hamiltonian(molecule_problem)[0], 'pauli'), 'len')"
        ],
    ],
) -> None

multiswap

multiswap(x: QArray[QBit], y: QArray[QBit]) -> None

[Qmod Classiq-library function]

Swaps the qubit states between two arrays. Qubits of respective indices are swapped, and additional qubits in the longer array are left unchanged.

Parameters:

Name Type Description Default
x QArray[QBit]

The first array

required
y QArray[QBit]

The second array

required

pauli_feature_map

pauli_feature_map(
    feature_map: QSVMFeatureMapPauli,
    qbv: QArray[
        QBit,
        Literal[
            "get_field(feature_map, 'feature_dimension')"
        ],
    ],
) -> None

permute

permute(functions: QCallableList) -> None

phase_oracle

phase_oracle(
    predicate: QCallable[QArray[QBit], QBit],
    target: QArray[QBit],
) -> None

[Qmod Classiq-library function]

Creates a phase oracle operator based on a predicate function.

Applies a predicate function and marks "good" and "bad" states with a phase flip. If the predicate is marked as \(\chi\), and the oracle is marked as \(S_\chi\), then:

\[ S_\chi\lvert x angle = egin{cases} -\lvert x angle & ext{if } \chi(x) = 1 \ \phantom{-} \lvert x angle & ext{if } \chi(x) = 0 \end{cases} \]

Parameters:

Name Type Description Default
predicate QCallable[QArray[QBit], QBit]

A predicate function that takes a QArray of QBits and sets a single QBit |1> if the predicate is true, and |0> otherwise.

required
target QArray[QBit]

The target QArray of QBits to apply the phase oracle to.

required
Usage Examples

Grover Algorithm

Hidden shift

prepare_amplitudes

prepare_amplitudes(
    amplitudes: CArray[CReal],
    bound: CReal,
    out: Output[
        QArray[
            QBit,
            Literal["log(get_field(amplitudes, 'len'), 2)"],
        ]
    ],
) -> None

[Qmod core-library function]

Initializes a quantum variable in a state corresponding to the given amplitudes:

\[ \left|\text{out}\right\rangle = \sum_{i=0}^{\text{len(amplitudes)}-1} \text{amplitudes}[i] \left|i\right\rangle \]

with \(i = 0, 1, 2, ..., \text{len(amplitudes)}-1\) corresponding to computational basis states.

Parameters:

Name Type Description Default
amplitudes CArray[CReal]

The amplitudes to initialize the quantum variable. Must be a valid real quantum state vector, i.e., the sum of squares should be 1. Must have a valid length (a power of 2).

required
bound CReal

An error bound, expressed as the \(L^{2}\) norm between the expected and actual distributions. A larger bound can reduce the circuit size at the expense of accuracy. Must be a positive real number.

required
out Output[QArray[QBit, Literal["log(get_field(amplitudes, 'len'), 2)"]]]

The quantum variable that will receive the initialized state. Must be uninitialized. For more information on quantum variable initialization, see here.

required
Notes
  1. If the output variable has been declared with a specific number of qubits, the number of qubits formed by the distribution must match the declared number.
  2. The synthesis engine automatically handles the allocation, either by drawing new qubits from the available pool or by reusing existing ones.

prepare_bell_state

prepare_bell_state(
    state_num: CInt, q: Output[QArray[QBit, Literal[2]]]
) -> None

[Qmod Classiq-library function]

Initializes a quantum array of size 2 in one of the four Bell states.

Parameters:

Name Type Description Default
state_num CInt

The number of the Bell state to be prepared. Must be an integer between 0 and 3.

required
q Output[QArray[QBit, Literal[2]]]

The quantum variable that will receive the initialized state. Must be uninitialized.

required
Bell States

The four Bell states are defined as follows (each state correlates to an integer between 0 and 3 as defined by the state_num argument):

If state_num = 0 the function prepares the Bell state:

\[ \left|\Phi^+\right\rangle = \frac{1}{\sqrt{2}} \left( \left| 00 \right\rangle + \left| 11 \right\rangle \right) \]

If state_num = 1 the function prepares the Bell state:

\[ \left|\Phi^-\right\rangle = \frac{1}{\sqrt{2}} \left( \left| 00 \right\rangle - \left| 11 \right\rangle \right) \]

If state_num = 2 the function prepares the Bell state:

\[ \left|\Psi^+\right\rangle = \frac{1}{\sqrt{2}} \left( \left| 01 \right\rangle + \left| 10 \right\rangle \right) \]

If state_num = 3 the function prepares the Bell state:

\[ \left|\Psi^-\right\rangle = \frac{1}{\sqrt{2}} \left( \left| 01 \right\rangle - \left| 10 \right\rangle \right) \]
Notes

The synthesis engine automatically handles the allocation, either by drawing new qubits from the available pool or by reusing existing ones.

prepare_exponential_state

prepare_exponential_state(
    rate: CInt, q: QArray[QBit]
) -> None

[Qmod Classiq-library function]

Prepares a quantum state with exponentially decreasing amplitudes. The state is prepared in the computational basis, with the amplitudes of the states decreasing exponentially with the index of the state:

\[ P(n) = \frac{1}{Z} e^{- \text{rate} \cdot n} \]

Parameters:

Name Type Description Default
rate CInt

The rate of the exponential decay.

required
q QArray[QBit]

The quantum register to prepare.

required

Further reading is available on the reference manual

prepare_ghz_state

prepare_ghz_state(
    size: CInt, q: Output[QArray[QBit]]
) -> None

[Qmod Classiq-library function]

Initializes a quantum variable in a Greenberger-Horne-Zeilinger (GHZ) state. i.e., a balanced superposition of all ones and all zeros, on an arbitrary number of qubits..

Parameters:

Name Type Description Default
size CInt

The number of qubits in the GHZ state. Must be a positive integer.

required
q Output[QArray[QBit]]

The quantum variable that will receive the initialized state. Must be uninitialized.

required
Notes

The synthesis engine automatically handles the allocation, either by drawing new qubits from the available pool or by reusing existing ones.

prepare_int

prepare_int(
    value: CInt,
    out: Output[
        QNum[
            Literal["floor(log(value, 2)) + 1"],
            Literal[False],
            Literal[0],
        ]
    ],
) -> None

[Qmod Classiq-library function]

Initializes a quantum variable to the computational basis state \(|\text{value}\rangle\). The number of allocated qubits is automatically computed from the value, and is the minimal number required for representation in the computational basis.

Parameters:

Name Type Description Default
value CInt

The value to assign to the quantum variable.

required
out Output[QNum[Literal['floor(log(value, 2)) + 1'], Literal[False], Literal[0]]]

The allocated quantum variable. Must be uninitialized. For more information on quantum variable initialization, see here.

required
Note

If the output variable has been declared with a specific number of qubits, it must match the number of allocated qubits.

prepare_state

prepare_state(
    probabilities: CArray[CReal],
    bound: CReal,
    out: Output[
        QArray[
            QBit,
            Literal[
                "log(get_field(probabilities, 'len'), 2)"
            ],
        ]
    ],
) -> None

[Qmod core-library function]

Initializes a quantum variable in a state corresponding to a given probability distribution:

\[ \left|\text{out}\right\rangle = \sum_{i=0}^{\text{len(probabilities)}-1} \sqrt{\text{probabilities}[i]} \left|i\right\rangle \]

with \(i = 0, 1, 2, ..., \text{len(amplitudes)}-1\) corresponding to computational basis states.

Parameters:

Name Type Description Default
probabilities CArray[CReal]

The probability distribution to initialize the quantum variable. Must be a valid probability distribution, i.e., a list of non-negative real numbers that sum to 1. Must have a valid length (a power of 2).

required
bound CReal

An error bound, expressed as the \(L^{2}\) norm between the expected and actual distributions. A larger bound can reduce the circuit size at the expense of accuracy. Must be a positive real number.

required
out Output[QArray[QBit, Literal["log(get_field(probabilities, 'len'), 2)"]]]

The quantum variable that will receive the initialized state. Must be uninitialized. For more information on quantum variable initialization, see here.

required
Notes
  1. If the output variable has been declared with a specific number of qubits, the number of qubits formed by the distribution must match the declared number.
  2. The synthesis engine automatically handles the allocation, either by drawing new qubits from the available pool or by reusing existing ones.

prepare_uniform_interval_state

prepare_uniform_interval_state(
    start: CInt, end: CInt, q: QArray[QBit]
) -> None

[Qmod Classiq-library function]

Initializes a quantum variable in a uniform superposition of the specified interval in the computational basis states:

\[ \left|\text{q}\right\rangle = \frac{1}{\sqrt{\text{end} - \text{start}}}\sum_{i=\text{start}}^{\text{end}-1}{|i\rangle} \]

The number of allocated qubits would be \(\left\lceil\log_2{\left(\text{end}\right)}\right\rceil\).

Parameters:

Name Type Description Default
start CInt

The lower bound of the interval to load (inclusive).

required
end CInt

The upper bound of the interval to load (exclusive).

required
q QArray[QBit]

The quantum variable that will receive the initialized state. Must be uninitialized. For more information on quantum variable initialization, see here.

required
Notes
  1. If the output variable has been declared with a specific number of qubits, it must match the number of allocated qubits.
  2. The synthesis engine automatically handles the allocation, either by drawing new qubits from the available pool or by reusing existing ones.

prepare_uniform_trimmed_state

prepare_uniform_trimmed_state(
    m: CInt, q: QArray[QBit]
) -> None

[Qmod Classiq-library function]

Initializes a quantum variable in a uniform superposition of the first m computational basis states:

\[ \left|\text{q}\right\rangle = \frac{1}{\sqrt{m}}\sum_{i=0}^{m-1}{|i\rangle} \]

The number of allocated qubits would be \(\left\lceil\log_2{m}\right\rceil\). The function is especially useful when m is not a power of 2.

Parameters:

Name Type Description Default
m CInt

The number of states to load in the superposition.

required
q QArray[QBit]

The quantum variable that will receive the initialized state. Must be uninitialized. For more information on quantum variable initialization, see here.

required
Notes
  1. If the output variable has been declared with a specific number of qubits, it must match the number of allocated qubits.
  2. The synthesis engine automatically handles the allocation, either by drawing new qubits from the available pool or by reusing existing ones.

projector_controlled_phase

projector_controlled_phase(
    phase: CReal,
    proj_cnot: QCallable[QArray[QBit], QBit],
    qvar: QArray[QBit],
    aux: QBit,
) -> None

[Qmod Classiq-library function]

Assigns a phase to the entire subspace determined by the given projector. Corresponds to the operation:

\[ \Pi_{\phi} = (C_{\Pi}NOT) e^{-i rac{\phi}{2}Z}(C_{\Pi}NOT) \]

Parameters:

Name Type Description Default
phase_seq

A rotation phase.

required
proj_cnot QCallable[QArray[QBit], QBit]

Projector-controlled-not unitary that sets an auxilliary qubit to |1> when the state is in the projection.

required
qvar QArray[QBit]

The quantum variable to which the rotation applies, which resides in the entire block encoding space.

required
aux QBit

A zero auxilliary qubit, used for the projector-controlled-phase rotation. Given as an inout so that qsvt can be used as a building-block in a larger algorithm.

required
Further reading in Classiq Library

QSVT function usage example

qaoa_cost_layer

qaoa_cost_layer(
    g: CReal,
    hamiltonian: CArray[PauliTerm],
    target: QArray[QBit],
) -> None

[Qmod Classiq-library function]

Applies the cost layer to the QAOA model.

This function integrates the problem-specific cost function into the QAOA model's objective function. The cost layer represents the primary objective that the QAOA algorithm seeks to optimize, such as minimizing energy or maximizing profit, depending on the application.

For more details on defining cost functions in QAOA models using Pyomo, see: Problem Formulation Args: g: The rotation parameter for the cost layer (prefactor). hamiltonian: The Hamiltonian terms for the QAOA model. target: The target quantum array variable.

qaoa_init

qaoa_init(target: QArray[QBit]) -> None

[Qmod Classiq-library function]

Initializes the QAOA circuit by applying the Hadamard gate to all qubits.

In the Quantum Approximate Optimization Algorithm (QAOA), the initial state is a uniform superposition created by applying the Hadamard gate to each qubit. This function prepares the qubits for the subsequent application of the cost and mixer layers by preparing them in an equal superposition state.

Parameters:

Name Type Description Default
target QArray[QBit]

The target quantum array variable.

required

qaoa_layer

qaoa_layer(
    g: CReal,
    b: CReal,
    hamiltonian: CArray[PauliTerm],
    target: QArray[QBit],
) -> None

[Qmod Classiq-library function]

Applies the QAOA layer, which concatenates the cost layer and the mixer layer.

The qaoa_layer function integrates both the cost and mixer layers, essential components of the Quantum Approximate Optimization Algorithm (QAOA). The cost layer encodes the problem's objective, while the mixer layer introduces quantum superposition and drives the search across the solution space.

For more details mon the QAOA problem formulation, please see the following tutorial Args: g: The rotation parameter for the cost layer. b: The rotation parameter for the mixer layer. hamiltonian: The Hamiltonian terms for the QAOA model. target: The target quantum array variable.

qaoa_mixer_layer

qaoa_mixer_layer(b: CReal, target: QArray[QBit]) -> None

[Qmod Classiq-library function]

Applies the mixer layer for the QAOA algorithm. The mixer layer is a sequence of X gates applied to each qubit in the target quantum array variable.

Please refer to the QAOA mixer tutorial for an example

Parameters:

Name Type Description Default
b CReal

The rotation parameter for the mixer layer.

required
target QArray[QBit]

The target quantum array.

required

qaoa_penalty

qaoa_penalty(
    num_qubits: CInt,
    params_list: CArray[CReal],
    hamiltonian: CArray[PauliTerm],
    target: QArray[QBit, Literal["num_qubits"]],
) -> None

[Qmod Classiq-library function]

Applies the penalty layer to the QAOA model.

This function adds a penalty term to the objective function of the QAOA model to enforce certain constraints (e.g., binary or integer variables) during the optimization process.

Please refer to the Optimization Problem tutorial for details.

Parameters:

Name Type Description Default
num_qubits CInt

The number of qubits in the quantum circuit.

required
hamiltonian CArray[PauliTerm]

The Hamiltonian terms for the QAOA model.

required
target QArray[QBit, Literal['num_qubits']]

The target quantum array variable.

required

qct_qst_type1

qct_qst_type1(x: QArray[QBit]) -> None

[Qmod Classiq-library function]

Applies the quantum discrete cosine (DCT) and sine (DST) transform of type 1 to the qubit array x. Corresponds to the matrix (with \(n\equiv\)x.len):

$$ \left( egin{array}{ccc|c} {} &{} &{} \ {}&{ m DCT}^{(1)}(2^{n-1}+1) & {}& 0\ {} &{} &{} \ \hline {} & 0 & {} & i{ m DST}^{(1)}(2^{n-1}-1) \end{array}

ight) $$

Parameters:

Name Type Description Default
x QArray[QBit]

The qubit array to apply the transform to.

required

qct_qst_type2

qct_qst_type2(x: QArray[QBit], q: QBit) -> None

[Qmod Classiq-library function]

Applies the quantum discrete cosine (DCT) and sine (DST) transform of type 2 to the qubit array x concatenated with q, with q being the MSB. Corresponds to the matrix (with \(n\equiv\)x.len+1):

$$ \left( egin{array}{c|c} { m DCT}^{(2)}(2^{n-1}) & 0\ \hline 0 & -{ m DST}^{(2)}(2^{n-1}) \end{array}

ight) $$

Parameters:

Name Type Description Default
x QArray[QBit]

The LSB part of the qubit array to apply the transform to.

required
q QBit

The MSB of the qubit array to apply the transform to.

required

qct_type2

qct_type2(x: QArray[QBit]) -> None

[Qmod Classiq-library function]

Applies the quantum discrete cosine (DCT) transform of type 2, \({ m DCT}^{(2)}\), to the qubit array x.

Parameters:

Name Type Description Default
x QArray[QBit]

The qubit array to apply the transform to.

required

qdrift

qdrift(
    pauli_operator: CArray[PauliTerm],
    evolution_coefficient: CReal,
    num_qdrift: CInt,
    qbv: QArray[
        QBit,
        Literal[
            "get_field(get_field(pauli_operator[0], 'pauli'), 'len')"
        ],
    ],
) -> None

[Qmod core-library function]

Exponentiates a Pauli operator using the QDrift method. The QDrift method is a stochastic method based on the Trotter decomposition for approximating the exponential of a sum of operators by a product of exponentials of each operator. The QDrift method randomizes the order of the operators in the product of exponentials to stochastically reduce the error of the approximation. The error of the QDrift method decreases as the number of QDrift steps increases.

See E. Campbell, Random Compiler for Fast Hamiltonian Simulation (2019).

Parameters:

Name Type Description Default
pauli_operator CArray[PauliTerm]

The Pauli operator to be exponentiated.

required
evolution_coefficient CReal

A global evolution coefficient multiplying the Pauli operator.

required
num_qdrift

The number of QDrift steps.

required
qbv QArray[QBit, Literal["get_field(get_field(pauli_operator[0], 'pauli'), 'len')"]]

The target quantum variable of the exponentiation.

required

qft

qft(target: QArray[QBit]) -> None

[Qmod Classiq-library function]

Performs the Quantum Fourier Transform (QFT) on target in-place. Implements the following transformation:

\[ y_{k} = \frac{1}{\sqrt{N}} \sum_{j=0}^{N-1} x_j e^{2\pi i \frac{jk}{N}} \]

Parameters:

Name Type Description Default
target QArray[QBit]

The quantum object to be transformed

required

Further reading in Classiq Library: Link: qft library reference

qft_no_swap

qft_no_swap(qbv: QArray[QBit]) -> None

[Qmod Classiq-library function]

Applies the Quantum Fourier Transform (QFT) without the swap gates.

Parameters:

Name Type Description Default
qbv QArray[QBit]

The quantum number to which the QFT is applied.

required

qft_space_add_const

qft_space_add_const(
    value: CInt, phi_b: QArray[QBit]
) -> None

[Qmod Classiq-library function]

Adds a constant to a quantum number (in the Fourier space) using the Quantum Fourier Transform (QFT) Adder algorithm. Assuming that the input phi_b has n qubits, the result will be \(\phi_b+=value \mod 2^n\).

To perform the full algorithm, use: within_apply(lambda: QFT(phi_b), qft_space_add_const(value, phi_b))

Parameters:

Name Type Description Default
value CInt

The constant to add to the quantum number.

required
phi_b QArray[QBit]

The quantum number (at the aft space) to which the constant is added.

required

qfunc

qfunc(
    func: Optional[Callable] = None,
    *,
    external: bool = False,
    generative: bool = False
) -> Union[Callable[[Callable], QCallable], QCallable]

qpe

qpe(unitary: QCallable, phase: QNum) -> None

[Qmod Classiq-library function]

Implements the standard Quantum Phase Estimation (QPE) algorithm, which estimates the phase (eigenvalue) associated with an eigenstate of a given unitary operator \(U\).

Parameters:

Name Type Description Default
unitary QCallable

A callable representing the unitary operator \(U\), whose eigenvalue is to be estimated.

required
phase QNum

The quantum variable that represents the estimated phase (eigenvalue), assuming initialized to zero.

required

Further reading in Classiq Library: Link: qpe library reference

qpe_flexible

qpe_flexible(
    unitary_with_power: QCallable[CInt], phase: QNum
) -> None

[Qmod Classiq-library function]

Implements the Quantum Phase Estimation (QPE) algorithm, which estimates the phase (eigenvalue) associated with an eigenstate of a given unitary operator \(U\). This is a flexible version that allows the user to provide a callable that generates the unitary operator \(U^k\) for a given integer \(k\), offering greater flexibility in handling different quantum circuits using some powering rule.

Parameters:

Name Type Description Default
unitary_with_power QCallable[CInt]

A callable that returns the unitary operator \(U^k\) given an integer \(k\). This callable is used to control the application of powers of the unitary operator.

required
phase QNum

The quantum variable that represents the estimated phase (eigenvalue), assuming initialized to zero.

required

Further reading in Classiq Library: Link: qpe library reference

qst_type2

qst_type2(x: QArray[QBit]) -> None

[Qmod Classiq-library function]

Applies the quantum discrete sine (DST) transform of type 2, \({ m DST}^{(2)}\), to the qubit array x.

Parameters:

Name Type Description Default
x QArray[QBit]

The qubit array to apply the transform to.

required

qsvt

qsvt(
    phase_seq: CArray[CReal],
    proj_cnot_1: QCallable[QArray[QBit], QBit],
    proj_cnot_2: QCallable[QArray[QBit], QBit],
    u: QCallable[QArray[QBit]],
    qvar: QArray[QBit],
    aux: QBit,
) -> None

[Qmod Classiq-library function]

Implements the Quantum Singular Value Transformation (QSVT) - an algorithmic framework, used to apply polynomial transformations of degree d on the singular values of a block encoded matrix, given as the unitary u. Given a unitary \(U\), a list of phase angles \(\phi_1, \phi_2, ..., \phi_{d+1}\) and 2 projector-controlled-not operands \(C_{\Pi}NOT,C_{ ilde{\Pi}}NOT\), the QSVT sequence is as follows: Given a unitary \(U\), a list of phase angles \(\phi_1, \phi_2, ..., \phi_{d+1}\) and 2 projector-controlled-not operands \(C_{\Pi}NOT,C_{ ilde{\Pi}}NOT\), the QSVT sequence is as follows:

\[ ilde{\Pi}_{\phi_{d+1}}U \prod_{k=1}^{(d-1)/2} (\Pi_{\phi_{d-2k}} U^{\dagger} ilde{\Pi}_{\phi_{d - (2k+1)}}U)\Pi_{\phi_{1}} \]

for odd \(d\), and:

\[ \prod_{k=1}^{d/2} (\Pi_{\phi_{d-(2k-1)}} U^{\dagger} ilde{\Pi}_{\phi_{d-2k}}U)\Pi_{\phi_{1}} \]

for even \(d\).

Each of the \(\Pi\)s is a projector-controlled-phase unitary, according to the given projectors.

Parameters:

Name Type Description Default
phase_seq CArray[CReal]

A sequence of phase angles of length d+1.

required
proj_cnot_1 QCallable[QArray[QBit], QBit]

Projector-controlled-not unitary that locates the encoded matrix columns within U. Accepts a quantum variable of the same size as qvar, and a qubit that is set to |1> when the state is in the block.

required
proj_cnot_2 QCallable[QArray[QBit], QBit]

Projector-controlled-not unitary that locates the encoded matrix rows within U. Accepts a quantum variable of the same size as qvar, and a qubit that is set to |1> when the state is in the block.

required
u QCallable[QArray[QBit]]

A block encoded unitary matrix.

required
qvar QArray[QBit]

The quantum variable to which U is applied, which resides in the entire block encoding space.

required
aux QBit

A zero auxilliary qubit, used for the projector-controlled-phase rotations. Given as an inout so that qsvt can be used as a building-block in a larger algorithm.

required
Further reading in Classiq Library

QSVT function usage example

qsvt_inversion

qsvt_inversion(
    phase_seq: CArray[CReal],
    block_encoding_cnot: QCallable[QArray[QBit], QBit],
    u: QCallable[QArray[QBit]],
    qvar: QArray[QBit],
    aux: QBit,
) -> None

[Qmod Classiq-library function]

Implements matrix inversion on a given block-encoding of a square matrix, using the QSVT framework. Applies a polynomial approximation of the inverse of the singular values of the matrix encoded in u. The phases for the polynomial should be pre-calculated and passed into the function.

Parameters:

Name Type Description Default
phase_seq CArray[CReal]

A sequence of phase angles of length d+1, corresponding to an odd polynomial approximation of the scaled inverse function.

required
block_encoding_cnot QCallable[QArray[QBit], QBit]

Projector-controlled-not unitary that locates the encoded matrix columns within U. Accepts a quantum variable of the same size as qvar, and a qubit that is set to |1> when the state is in the block.

required
u QCallable[QArray[QBit]]

A block encoded unitary matrix.

required
qvar QArray[QBit]

The quantum variable to which U is applied, which resides in the entire block encoding space.

required
aux QBit

A zero auxilliary qubit, used for the projector-controlled-phase rotations. Given as an inout so that qsvt can be used as a building-block in a larger algorithm.

required

For usage example, see: QSVT matrix inversion example

qsvt_step

qsvt_step(
    phase1: CReal,
    phase2: CReal,
    proj_cnot_1: QCallable[QArray[QBit], QBit],
    proj_cnot_2: QCallable[QArray[QBit], QBit],
    u: QCallable[QArray[QBit]],
    qvar: QArray[QBit],
    aux: QBit,
) -> None

[Qmod Classiq-library function]

Applies a single QSVT step, composed of 2 projector-controlled-phase rotations, and applications of the block encoding unitary u and its inverse:

\[ \Pi_{\phi_2}U^{\dagger} ilde{\Pi}_{\phi_{1}}U \]

Parameters:

Name Type Description Default
phase1 CReal

1st rotation phase.

required
phase2 CReal

2nd rotation phase.

required
proj_cnot_1 QCallable[QArray[QBit], QBit]

Projector-controlled-not unitary that locates the encoded matrix columns within U. Accepts a quantum variable of the same size as qvar, and a qubit that is set to |1> when the state is in the block.

required
proj_cnot_2 QCallable[QArray[QBit], QBit]

Projector-controlled-not unitary that locates the encoded matrix rows within U. Accepts a quantum variable of the same size as qvar, and a qubit that is set to |1> when the state is in the block.

required
u QCallable[QArray[QBit]]

A block encoded unitary matrix.

required
qvar QArray[QBit]

The quantum variable to which U is applied, which resides in the entire block encoding space.

required
aux QBit

A zero auxilliary qubit, used for the projector-controlled-phase rotations. Given as an inout so that qsvt can be used as a building-block in a larger algorithm.

required
Further reading in Classiq Library

QSVT function usage example

randomized_benchmarking

randomized_benchmarking(
    num_of_cliffords: CInt, target: QArray[QBit]
) -> None

reflect_about_zero

reflect_about_zero(packed_vars: QArray[QBit]) -> None
[Qmod Classiq-library function]

Reflects the state about the |0> state (i.e. applies a (-1) phase to all states
besides the |0> state). Implements the operator $S_0$:

$$
egin{equation}
S_0|{x}

angle = (-1)^{(x e0)}|{x} angle= (2|{0} angle\langle{0}|-I)|{x} angle \end{equation} $$

Args:
    packed_vars: The quantum state to reflect.

single_pauli_exponent

single_pauli_exponent(
    pauli_string: CArray[Pauli],
    coefficient: CReal,
    qbv: QArray[
        QBit, Literal["get_field(pauli_string, 'len')"]
    ],
) -> None

[Qmod core-library function]

Exponentiates the specified single Pauli operator multiplied by some coefficient.

Parameters:

Name Type Description Default
pauli_string CArray[Pauli]

The Pauli operator to be exponentiated.

required
coefficient CReal

A coefficient multiplying the Pauli operator.

required
qbv QArray[QBit, Literal["get_field(pauli_string, 'len')"]]

The target quantum variable of the exponentiation.

required

suzuki_trotter

suzuki_trotter(
    pauli_operator: CArray[PauliTerm],
    evolution_coefficient: CReal,
    order: CInt,
    repetitions: CInt,
    qbv: QArray[
        QBit,
        Literal[
            "get_field(get_field(pauli_operator[0], 'pauli'), 'len')"
        ],
    ],
) -> None

[Qmod core-library function]

Applies the Suzuki-Trotter decomposition to a Pauli operator. The Suzuki-Trotter decomposition is a method for approximating the exponential of a sum of operators by a product of exponentials of each operator. The Suzuki-Trotter decomposition of a given order nullifies the error of the Taylor series expansion of the product of exponentials up to that order. The error of a Suzuki-Trotter decomposition decreases as the order and number of repetitions increase.

See N. Hatano and M. Suzuki, Finding Exponential Product Formulas of Higher Orders (2005).

Parameters:

Name Type Description Default
pauli_operator CArray[PauliTerm]

The Pauli operator to be exponentiated.

required
evolution_coefficient CReal

A global evolution coefficient multiplying the Pauli operator.

required
order CInt

The order of the Suzuki-Trotter decomposition.

required
repetitions CInt

The number of repetitions of the Suzuki-Trotter decomposition.

required
qbv QArray[QBit, Literal["get_field(get_field(pauli_operator[0], 'pauli'), 'len')"]]

The target quantum variable of the exponentiation.

required

swap_test

swap_test(
    state1: QArray[QBit],
    state2: QArray[QBit],
    test: Output[QBit],
) -> None

[Qmod Classiq-library function]

Tests the overlap (in terms of fidelity) of two quantum states. The fidelity of state1 and state2 is calculated from the probability of measuring test qubit in the state 0 as follows:

\[ |\langle state1 | state2 \rangle |^2 = 2*Prob(test=0)-1 \]

Parameters:

Name Type Description Default
state1 QArray[QBit]

A quantum state to check its overlap with state2.

required
state2 QArray[QBit]

A quantum state to check its overlap with state1.

required
test Output[QBit]

A qubit for which the probability of measuring 0 is \(0.5*(|\langle state1 | state2 \rangle |^2+1)\)

required
Example

Further reading in the Classiq library is found here.

switch

switch(selector: CInt, cases: QCallableList) -> None

unitary

unitary(
    elements: CArray[CArray[CReal]],
    target: QArray[
        QBit,
        Literal["log(get_field(elements[0], 'len'), 2)"],
    ],
) -> None

[Qmod core-library function]

Applies a unitary matrix on a quantum state.

Parameters:

Name Type Description Default
elements CArray[CArray[CReal]]

A 2d array of complex numbers representing the unitary matrix. This matrix must be unitary.

required
target QArray[QBit, Literal["log(get_field(elements[0], 'len'), 2)"]]

The quantum state to apply the unitary on. Should be of corresponding size.

required

Links: Reference Manual

enums

BUILTIN_ENUM_DECLARATIONS

BUILTIN_ENUM_DECLARATIONS = {__name__: EnumDeclaration(name=__name__, members={name: _PSEbfor enum_val in enum_def})for enum_def in values() if isinstance(enum_def, type) and issubclass(enum_def, IntEnum) and enum_def is not IntEnum}

Element

Bases: IntEnum

Ac

Ac = 88

Ag

Ag = 46

Al

Al = 12

Am

Am = 94

Ar

Ar = 17

As

As = 32

At

At = 84

Au

Au = 78

B

B = 4

Ba

Ba = 55

Be

Be = 3

Bh

Bh = 106

Bi

Bi = 82

Bk

Bk = 96

Br

Br = 34

C

C = 5

Ca

Ca = 19

Cd

Cd = 47

Ce

Ce = 57

Cf

Cf = 97

Cl

Cl = 16

Cm

Cm = 95

Cn

Cn = 111

Co

Co = 26

Cr

Cr = 23

Cs

Cs = 54

Cu

Cu = 28

Db

Db = 104

Ds

Ds = 109

Dy

Dy = 65

Er

Er = 67

Es

Es = 98

Eu

Eu = 62

F

F = 8

Fe

Fe = 25

Fl

Fl = 113

Fm

Fm = 99

Fr

Fr = 86

Ga

Ga = 30

Gd

Gd = 63

Ge

Ge = 31

H

H = 0

He

He = 1

Hf

Hf = 71

Hg

Hg = 79

Ho

Ho = 66

Hs

Hs = 107

I

I = 52

In

In = 48

Ir

Ir = 76

K

K = 18

Kr

Kr = 35

La

La = 56

Li

Li = 2

Lr

Lr = 102

Lu

Lu = 70

Lv

Lv = 115

Mc

Mc = 114

Md

Md = 100

Mg

Mg = 11

Mn

Mn = 24

Mo

Mo = 41

Mt

Mt = 108

N

N = 6

Na

Na = 10

Nb

Nb = 40

Nd

Nd = 59

Ne

Ne = 9

Nh

Nh = 112

Ni

Ni = 27

No

No = 101

Np

Np = 92

O

O = 7

Og

Og = 117

Os

Os = 75

P

P = 14

Pa

Pa = 90

Pb

Pb = 81

Pd

Pd = 45

Pm

Pm = 60

Po

Po = 83

Pr

Pr = 58

Pt

Pt = 77

Pu

Pu = 93

Ra

Ra = 87

Rb

Rb = 36

Re

Re = 74

Rf

Rf = 103

Rg

Rg = 110

Rh

Rh = 44

Rn

Rn = 85

Ru

Ru = 43

S

S = 15

Sb

Sb = 50

Sc

Sc = 20

Se

Se = 33

Sg

Sg = 105

Si

Si = 13

Sm

Sm = 61

Sn

Sn = 49

Sr

Sr = 37

Ta

Ta = 72

Tb

Tb = 64

Tc

Tc = 42

Te

Te = 51

Th

Th = 89

Ti

Ti = 21

Tl

Tl = 80

Tm

Tm = 68

Ts

Ts = 116

U

U = 91

V

V = 22

W

W = 73

Xe

Xe = 53

Y

Y = 38

Yb

Yb = 69

Zn

Zn = 29

Zr

Zr = 39

FermionMapping

Bases: IntEnum

BRAVYI_KITAEV

BRAVYI_KITAEV = 2

FAST_BRAVYI_KITAEV

FAST_BRAVYI_KITAEV = 3

JORDAN_WIGNER

JORDAN_WIGNER = 0

PARITY

PARITY = 1

FinanceFunctionType

Bases: IntEnum

EUROPEAN_CALL_OPTION

EUROPEAN_CALL_OPTION = 3

SHORTFALL

SHORTFALL = 1

VAR

VAR = 0

X_SQUARE

X_SQUARE = 2

LadderOperator

Bases: IntEnum

MINUS

MINUS = 1

PLUS

PLUS = 0

Optimizer

Bases: IntEnum

ADAM

ADAM = 5

COBYLA

COBYLA = 1

L_BFGS_B

L_BFGS_B = 3

NELDER_MEAD

NELDER_MEAD = 4

SPSA

SPSA = 2

Pauli

Bases: IntEnum

Enumeration for the Pauli matrices used in quantum computing.

The Pauli matrices are fundamental operations in quantum computing, and this enum assigns integer values to represent each matrix.

I

I = 0

I (int): Identity matrix, represented by the integer 0.

\(I = \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix}\)

X

X = 1

X (int): Pauli-X matrix, represented by the integer 1.

\(X = \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}\)

Y

Y = 2

Y (int): Pauli-Y matrix, represented by the integer 2.

\(Y = \begin{bmatrix} 0 & -i \\ i & 0 \end{bmatrix}\)

Z

Z = 3

Z (int): Pauli-Z matrix, represented by the integer 3.

\(Z = \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix}\)

QSVMFeatureMapEntanglement

Bases: IntEnum

CIRCULAR

CIRCULAR = 2

FULL

FULL = 0

LINEAR

LINEAR = 1

PAIRWISE

PAIRWISE = 4

SCA

SCA = 3

structs

BUILTIN_STRUCT_DECLARATIONS

BUILTIN_STRUCT_DECLARATIONS = {
    __name__: StructDeclaration(
        name=__name__,
        variables={
            name: convert(type)
            for field in fields(struct_decl)
        },
    )
    for struct_decl in values()
    if is_dataclass(struct_decl)
}

ChemistryAtom

ChemistryAtom(element: CInt, position: Position)

element

element: CInt

position

position: Position

CombinatorialOptimizationSolution

CombinatorialOptimizationSolution(
    probability: CReal,
    cost: CReal,
    solution: CArray[CInt],
    count: CInt,
)

cost

cost: CReal

count

count: CInt

probability

probability: CReal

solution

solution: CArray[CInt]

FinanceFunction

FinanceFunction(
    f: CInt,
    threshold: CReal,
    larger: CBool,
    polynomial_degree: CInt,
    use_chebyshev_polynomial_approximation: CBool,
    tail_probability: CReal,
)

f

f: CInt

larger

larger: CBool

polynomial_degree

polynomial_degree: CInt

tail_probability

tail_probability: CReal

threshold

threshold: CReal

use_chebyshev_polynomial_approximation

use_chebyshev_polynomial_approximation: CBool

FockHamiltonianProblem

FockHamiltonianProblem(
    mapping: CInt,
    z2_symmetries: CBool,
    terms: CArray[LadderTerm],
    num_particles: CArray[CInt],
)

mapping

mapping: CInt

num_particles

num_particles: CArray[CInt]

terms

z2_symmetries

z2_symmetries: CBool

GaussianModel

GaussianModel(
    num_qubits: CInt,
    normal_max_value: CReal,
    default_probabilities: CArray[CReal],
    rhos: CArray[CReal],
    loss: CArray[CInt],
    min_loss: CInt,
)

default_probabilities

default_probabilities: CArray[CReal]

loss

loss: CArray[CInt]

min_loss

min_loss: CInt

normal_max_value

normal_max_value: CReal

num_qubits

num_qubits: CInt

rhos

rhos: CArray[CReal]

LadderOp

LadderOp(op: LadderOperator, index: CInt)

index

index: CInt

LadderTerm

LadderTerm(coefficient: CReal, ops: CArray[LadderOp])

coefficient

coefficient: CReal

ops

LogNormalModel

LogNormalModel(num_qubits: CInt, mu: CReal, sigma: CReal)

mu

mu: CReal

num_qubits

num_qubits: CInt

sigma

sigma: CReal

Molecule

Molecule(
    atoms: CArray[ChemistryAtom], spin: CInt, charge: CInt
)

atoms

charge

charge: CInt

spin

spin: CInt

MoleculeProblem

MoleculeProblem(
    mapping: CInt,
    z2_symmetries: CBool,
    molecule: Molecule,
    freeze_core: CBool,
    remove_orbitals: CArray[CInt],
)

freeze_core

freeze_core: CBool

mapping

mapping: CInt

molecule

molecule: Molecule

remove_orbitals

remove_orbitals: CArray[CInt]

z2_symmetries

z2_symmetries: CBool

PauliTerm

PauliTerm(pauli: CArray[Pauli], coefficient: CReal)

A term in a Hamiltonian, represented as a product of Pauli operators.

Attributes:

Name Type Description
pauli CArray[Pauli]

The list of the chosen Pauli operators in the term, corresponds to a product of them.

coefficient CReal

The coefficient of the term (floating number).

coefficient

coefficient: CReal

pauli

pauli: CArray[Pauli]

Position

Position(x: CReal, y: CReal, z: CReal)

x

x: CReal

y

y: CReal

z

z: CReal

QSVMFeatureMapPauli

QSVMFeatureMapPauli(
    feature_dimension: CInt,
    reps: CInt,
    entanglement: CInt,
    alpha: CReal,
    paulis: CArray[CArray[Pauli]],
)

alpha

alpha: CReal

entanglement

entanglement: CInt

feature_dimension

feature_dimension: CInt

paulis

paulis: CArray[CArray[Pauli]]

reps

reps: CInt

QsvmResult

QsvmResult(
    test_score: CReal, predicted_labels: CArray[CReal]
)

predicted_labels

predicted_labels: CArray[CReal]

test_score

test_score: CReal

classical_execution_primitives

CARRAY_SEPARATOR

CARRAY_SEPARATOR: Final[str] = '_'

ExecutionParams

ExecutionParams = Dict[
    str, Union[float, int, List[int], List[float]]
]

batch_estimate

batch_estimate(
    hamiltonian: List[QmodPyStruct],
    batch_execution_params: List[ExecutionParams],
) -> EstimationResults

batch_sample

batch_sample(
    batch_execution_params: List[ExecutionParams],
) -> MultipleExecutionDetails

estimate

estimate(
    hamiltonian: List[QmodPyStruct],
    execution_params: Optional[ExecutionParams] = None,
) -> EstimationResult

iqae

iqae(
    epsilon: float,
    alpha: float,
    execution_params: Optional[ExecutionParams] = None,
) -> IQAEResult

molecule_ground_state_solution_post_process

molecule_ground_state_solution_post_process(
    problem: QmodPyStruct, vqe_result: VQESolverResult
) -> QmodPyStruct

qae_with_qpe_result_post_processing

qae_with_qpe_result_post_processing(
    estimation_register_size: int,
    estimation_method: QaeWithQpeEstimationMethod,
    result: ExecutionDetails,
) -> float

qsvm_full_run

qsvm_full_run(
    train_data: Data,
    train_labels: Labels,
    test_data: Data,
    test_labels: Labels,
    predict_data: Data,
) -> QmodPyStruct

sample

sample(
    execution_params: Optional[ExecutionParams] = None,
) -> ExecutionDetails

save

save(values_to_save: dict) -> None

vqe

vqe(
    hamiltonian: List[QmodPyStruct],
    maximize: bool,
    initial_point: List[float],
    optimizer: Optimizer,
    max_iteration: int,
    tolerance: float,
    step_size: float,
    skip_compute_variance: bool,
    alpha_cvar: float,
) -> VQESolverResult

classical_functions

ChemistryAtom

ChemistryAtom(element: CInt, position: Position)

element

element: CInt

position

position: Position

CombinatorialOptimizationSolution

CombinatorialOptimizationSolution(
    probability: CReal,
    cost: CReal,
    solution: CArray[CInt],
    count: CInt,
)

cost

cost: CReal

count

count: CInt

probability

probability: CReal

solution

solution: CArray[CInt]

FinanceFunction

FinanceFunction(
    f: CInt,
    threshold: CReal,
    larger: CBool,
    polynomial_degree: CInt,
    use_chebyshev_polynomial_approximation: CBool,
    tail_probability: CReal,
)

f

f: CInt

larger

larger: CBool

polynomial_degree

polynomial_degree: CInt

tail_probability

tail_probability: CReal

threshold

threshold: CReal

use_chebyshev_polynomial_approximation

use_chebyshev_polynomial_approximation: CBool

FockHamiltonianProblem

FockHamiltonianProblem(
    mapping: CInt,
    z2_symmetries: CBool,
    terms: CArray[LadderTerm],
    num_particles: CArray[CInt],
)

mapping

mapping: CInt

num_particles

num_particles: CArray[CInt]

terms

z2_symmetries

z2_symmetries: CBool

GaussianModel

GaussianModel(
    num_qubits: CInt,
    normal_max_value: CReal,
    default_probabilities: CArray[CReal],
    rhos: CArray[CReal],
    loss: CArray[CInt],
    min_loss: CInt,
)

default_probabilities

default_probabilities: CArray[CReal]

loss

loss: CArray[CInt]

min_loss

min_loss: CInt

normal_max_value

normal_max_value: CReal

num_qubits

num_qubits: CInt

rhos

rhos: CArray[CReal]

LadderOp

LadderOp(op: LadderOperator, index: CInt)

index

index: CInt

LadderTerm

LadderTerm(coefficient: CReal, ops: CArray[LadderOp])

coefficient

coefficient: CReal

ops

LogNormalModel

LogNormalModel(num_qubits: CInt, mu: CReal, sigma: CReal)

mu

mu: CReal

num_qubits

num_qubits: CInt

sigma

sigma: CReal

Molecule

Molecule(
    atoms: CArray[ChemistryAtom], spin: CInt, charge: CInt
)

atoms

charge

charge: CInt

spin

spin: CInt

MoleculeProblem

MoleculeProblem(
    mapping: CInt,
    z2_symmetries: CBool,
    molecule: Molecule,
    freeze_core: CBool,
    remove_orbitals: CArray[CInt],
)

freeze_core

freeze_core: CBool

mapping

mapping: CInt

molecule

molecule: Molecule

remove_orbitals

remove_orbitals: CArray[CInt]

z2_symmetries

z2_symmetries: CBool

PauliTerm

PauliTerm(pauli: CArray[Pauli], coefficient: CReal)

A term in a Hamiltonian, represented as a product of Pauli operators.

Attributes:

Name Type Description
pauli CArray[Pauli]

The list of the chosen Pauli operators in the term, corresponds to a product of them.

coefficient CReal

The coefficient of the term (floating number).

coefficient

coefficient: CReal

pauli

pauli: CArray[Pauli]

Position

Position(x: CReal, y: CReal, z: CReal)

x

x: CReal

y

y: CReal

z

z: CReal

QSVMFeatureMapPauli

QSVMFeatureMapPauli(
    feature_dimension: CInt,
    reps: CInt,
    entanglement: CInt,
    alpha: CReal,
    paulis: CArray[CArray[Pauli]],
)

alpha

alpha: CReal

entanglement

entanglement: CInt

feature_dimension

feature_dimension: CInt

paulis

paulis: CArray[CArray[Pauli]]

reps

reps: CInt

QsvmResult

QsvmResult(
    test_score: CReal, predicted_labels: CArray[CReal]
)

predicted_labels

predicted_labels: CArray[CReal]

test_score

test_score: CReal

fock_hamiltonian_problem_to_hamiltonian

fock_hamiltonian_problem_to_hamiltonian(
    problem: FockHamiltonianProblem,
) -> CArray[PauliTerm]

gaussian_finance_post_process

gaussian_finance_post_process(
    finance_model: GaussianModel,
    estimation_method: FinanceFunction,
    probability: CReal,
) -> CReal

grid_entangler_graph

grid_entangler_graph(
    num_qubits: CInt,
    schmidt_rank: CInt,
    grid_randomization: CBool,
) -> CArray[CArray[CInt]]

hypercube_entangler_graph

hypercube_entangler_graph(
    num_qubits: CInt,
) -> CArray[CArray[CInt]]

log_normal_finance_post_process

log_normal_finance_post_process(
    finance_model: LogNormalModel,
    estimation_method: FinanceFunction,
    probability: CReal,
) -> CReal

molecule_problem_to_hamiltonian

molecule_problem_to_hamiltonian(
    problem: MoleculeProblem,
) -> CArray[PauliTerm]

qft_const_adder_phase

qft_const_adder_phase(
    bit_index: CInt, value: CInt, reg_len: CInt
) -> CReal

qfunc

DEC_QFUNCS

DEC_QFUNCS: List[QFunc] = []

GEN_QFUNCS

GEN_QFUNCS: List[GenerativeQFunc] = []

qfunc

qfunc(
    func: Optional[Callable] = None,
    *,
    external: bool = False,
    generative: bool = False
) -> Union[Callable[[Callable], QCallable], QCallable]

set_discovered_functions

set_discovered_functions(
    dec_funcs: List[QFunc], gen_funcs: List[GenerativeQFunc]
) -> None

QBit

QBit(
    origin: Union[str, HandleBinding],
    *,
    _expr_str: Optional[str] = None,
    depth: int = 2
)

Bases: QScalar

get_qmod_type

get_qmod_type() -> QuantumType

to_qmod_quantum_type

to_qmod_quantum_type(type_hint: Any) -> QuantumType

to_qvar

to_qvar(
    origin: Union[str, HandleBinding],
    type_hint: Any,
    expr_str: Optional[str],
) -> QBit

QNum

QNum(
    name: Union[str, HandleBinding],
    size: Union[int, CInt, Expression, None] = None,
    is_signed: Union[
        bool, Expression, SymbolicExpr, None
    ] = None,
    fraction_digits: Union[
        int, CInt, Expression, None
    ] = None,
    _expr_str: Optional[str] = None,
)

Bases: Generic[_P], QScalar

fraction_digits

fraction_digits: Union[CParamScalar, int]

is_signed

is_signed: Union[CParamScalar, bool]

get_qmod_type

get_qmod_type() -> QuantumType

to_qmod_quantum_type

to_qmod_quantum_type(type_hint: Any) -> QuantumType

to_qvar

to_qvar(
    origin: Union[str, HandleBinding],
    type_hint: Any,
    expr_str: Optional[str],
) -> QNum

QArray

QArray(
    name: Union[str, HandleBinding],
    element_type: Union[_GenericAlias, QuantumType] = QBit,
    length: Optional[
        Union[int, SymbolicExpr, Expression]
    ] = None,
    _expr_str: Optional[str] = None,
)

Bases: ArrayBase[_P], QVar

len

len: Union[CParamScalar, int]

get_qmod_type

get_qmod_type() -> QuantumBitvector

to_qmod_quantum_type

to_qmod_quantum_type(type_hint: Any) -> QuantumType

to_qvar

to_qvar(
    origin: Union[str, HandleBinding],
    type_hint: Any,
    expr_str: Optional[str],
) -> QArray

CInt

CInt(expr: str)

Bases: CParam

CReal

CReal(expr: str)

Bases: CParam

CBool

CBool(expr: str)

Bases: CParam

CArray

CArray(expr: str)

Bases: CParam, ArrayBase[_P]

len

len: int

QCallable

Bases: Generic[P], ABC

CURRENT_EXPANDABLE

CURRENT_EXPANDABLE: Optional[QExpandableInterface] = None

FRAME_DEPTH

FRAME_DEPTH = 1

func_decl

func_decl: AnonQuantumFunctionDeclaration

create_quantum_function_call

create_quantum_function_call(
    source_ref_: SourceReference, *args: Any, **kwargs: Any
) -> QuantumFunctionCall

QCallableList

Bases: QCallable, Generic[P], ABC

len

len: int

QStruct

QStruct(
    name: Union[str, HandleBinding],
    _struct_name: Optional[str] = None,
    _fields: Optional[Mapping[str, QVar]] = None,
    _expr_str: Optional[str] = None,
)

Bases: QVar

get_qmod_type

get_qmod_type() -> QuantumType

to_qmod_quantum_type

to_qmod_quantum_type(type_hint: Any) -> QuantumType

to_qvar

to_qvar(
    origin: Union[str, HandleBinding],
    type_hint: Any,
    expr_str: Optional[str],
) -> QStruct

QConstant

QConstant(name: str, py_type: type, value: Any)

Bases: SymbolicExpr

CURRENT_QMODULE

CURRENT_QMODULE: Optional[ModelStateContainer] = None

name

name = name

add_to_model

add_to_model() -> None

set_current_model

set_current_model(qmodule: ModelStateContainer) -> None

cfunc

cfunc

cfunc(
    func: Optional[Callable] = None,
) -> Union[Callable[[Callable], CFunc], CFunc]

get_caller_locals

get_caller_locals() -> Dict[str, Any]

Print the local variables in the caller's frame.

create_model

create_model(
    entry_point: Union[QFunc, GenerativeQFunc],
    constraints: Optional[Constraints] = None,
    execution_preferences: Optional[
        ExecutionPreferences
    ] = None,
    preferences: Optional[Preferences] = None,
    classical_execution_function: Optional[CFunc] = None,
    out_file: Optional[str] = None,
) -> SerializedModel

Create a serialized model from a given Qmod entry function and additional parameters.

Parameters:

Name Type Description Default
entry_point Union[QFunc, GenerativeQFunc]

The entry point function for the model, which must be a QFunc named 'main'.

required
constraints Optional[Constraints]

Constraints for the synthesis of the model. See Constraints (Optional).

None
execution_preferences Optional[ExecutionPreferences]

Preferences for the execution of the model. See ExecutionPreferences (Optional).

None
preferences Optional[Preferences]

Preferences for the synthesis of the model. See Preferences (Optional).

None
classical_execution_function Optional[CFunc]

A function for the classical execution logic, which must be a CFunc (Optional).

None
out_file Optional[str]

File path to write the Qmod model in native Qmod representation to (Optional).

None

Returns:

Name Type Description
SerializedModel SerializedModel

A serialized model.

Raises:

Type Description
ClassiqError

If the entry point function is not named 'main'.

symbolic

Catalan

Catalan = SymbolicExpr('Catalan', False)