mimiqcircuits.operations.amplitude

Amplitude operation.

Classes

Amplitude(bs)

Record the amplitude of a computational basis state.

class Amplitude(bs)[source]

Bases: Operation

Record the amplitude of a computational basis state.

Amplitude(bs) reads the complex amplitude of the basis state bs in the current quantum state and stores it in a z-variable. It does not change the state. The instruction takes only the target z-variable.

Parameters:

bs (BitString) – The basis state whose amplitude is recorded.

See also

BitString, ExpectationValue

Examples

>>> from mimiqcircuits import *
>>> c = Circuit()
>>> # prepare a Bell state
>>> c.push(GateH(), 0)
1-qubit circuit with 1 instruction:
└── H @ q[0]

>>> c.push(GateCX(), 0, 1)
2-qubit circuit with 2 instructions:
├── H @ q[0]
└── CX @ q[0], q[1]

>>> # store the amplitude of |11> in z-variable 0
>>> c.push(Amplitude(BitString("11")), 0)
2-qubit, 1-zvar circuit with 3 instructions:
├── H @ q[0]
├── CX @ q[0], q[1]
└── Amplitude(bs"11") @ z[0]
property zregsizes

Size of each z-variable register, with one entry per register.

Empty or None when the operation has no z-variable register. Read-only: assigning to it raises ValueError.

iswrapper()[source]

Whether the operation wraps another operation.

True for composite operations such as Control, Power, Inverse, Parallel or IfStatement, False otherwise.

Returns:

bool

inverse()[source]

Not supported.

Raises:

NotImplementedError – Always.

static isunitary()[source]

Whether the operation acts unitarily on the quantum state.

Returns:

True for gates, annotations, Barrier, and the operations that only read the state into a z-variable, such as ExpectationValue or Amplitude. False for everything else: measurements, resets, noise channels, classical operations, and containers such as Block or IfStatement.

Return type:

bool