Skip to content

Classical Types

This is a list of the classical types that are built-in in Qmod. For more information regarding classical types see: classical types.

structs

Classes:

Name Description
CombinatorialOptimizationSolution
GaussianModel
IndexedPauli

A single-qubit Pauli matrix on a specific qubit given by its index.

LogNormalModel
PauliTerm

A term in a Hamiltonian, represented as a product of single-qubit Pauli matrices.

QSVMFeatureMapPauli
QsvmResult
SparsePauliOp

Represents a collection of sparse Pauli operators.

SparsePauliTerm

A term in the Hamiltonian, represented as a sparse product of single-qubit Pauli

BUILTIN_STRUCT_DECLARATIONS

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

CombinatorialOptimizationSolution

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

Attributes:

Name Type Description
cost CReal
count CInt
probability CReal
solution CArray[CInt]

cost

cost: CReal

count

count: CInt

probability

probability: CReal

solution

solution: CArray[CInt]

GaussianModel

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

Attributes:

Name Type Description
default_probabilities CArray[CReal]
loss CArray[CInt]
min_loss CInt
normal_max_value CReal
num_qubits CInt
rhos CArray[CReal]

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]

IndexedPauli

IndexedPauli(pauli: Pauli, index: CInt)

A single-qubit Pauli matrix on a specific qubit given by its index.

Attributes:

Name Type Description
pauli Pauli

The Pauli operator.

index CInt

The index of the qubit being operated on.

index

index: CInt

pauli

pauli: Pauli

LogNormalModel

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

Attributes:

Name Type Description
mu CReal
num_qubits CInt
sigma CReal

mu

mu: CReal

num_qubits

num_qubits: CInt

sigma

sigma: CReal

PauliTerm

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

A term in a Hamiltonian, represented as a product of single-qubit Pauli matrices.

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]

QSVMFeatureMapPauli

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

Attributes:

Name Type Description
alpha CReal
entanglement CInt
feature_dimension CInt
paulis CArray[CArray[Pauli]]
reps CInt

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]
)

Attributes:

Name Type Description
predicted_labels CArray[CReal]
test_score CReal

predicted_labels

predicted_labels: CArray[CReal]

test_score

test_score: CReal

SparsePauliOp

SparsePauliOp(
    terms: list[SparsePauliTerm], num_qubits: int
)

Represents a collection of sparse Pauli operators.

Attributes:

Name Type Description
terms CArray[SparsePauliTerm]

The list of chosen sparse Pauli terms, corresponds to a product of them. (See: SparsePauliTerm)

num_qubits CInt

The number of qubits in the Hamiltonian.

num_qubits

num_qubits: int

terms

terms: list[SparsePauliTerm]

SparsePauliTerm

SparsePauliTerm(
    paulis: CArray[IndexedPauli], coefficient: CReal
)

A term in the Hamiltonian, represented as a sparse product of single-qubit Pauli matrices.

Attributes: paulis (CArray[IndexedPauli]): The list of chosen sparse Pauli operators in the term corresponds to a product of them. (See IndexedPauli) coefficient (CReal): The coefficient of the term (floating number).

Attributes:

Name Type Description
coefficient CReal
paulis CArray[IndexedPauli]

coefficient

coefficient: CReal

paulis

paulis: CArray[IndexedPauli]

constants

Attributes:

Name Type Description
SIGNED
UNSIGNED

SIGNED

SIGNED = QConstant('SIGNED', CBool, True)

UNSIGNED

UNSIGNED = QConstant('UNSIGNED', CBool, False)

enums

Classes:

Name Description
Optimizer
Pauli

Enumeration for the Pauli matrices used in quantum computing.

QSVMFeatureMapEntanglement

BUILTIN_ENUM_DECLARATIONS

BUILTIN_ENUM_DECLARATIONS = {
    (__name__): (
        EnumDeclaration(
            name=__name__,
            members={
                (name): (value) for 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
}

Optimizer

Bases: IntEnum

Attributes:

Name Type Description
ADAM
COBYLA
L_BFGS_B
NELDER_MEAD
SLSQP
SPSA

ADAM

ADAM = 5

COBYLA

COBYLA = 1

L_BFGS_B

L_BFGS_B = 3

NELDER_MEAD

NELDER_MEAD = 4

SLSQP

SLSQP = 6

SPSA

SPSA = 2

Pauli

Bases: IntEnum

Enumeration for the Pauli matrices used in quantum computing.

Represents the four Pauli matrices used in quantum mechanics: Identity (I), X, Y, and Z operators. The Pauli matrices are defined as:

\[ I = \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix} \]
\[ X = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix} \]
\[ Y = \begin{pmatrix} 0 & -i \\ i & 0 \end{pmatrix} \]
\[ Z = \begin{pmatrix} 1 & 0 \\ 0 & -1 \end{pmatrix} \]

Attributes:

Name Type Description
I int

The identity operator (value 0).

X int

The Pauli-X operator (value 1).

Y int

The Pauli-Y operator (value 2).

Z int

The Pauli-Z operator (value 3).

I

I = 0

X

X = 1

Y

Y = 2

Z

Z = 3

QSVMFeatureMapEntanglement

Bases: IntEnum

Attributes:

Name Type Description
CIRCULAR
FULL
LINEAR
PAIRWISE
SCA

CIRCULAR

CIRCULAR = 2

FULL

FULL = 0

LINEAR

LINEAR = 1

PAIRWISE

PAIRWISE = 4

SCA

SCA = 3