Skip to content

Analog

Operations

oqd_core.interface.analog.operation

AnalogCircuit

Bases: AnalogOperation

Class representing a quantum information experiment represented in terms of analog operations.

Attributes:

Name Type Description
sequence List[Union[Measure, Evolve, Initialize]]

Sequence of statements, including initialize, evolve, measure

Source code in oqd-core/src/oqd_core/interface/analog/operation.py
class AnalogCircuit(AnalogOperation):
    """
    Class representing a quantum information experiment represented in terms of analog operations.

    Attributes:
        sequence (List[Union[Measure, Evolve, Initialize]]): Sequence of statements, including initialize, evolve, measure

    """

    sequence: List[Statement] = []

    n_qreg: Union[NonNegativeInt, None] = None
    n_qmode: Union[NonNegativeInt, None] = None

    def evolve(self, gate: AnalogGate, duration: float):
        self.sequence.append(Evolve(duration=duration, gate=gate))

    def initialize(self):
        self.sequence.append(Initialize())

    def measure(self):
        self.sequence.append(Measure())

AnalogGate

Bases: TypeReflectBaseModel

Class representing an analog gate composed of Hamiltonian terms and dissipation terms

Attributes:

Name Type Description
hamiltonian Operator

Hamiltonian terms of the gate

Source code in oqd-core/src/oqd_core/interface/analog/operation.py
class AnalogGate(TypeReflectBaseModel):
    """
    Class representing an analog gate composed of Hamiltonian terms and dissipation terms

    Attributes:
        hamiltonian (Operator): Hamiltonian terms of the gate
    """

    hamiltonian: OperatorSubtypes

AnalogOperation

Bases: VisitableBaseModel

Class representing an analog operation applied to the quantum system

Source code in oqd-core/src/oqd_core/interface/analog/operation.py
class AnalogOperation(VisitableBaseModel):
    """
    Class representing an analog operation applied to the quantum system
    """

    pass

Evolve

Bases: AnalogOperation

Class representing an evolution by an analog gate in the analog circuit

Attributes:

Name Type Description
duration float

Duration of the evolution

gate AnalogGate

Analog gate to evolve by

Source code in oqd-core/src/oqd_core/interface/analog/operation.py
class Evolve(AnalogOperation):
    """
    Class representing an evolution by an analog gate in the analog circuit

    Attributes:
        duration (float): Duration of the evolution
        gate (AnalogGate): Analog gate to evolve by
    """

    key: Literal["evolve"] = "evolve"
    duration: float
    gate: Union[AnalogGate, str]

Measure

Bases: AnalogOperation

Class representing a measurement in the analog circuit

Source code in oqd-core/src/oqd_core/interface/analog/operation.py
class Measure(AnalogOperation):
    """
    Class representing a measurement in the analog circuit
    """

    key: Literal["measure"] = "measure"

Initialize

Bases: AnalogOperation

Class representing a initialization in the analog circuit

Source code in oqd-core/src/oqd_core/interface/analog/operation.py
class Initialize(AnalogOperation):
    """
    Class representing a initialization in the analog circuit
    """

    key: Literal["initialize"] = "initialize"

Operators

oqd_core.interface.analog.operator

OperatorSubtypes = Union[PauliI, PauliX, PauliY, PauliZ, Creation, Annihilation, Identity, OperatorAdd, OperatorSub, OperatorMul, OperatorScalarMul, OperatorKron] module-attribute

Alias for the union of concrete Operator subtypes

Operator

Bases: TypeReflectBaseModel

Class representing the abstract syntax tree (AST) for a quantum operator

Source code in oqd-core/src/oqd_core/interface/analog/operator.py
class Operator(TypeReflectBaseModel):
    """
    Class representing the abstract syntax tree (AST) for a quantum operator
    """

    def __neg__(self):
        return OperatorScalarMul(op=self, expr=MathNum(value=-1))

    def __pos__(self):
        return self

    def __add__(self, other):
        return OperatorAdd(op1=self, op2=other)

    def __sub__(self, other):
        return OperatorSub(op1=self, op2=other)

    def __matmul__(self, other):
        if isinstance(other, MathExpr):
            raise TypeError(
                "Tried Kron product between Operator and MathExpr. "
                + "Scalar multiplication of MathExpr and Operator should be bracketed when perfoming Kron product."
            )
        return OperatorKron(op1=self, op2=other)

    def __mul__(self, other):
        if isinstance(other, Operator):
            return OperatorMul(op1=self, op2=other)
        else:
            other = MathExpr.cast(other)
            return OperatorScalarMul(op=self, expr=other)

    def __rmul__(self, other):
        other = MathExpr.cast(other)
        return self * other

    pass

OperatorTerminal

Bases: Operator

Class representing a terminal in the Operator abstract syntax tree (AST)

Source code in oqd-core/src/oqd_core/interface/analog/operator.py
class OperatorTerminal(Operator):
    """
    Class representing a terminal in the [`Operator`][oqd_core.interface.analog.operator.Operator] abstract syntax tree (AST)
    """

    pass

Pauli

Bases: OperatorTerminal

Class representing a Pauli operator

Source code in oqd-core/src/oqd_core/interface/analog/operator.py
class Pauli(OperatorTerminal):
    """
    Class representing a Pauli operator
    """

    pass

PauliI

Bases: Pauli

Class for the Pauli I operator

Source code in oqd-core/src/oqd_core/interface/analog/operator.py
class PauliI(Pauli):
    """
    Class for the Pauli I operator
    """

    pass

PauliX

Bases: Pauli

Class for the Pauli X operator

Source code in oqd-core/src/oqd_core/interface/analog/operator.py
class PauliX(Pauli):
    """
    Class for the Pauli X operator
    """

    pass

PauliY

Bases: Pauli

Class for the Pauli Y operator

Source code in oqd-core/src/oqd_core/interface/analog/operator.py
class PauliY(Pauli):
    """
    Class for the Pauli Y operator
    """

    pass

PauliZ

Bases: Pauli

Class for the Pauli Z operator

Source code in oqd-core/src/oqd_core/interface/analog/operator.py
class PauliZ(Pauli):
    """
    Class for the Pauli Z operator
    """

    pass

Ladder

Bases: OperatorTerminal

Class representing a ladder operator in Fock space

Source code in oqd-core/src/oqd_core/interface/analog/operator.py
class Ladder(OperatorTerminal):
    """
    Class representing a ladder operator in Fock space
    """

    pass

Creation

Bases: Ladder

Class for the Creation operator in Fock space

Source code in oqd-core/src/oqd_core/interface/analog/operator.py
class Creation(Ladder):
    """
    Class for the Creation operator in Fock space
    """

    pass

Annihilation

Bases: Ladder

Class for the Annihilation operator in Fock space

Source code in oqd-core/src/oqd_core/interface/analog/operator.py
class Annihilation(Ladder):
    """
    Class for the Annihilation operator in Fock space
    """

    pass

Identity

Bases: Ladder

Class for the Identity operator in Fock space

Source code in oqd-core/src/oqd_core/interface/analog/operator.py
class Identity(Ladder):
    """
    Class for the Identity operator in Fock space
    """

    pass

OperatorBinaryOp

Bases: Operator

Class representing binary operations on Operators

Source code in oqd-core/src/oqd_core/interface/analog/operator.py
class OperatorBinaryOp(Operator):
    """
    Class representing binary operations on [`Operators`][oqd_core.interface.analog.operator.Operator]
    """

    pass

OperatorAdd

Bases: OperatorBinaryOp

Class representing the addition of Operators

Attributes:

Name Type Description
op1 Operator

Left hand side Operator

op2 Operator

Right hand side Operator

Source code in oqd-core/src/oqd_core/interface/analog/operator.py
class OperatorAdd(OperatorBinaryOp):
    """
    Class representing the addition of [`Operators`][oqd_core.interface.analog.operator.Operator]

    Attributes:
        op1 (Operator): Left hand side [`Operator`][oqd_core.interface.analog.operator.Operator]
        op2 (Operator): Right hand side [`Operator`][oqd_core.interface.analog.operator.Operator]
    """

    op1: OperatorSubtypes
    op2: OperatorSubtypes

OperatorSub

Bases: OperatorBinaryOp

Class representing the subtraction of Operators

Attributes:

Name Type Description
op1 Operator

Left hand side Operator

op2 Operator

Right hand side Operator

Source code in oqd-core/src/oqd_core/interface/analog/operator.py
class OperatorSub(OperatorBinaryOp):
    """
    Class representing the subtraction of [`Operators`][oqd_core.interface.analog.operator.Operator]

    Attributes:
        op1 (Operator): Left hand side [`Operator`][oqd_core.interface.analog.operator.Operator]
        op2 (Operator): Right hand side [`Operator`][oqd_core.interface.analog.operator.Operator]
    """

    op1: OperatorSubtypes
    op2: OperatorSubtypes

OperatorMul

Bases: OperatorBinaryOp

Class representing the multiplication of Operators

Attributes:

Name Type Description
op1 Operator

Left hand side Operator

op2 Operator

Right hand side Operator

Source code in oqd-core/src/oqd_core/interface/analog/operator.py
class OperatorMul(OperatorBinaryOp):
    """
    Class representing the multiplication of [`Operators`][oqd_core.interface.analog.operator.Operator]

    Attributes:
        op1 (Operator): Left hand side [`Operator`][oqd_core.interface.analog.operator.Operator]
        op2 (Operator): Right hand side [`Operator`][oqd_core.interface.analog.operator.Operator]
    """

    op1: OperatorSubtypes
    op2: OperatorSubtypes

OperatorScalarMul

Bases: Operator

Class representing scalar multiplication of an Operator and a MathExpr

Attributes:

Name Type Description
op Operator

Operator to multiply

expr MathExpr

MathExpr to multiply by

Source code in oqd-core/src/oqd_core/interface/analog/operator.py
class OperatorScalarMul(Operator):
    """
    Class representing scalar multiplication of an [`Operator`][oqd_core.interface.analog.operator.Operator] and a
    [`MathExpr`][oqd_core.interface.math.MathExpr]

    Attributes:
        op (Operator): [`Operator`][oqd_core.interface.analog.operator.Operator] to multiply
        expr (MathExpr): [`MathExpr`][oqd_core.interface.math.MathExpr] to multiply by
    """

    op: OperatorSubtypes
    expr: MathExprSubtypes

OperatorKron

Bases: OperatorBinaryOp

Class representing the tensor product of Operators

Attributes:

Name Type Description
op1 Operator

Left hand side Operator

op2 Operator

Right hand side Operator

Source code in oqd-core/src/oqd_core/interface/analog/operator.py
class OperatorKron(OperatorBinaryOp):
    """
    Class representing the tensor product of [`Operators`][oqd_core.interface.analog.operator.Operator]

    Attributes:
        op1 (Operator): Left hand side [`Operator`][oqd_core.interface.analog.operator.Operator]
        op2 (Operator): Right hand side [`Operator`][oqd_core.interface.analog.operator.Operator]
    """

    op1: OperatorSubtypes
    op2: OperatorSubtypes

PauliPlus()

Function that constructs the Pauli + operator

Source code in oqd-core/src/oqd_core/interface/analog/operator.py
def PauliPlus():
    """
    Function that constructs the Pauli + operator
    """
    return OperatorAdd(
        op1=PauliX(),
        op2=OperatorScalarMul(
            op=PauliY(), expr=MathMul(expr1=MathImag(), expr2=MathNum(value=1))
        ),
    )

PauliMinus()

Function that constructs the Pauli - operator

Source code in oqd-core/src/oqd_core/interface/analog/operator.py
def PauliMinus():
    """
    Function that constructs the Pauli - operator
    """
    return OperatorAdd(
        op1=PauliX(),
        op2=OperatorScalarMul(
            op=PauliY(), expr=MathMul(expr1=MathImag(), expr2=MathNum(value=-1))
        ),
    )