scaluq

Classes

CXGate

Specific class of single-qubit-controlled Pauli-X gate.

CZGate

Specific class of single-qubit-controlled Pauli-Z gate.

Circuit

Quantum circuit represented as gate array

FusedSwapGate

Specific class of fused swap gate, which swap qubits in $[mathrm{qubit_index1},mathrm{qubit_index1}+mathrm{block_size})$ and qubits in $[mathrm{qubit_index2},mathrm{qubit_index2}+mathrm{block_size})$.

Gate

General class of QuantumGate.

GateType

<attribute '__doc__' of 'GateType' objects>

GlobalPhaseGate

Specific class of gate, which rotate global phase, represented as $e^{imathrm{phase}}I$.

HGate

Specific class of Hadamard gate.

IGate

Specific class of Pauli-I gate.

InitializationSettings

Wrapper class of Kokkos's InitializationSettings.

OneQubitMatrixGate

Specific class of single-qubit dense matrix gate.

Operator

None

P0Gate

Specific class of projection gate to $ket{0}$.

P1Gate

Specific class of projection gate to $ket{1}$.

PPauliRotationGate

Specific class of parametric multi-qubit pauli-rotation gate, represented as $e^{-ifrac{mathrm{angle}}{2}P}$. angle is given as param * pcoef.

PRXGate

Specific class of parametric X rotation gate, represented as $e^{-ifrac{mathrm{angle}}{2}X}$. angle is given as param * pcoef.

PRYGate

Specific class of parametric Y rotation gate, represented as $e^{-ifrac{mathrm{angle}}{2}Y}$. angle is given as param * pcoef.

PRZGate

Specific class of parametric Z rotation gate, represented as $e^{-ifrac{mathrm{angle}}{2}Z}$. angle is given as param * pcoef.

ParamGate

General class of parametric quantum gate.

ParamGateType

<attribute '__doc__' of 'ParamGateType' objects>

PauliGate

Specific class of multi-qubit pauli gate, which applies single-qubit Pauli gate to each of qubit.

PauliOperator

Pauli operator as coef and tensor product of single pauli for each qubit.

PauliRotationGate

Specific class of multi-qubit pauli-rotation gate, represented as $e^{-ifrac{mathrm{angle}}{2}P}$.

RXGate

Specific class of X rotation gate, represented as $e^{-ifrac{mathrm{angle}}{2}X}$.

RYGate

Specific class of Y rotation gate, represented as $e^{-ifrac{mathrm{angle}}{2}Y}$.

RZGate

Specific class of Z rotation gate, represented as $e^{-ifrac{mathrm{angle}}{2}Z}$.

SGate

Specific class of S gate, represented as $begin{bmatrix}

SdagGate

Specific class of inverse of S gate.

SqrtXGate

Specific class of sqrt(X) gate, represented as $begin{bmatrix}

SqrtXdagGate

Specific class of inverse of sqrt(X) gate.

SqrtYGate

Specific class of sqrt(Y) gate, represented as $begin{bmatrix}

SqrtYdagGate

Specific class of inverse of sqrt(Y) gate.

StateVector

Vector representation of quantum state.

SwapGate

Specific class of two-qubit swap gate.

TGate

Specific class of T gate, represented as $begin{bmatrix}

TdagGate

Specific class of inverse of T gate.

TwoQubitMatrixGate

Specific class of double-qubit dense matrix gate.

U1Gate

Specific class of IBMQ's U1 Gate, which is a rotation abount Z-axis, represented as $begin{bmatrix}

U2Gate

Specific class of IBMQ's U2 Gate, which is a rotation about X+Z-axis, represented as $frac{1}{sqrt{2}} begin{bmatrix}1 & -e^{-ilambda}\

U3Gate

Specific class of IBMQ's U3 Gate, which is a rotation abount 3 axis, represented as $begin{bmatrix}

XGate

Specific class of Pauli-X gate.

YGate

Specific class of Pauli-Y gate.

ZGate

Specific class of Pauli-Z gate.

Functions

CNot(→ Gate)

Generate general Gate class instance of CX.

CX(→ Gate)

Generate general Gate class instance of CX.

CZ(→ Gate)

Generate general Gate class instance of CZ.

FusedSwap(→ Gate)

Generate general Gate class instance of FusedSwap.

GlobalPhase(→ Gate)

Generate general Gate class instance of GlobalPhase.

H(→ Gate)

Generate general Gate class instance of H.

I(→ Gate)

Generate general Gate class instance of I.

P0(→ Gate)

Generate general Gate class instance of P0.

P1(→ Gate)

Generate general Gate class instance of P1.

PPauliRotation(→ ParamGate)

Generate general ParamGate class instance of PPauliRotation.

PRX(→ ParamGate)

Generate general ParamGate class instance of PRX.

PRY(→ ParamGate)

Generate general ParamGate class instance of PRY.

PRZ(→ ParamGate)

Generate general ParamGate class instance of PRZ.

Pauli(→ Gate)

Generate general Gate class instance of Pauli.

PauliRotation(→ Gate)

Generate general Gate class instance of PauliRotation.

RX(→ Gate)

Generate general Gate class instance of RX.

RY(→ Gate)

Generate general Gate class instance of RY.

RZ(→ Gate)

Generate general Gate class instance of RZ.

S(→ Gate)

Generate general Gate class instance of S.

Sdag(→ Gate)

Generate general Gate class instance of Sdag.

SqrtX(→ Gate)

Generate general Gate class instance of SqrtX.

SqrtXdag(→ Gate)

Generate general Gate class instance of SqrtXdag.

SqrtY(→ Gate)

Generate general Gate class instance of SqrtY.

SqrtYdag(→ Gate)

Generate general Gate class instance of SqrtYdag.

Swap(→ Gate)

Generate general Gate class instance of Swap.

T(→ Gate)

Generate general Gate class instance of T.

Tdag(→ Gate)

Generate general Gate class instance of Tdag.

U1(→ Gate)

Generate general Gate class instance of U1.

U2(→ Gate)

Generate general Gate class instance of U2.

U3(→ Gate)

Generate general Gate class instance of U3.

X(→ Gate)

Generate general Gate class instance of X.

Y(→ Gate)

Generate general Gate class instance of Y.

Z(→ Gate)

Generate general Gate class instance of Z.

finalize(→ None)

Terminate the Kokkos execution environment. Release the resources.

initialize(→ None)

You must call this before any scaluq function. Initialize the Kokkos execution environment.

is_finalized(→ bool)

Return true if finalize() is already called.

is_initialized(→ bool)

Return true if initialize() is already called.

Module Contents

scaluq.CNot(arg0: int, arg1: int, /) Gate

Generate general Gate class instance of CX. [note] CNot is an alias of CX.

scaluq.CX(arg0: int, arg1: int, /) Gate

Generate general Gate class instance of CX.

class scaluq.CXGate(arg: Gate, /)

Specific class of single-qubit-controlled Pauli-X gate.

Note

Upcast is required to use gate-general functions (ex: add to Circuit).

control() int

Get property control.

copy() Gate

Copy gate as Gate type.

gate_type() GateType

Get gate type as GateType enum.

get_control_qubit_list() list[int]

Get control qubits as list[int].

get_inverse() Gate

Generate inverse gate as Gate type. If not exists, return None.

get_matrix() numpy.typing.NDArray | None

Get matrix representation of the gate. If cannot, None is returned.

get_target_qubit_list() list[int]

Get target qubits as list[int]. Control qubits is not included.

target() int

Get property target.

update_quantum_state(arg: StateVector, /) None

Apply gate to state_vector. state_vector in args is directly updated.

scaluq.CZ(arg0: int, arg1: int, /) Gate

Generate general Gate class instance of CZ.

class scaluq.CZGate(arg: Gate, /)

Specific class of single-qubit-controlled Pauli-Z gate.

Note

Upcast is required to use gate-general functions (ex: add to Circuit).

control() int

Get property control.

copy() Gate

Copy gate as Gate type.

gate_type() GateType

Get gate type as GateType enum.

get_control_qubit_list() list[int]

Get control qubits as list[int].

get_inverse() Gate

Generate inverse gate as Gate type. If not exists, return None.

get_matrix() numpy.typing.NDArray | None

Get matrix representation of the gate. If cannot, None is returned.

get_target_qubit_list() list[int]

Get target qubits as list[int]. Control qubits is not included.

target() int

Get property target.

update_quantum_state(arg: StateVector, /) None

Apply gate to state_vector. state_vector in args is directly updated.

class scaluq.Circuit(arg: int, /)

Quantum circuit represented as gate array

add_circuit(arg: Circuit, /) None

Add all gates in specified circuit. Given gates are copied.

add_gate(arg: Gate, /) None

Add gate. Given gate is copied.

add_param_gate(arg0: ParamGate, arg1: str, /) None

Add parametric gate with specifing key. Given param_gate is copied.

calculate_depth() int

Get depth of circuit.

copy() Circuit

Copy circuit. All the gates inside is copied.

gate_count() int

Get property of gate_count.

gate_list() list[Gate | tuple[ParamGate, str]]

Get property of gate_list.

get(arg: int, /) Gate | tuple[ParamGate, str]

Get reference of i-th gate.

get_inverse() Circuit

Get inverse of circuit. ALl the gates are newly created.

get_key(arg: int, /) str | None

Get parameter key of i-th gate. If it is not parametric, return None.

key_set() set[str]

Get set of keys of parameters.

n_qubits() int

Get property of n_qubits.

update_quantum_state(arg0: StateVector, /, **kwargs) None

Apply gate to the StateVector. StateVector in args is directly updated. If the circuit contains parametric gate, you have to give real value of parameter as “name=value” format in kwargs.

update_quantum_state(arg0: StateVector, arg1: dict[str, float], /) None

Apply gate to the StateVector. StateVector in args is directly updated. If the circuit contains parametric gate, you have to give real value of parameter as dict[str, float] in 2nd arg.

scaluq.FusedSwap(arg0: int, arg1: int, arg2: int, /) Gate

Generate general Gate class instance of FusedSwap.

class scaluq.FusedSwapGate(arg: Gate, /)

Specific class of fused swap gate, which swap qubits in \([\mathrm{qubit\_index1},\mathrm{qubit\_index1}+\mathrm{block\_size})\) and qubits in \([\mathrm{qubit\_index2},\mathrm{qubit\_index2}+\mathrm{block\_size})\).

Note

Upcast is required to use gate-general functions (ex: add to Circuit).

block_size() int

Get property block_size.

copy() Gate

Copy gate as Gate type.

gate_type() GateType

Get gate type as GateType enum.

get_control_qubit_list() list[int]

Get control qubits as list[int].

get_inverse() Gate

Generate inverse gate as Gate type. If not exists, return None.

get_matrix() numpy.typing.NDArray | None

Get matrix representation of the gate. If cannot, None is returned.

get_target_qubit_list() list[int]

Get target qubits as list[int]. Control qubits is not included.

qubit_index1() int

Get property qubit_index1.

qubit_index2() int

Get property qubit_index2.

update_quantum_state(arg: StateVector, /) None

Apply gate to state_vector. state_vector in args is directly updated.

class scaluq.Gate(arg: PauliRotationGate, /)

General class of QuantumGate.

Note

Downcast to requred to use gate-specific functions.

copy() Gate

Copy gate as Gate type.

gate_type() GateType

Get gate type as GateType enum.

get_control_qubit_list() list[int]

Get control qubits as list[int].

get_inverse() Gate

Generate inverse gate as Gate type. If not exists, return None.

get_matrix() numpy.typing.NDArray | None

Get matrix representation of the gate. If cannot, None is returned.

get_target_qubit_list() list[int]

Get target qubits as list[int]. Control qubits is not included.

update_quantum_state(arg: StateVector, /) None

Apply gate to state_vector. state_vector in args is directly updated.

class scaluq.GateType(*args, **kwds)

Bases: enum.Enum

<attribute ‘__doc__’ of ‘GateType’ objects>

CX: Any
CZ: Any
FusedSwap: Any
GlobalPhase: Any
H: Any
I: Any
OneQubitMatrix: Any
P0: Any
P1: Any
Pauli: Any
PauliRotation: Any
RX: Any
RY: Any
RZ: Any
S: Any
Sdag: Any
SqrtX: Any
SqrtXdag: Any
SqrtY: Any
SqrtYdag: Any
Swap: Any
T: Any
Tdag: Any
TwoQubitMatrix: Any
U1: Any
U2: Any
U3: Any
X: Any
Y: Any
Z: Any
scaluq.GlobalPhase(arg: float, /) Gate

Generate general Gate class instance of GlobalPhase.

class scaluq.GlobalPhaseGate(arg: Gate, /)

Specific class of gate, which rotate global phase, represented as \(e^{i\mathrm{phase}}I\).

Note

Upcast is required to use gate-general functions (ex: add to Circuit).

copy() Gate

Copy gate as Gate type.

gate_type() GateType

Get gate type as GateType enum.

get_control_qubit_list() list[int]

Get control qubits as list[int].

get_inverse() Gate

Generate inverse gate as Gate type. If not exists, return None.

get_matrix() numpy.typing.NDArray | None

Get matrix representation of the gate. If cannot, None is returned.

get_target_qubit_list() list[int]

Get target qubits as list[int]. Control qubits is not included.

phase() float

Get phase property

update_quantum_state(arg: StateVector, /) None

Apply gate to state_vector. state_vector in args is directly updated.

scaluq.H(arg: int, /) Gate

Generate general Gate class instance of H.

class scaluq.HGate(arg: Gate, /)

Specific class of Hadamard gate.

Note

Upcast is required to use gate-general functions (ex: add to Circuit).

copy() Gate

Copy gate as Gate type.

gate_type() GateType

Get gate type as GateType enum.

get_control_qubit_list() list[int]

Get control qubits as list[int].

get_inverse() Gate

Generate inverse gate as Gate type. If not exists, return None.

get_matrix() numpy.typing.NDArray | None

Get matrix representation of the gate. If cannot, None is returned.

get_target_qubit_list() list[int]

Get target qubits as list[int]. Control qubits is not included.

target() int
update_quantum_state(arg: StateVector, /) None

Apply gate to state_vector. state_vector in args is directly updated.

scaluq.I() Gate

Generate general Gate class instance of I.

class scaluq.IGate(arg: Gate, /)

Specific class of Pauli-I gate.

Note

Upcast is required to use gate-general functions (ex: add to Circuit).

copy() Gate

Copy gate as Gate type.

gate_type() GateType

Get gate type as GateType enum.

get_control_qubit_list() list[int]

Get control qubits as list[int].

get_inverse() Gate

Generate inverse gate as Gate type. If not exists, return None.

get_matrix() numpy.typing.NDArray | None

Get matrix representation of the gate. If cannot, None is returned.

get_target_qubit_list() list[int]

Get target qubits as list[int]. Control qubits is not included.

update_quantum_state(arg: StateVector, /) None

Apply gate to state_vector. state_vector in args is directly updated.

class scaluq.InitializationSettings

Wrapper class of Kokkos’s InitializationSettings.

get_device_id() int
get_disable_warnings() bool
get_map_device_id_by() str
get_num_threads() int
get_print_configuration() bool
get_tools_args() str
get_tools_help() bool
get_tools_libs() str
get_tune_internals() bool
has_device_id() bool
has_disable_warnings() bool
has_map_device_id_by() bool
has_num_threads() bool
has_print_configuration() bool
has_tools_args() bool
has_tools_help() bool
has_tools_libs() bool
has_tune_internals() bool
set_device_id(arg: int, /) InitializationSettings
set_disable_warnings(arg: bool, /) InitializationSettings
set_map_device_id_by(arg: str, /) InitializationSettings
set_num_threads(arg: int, /) InitializationSettings
set_print_configuration(arg: bool, /) InitializationSettings
set_tools_args(arg: str, /) InitializationSettings
set_tools_help(arg: bool, /) InitializationSettings
set_tools_libs(arg: str, /) InitializationSettings
set_tune_internals(arg: bool, /) InitializationSettings
class scaluq.OneQubitMatrixGate(arg: Gate, /)

Specific class of single-qubit dense matrix gate.

Note

Upcast is required to use gate-general functions (ex: add to Circuit).

copy() Gate

Copy gate as Gate type.

gate_type() GateType

Get gate type as GateType enum.

get_control_qubit_list() list[int]

Get control qubits as list[int].

get_inverse() Gate

Generate inverse gate as Gate type. If not exists, return None.

get_matrix() numpy.typing.NDArray | None

Get matrix representation of the gate. If cannot, None is returned.

get_target_qubit_list() list[int]

Get target qubits as list[int]. Control qubits is not included.

matrix() list[list[complex]]
update_quantum_state(arg: StateVector, /) None

Apply gate to state_vector. state_vector in args is directly updated.

class scaluq.Operator(arg: int, /)

None

add_operator(arg: PauliOperator, /) None
add_random_operator(operator_count: int, seed: int | None = None) None
apply_to_state(arg: StateVector, /) None
get_dagger() Operator
get_expectation_value(arg: StateVector, /) complex
get_transition_amplitude(arg0: StateVector, arg1: StateVector, /) complex
is_hermitian() bool
n_qubits() int
optimize() None
terms() list[PauliOperator]
to_string() str
scaluq.P0(arg: int, /) Gate

Generate general Gate class instance of P0.

class scaluq.P0Gate(arg: Gate, /)

Specific class of projection gate to \(\ket{0}\).

Note

This gate is not unitary.

Note

Upcast is required to use gate-general functions (ex: add to Circuit).

copy() Gate

Copy gate as Gate type.

gate_type() GateType

Get gate type as GateType enum.

get_control_qubit_list() list[int]

Get control qubits as list[int].

get_inverse() Gate

Generate inverse gate as Gate type. If not exists, return None.

get_matrix() numpy.typing.NDArray | None

Get matrix representation of the gate. If cannot, None is returned.

get_target_qubit_list() list[int]

Get target qubits as list[int]. Control qubits is not included.

target() int
update_quantum_state(arg: StateVector, /) None

Apply gate to state_vector. state_vector in args is directly updated.

scaluq.P1(arg: int, /) Gate

Generate general Gate class instance of P1.

class scaluq.P1Gate(arg: Gate, /)

Specific class of projection gate to \(\ket{1}\).

Note

This gate is not unitary.

Note

Upcast is required to use gate-general functions (ex: add to Circuit).

copy() Gate

Copy gate as Gate type.

gate_type() GateType

Get gate type as GateType enum.

get_control_qubit_list() list[int]

Get control qubits as list[int].

get_inverse() Gate

Generate inverse gate as Gate type. If not exists, return None.

get_matrix() numpy.typing.NDArray | None

Get matrix representation of the gate. If cannot, None is returned.

get_target_qubit_list() list[int]

Get target qubits as list[int]. Control qubits is not included.

target() int
update_quantum_state(arg: StateVector, /) None

Apply gate to state_vector. state_vector in args is directly updated.

scaluq.PPauliRotation(pauli: PauliOperator, coef: float = 1.0) ParamGate

Generate general ParamGate class instance of PPauliRotation.

class scaluq.PPauliRotationGate(arg: ParamGate, /)

Specific class of parametric multi-qubit pauli-rotation gate, represented as \(e^{-i\frac{\mathrm{angle}}{2}P}\). angle is given as param * pcoef.

Note

Upcast is required to use gate-general functions (ex: add to Circuit).

copy() ParamGate

Copy gate as ParamGate type.

get_control_qubit_list() list[int]

Get control qubits as list[int].

get_inverse() ParamGate

Generate inverse parametric-gate as ParamGate type. If not exists, return None.

get_matrix(arg: float, /) numpy.typing.NDArray | None

Get matrix representation of the gate with holding the parameter. If cannot, None is returned.

get_target_qubit_list() list[int]

Get target qubits as list[int]. Control qubits is not included.

param_gate_type() ParamGateType

Get parametric gate type as ParamGateType enum.

update_quantum_state(arg0: StateVector, arg1: float, /) None

Apply gate to state_vector with holding the parameter. state_vector in args is directly updated.

scaluq.PRX(target: int, coef: float = 1.0) ParamGate

Generate general ParamGate class instance of PRX.

class scaluq.PRXGate(arg: ParamGate, /)

Specific class of parametric X rotation gate, represented as \(e^{-i\frac{\mathrm{angle}}{2}X}\). angle is given as param * pcoef.

Note

Upcast is required to use gate-general functions (ex: add to Circuit).

copy() ParamGate

Copy gate as ParamGate type.

get_control_qubit_list() list[int]

Get control qubits as list[int].

get_inverse() ParamGate

Generate inverse parametric-gate as ParamGate type. If not exists, return None.

get_matrix(arg: float, /) numpy.typing.NDArray | None

Get matrix representation of the gate with holding the parameter. If cannot, None is returned.

get_target_qubit_list() list[int]

Get target qubits as list[int]. Control qubits is not included.

param_gate_type() ParamGateType

Get parametric gate type as ParamGateType enum.

target() int
update_quantum_state(arg0: StateVector, arg1: float, /) None

Apply gate to state_vector with holding the parameter. state_vector in args is directly updated.

scaluq.PRY(target: int, coef: float = 1.0) ParamGate

Generate general ParamGate class instance of PRY.

class scaluq.PRYGate(arg: ParamGate, /)

Specific class of parametric Y rotation gate, represented as \(e^{-i\frac{\mathrm{angle}}{2}Y}\). angle is given as param * pcoef.

Note

Upcast is required to use gate-general functions (ex: add to Circuit).

copy() ParamGate

Copy gate as ParamGate type.

get_control_qubit_list() list[int]

Get control qubits as list[int].

get_inverse() ParamGate

Generate inverse parametric-gate as ParamGate type. If not exists, return None.

get_matrix(arg: float, /) numpy.typing.NDArray | None

Get matrix representation of the gate with holding the parameter. If cannot, None is returned.

get_target_qubit_list() list[int]

Get target qubits as list[int]. Control qubits is not included.

param_gate_type() ParamGateType

Get parametric gate type as ParamGateType enum.

target() int
update_quantum_state(arg0: StateVector, arg1: float, /) None

Apply gate to state_vector with holding the parameter. state_vector in args is directly updated.

scaluq.PRZ(target: int, coef: float = 1.0) ParamGate

Generate general ParamGate class instance of PRZ.

class scaluq.PRZGate(arg: ParamGate, /)

Specific class of parametric Z rotation gate, represented as \(e^{-i\frac{\mathrm{angle}}{2}Z}\). angle is given as param * pcoef.

Note

Upcast is required to use gate-general functions (ex: add to Circuit).

copy() ParamGate

Copy gate as ParamGate type.

get_control_qubit_list() list[int]

Get control qubits as list[int].

get_inverse() ParamGate

Generate inverse parametric-gate as ParamGate type. If not exists, return None.

get_matrix(arg: float, /) numpy.typing.NDArray | None

Get matrix representation of the gate with holding the parameter. If cannot, None is returned.

get_target_qubit_list() list[int]

Get target qubits as list[int]. Control qubits is not included.

param_gate_type() ParamGateType

Get parametric gate type as ParamGateType enum.

target() int
update_quantum_state(arg0: StateVector, arg1: float, /) None

Apply gate to state_vector with holding the parameter. state_vector in args is directly updated.

class scaluq.ParamGate(arg: PPauliRotationGate, /)

General class of parametric quantum gate.

Note

Downcast to requred to use gate-specific functions.

copy() ParamGate

Copy gate as ParamGate type.

get_control_qubit_list() list[int]

Get control qubits as list[int].

get_inverse() ParamGate

Generate inverse parametric-gate as ParamGate type. If not exists, return None.

get_matrix(arg: float, /) numpy.typing.NDArray | None

Get matrix representation of the gate with holding the parameter. If cannot, None is returned.

get_target_qubit_list() list[int]

Get target qubits as list[int]. Control qubits is not included.

param_gate_type() ParamGateType

Get parametric gate type as ParamGateType enum.

update_quantum_state(arg0: StateVector, arg1: float, /) None

Apply gate to state_vector with holding the parameter. state_vector in args is directly updated.

class scaluq.ParamGateType(*args, **kwds)

Bases: enum.Enum

<attribute ‘__doc__’ of ‘ParamGateType’ objects>

PPauliRotation: Any
PRX: Any
PRY: Any
PRZ: Any
scaluq.Pauli(arg: PauliOperator, /) Gate

Generate general Gate class instance of Pauli.

class scaluq.PauliGate(arg: Gate, /)

Specific class of multi-qubit pauli gate, which applies single-qubit Pauli gate to each of qubit.

Note

Upcast is required to use gate-general functions (ex: add to Circuit).

copy() Gate

Copy gate as Gate type.

gate_type() GateType

Get gate type as GateType enum.

get_control_qubit_list() list[int]

Get control qubits as list[int].

get_inverse() Gate

Generate inverse gate as Gate type. If not exists, return None.

get_matrix() numpy.typing.NDArray | None

Get matrix representation of the gate. If cannot, None is returned.

get_target_qubit_list() list[int]

Get target qubits as list[int]. Control qubits is not included.

update_quantum_state(arg: StateVector, /) None

Apply gate to state_vector. state_vector in args is directly updated.

class scaluq.PauliOperator(bit_flip_mask: int, phase_flip_mask: int, coef: complex = 1.0)

Pauli operator as coef and tensor product of single pauli for each qubit.

I: int
X: int
Y: int
Z: int
add_single_pauli(arg0: int, arg1: int, /) None

Add (apply tensor product) another single pauli. You cannot specify qubit index that has always a single pauli.

apply_to_state(arg: StateVector, /) None

Apply pauli to state vector.

change_coef(arg: complex, /) None

Set property coef.

get_XZ_mask_representation() tuple[int, int]

Get single-pauli property as binary integer representation. See description of __init__(bit_flip_mask_py: int, phase_flip_mask_py: int, coef: float=1.) for details.

get_coef() complex

Get property coef.

get_dagger() PauliOperator

Get adjoint operator.

get_expectation_value(arg: StateVector, /) complex

Get expectation value of measuring state vector. \(\bra{\psi}P\ket{\psi}\).

get_pauli_id_list() list[int]

Get pauli id to be applied. The order is correspond to the result of get_target_qubit_list

get_pauli_string() str

Get single-pauli property as string representation. See description of __init__(pauli_string: str, coef: float=1.) for details.

get_qubit_count() int

Get num of qubits to applied with, when count from 0-th qubit. Subset of \([0, \mathrm{qubit_count})\) is the target.

get_target_qubit_list() list[int]

Get qubits to be applied pauli.

get_transition_amplitude(arg0: StateVector, arg1: StateVector, /) complex

Get transition amplitude of measuring state vector. \(\bra{\chi}P\ket{\psi}\).

scaluq.PauliRotation(arg0: PauliOperator, arg1: float, /) Gate

Generate general Gate class instance of PauliRotation.

class scaluq.PauliRotationGate(arg: Gate, /)

Specific class of multi-qubit pauli-rotation gate, represented as \(e^{-i\frac{\mathrm{angle}}{2}P}\).

Note

Upcast is required to use gate-general functions (ex: add to Circuit).

copy() Gate

Copy gate as Gate type.

gate_type() GateType

Get gate type as GateType enum.

get_control_qubit_list() list[int]

Get control qubits as list[int].

get_inverse() Gate

Generate inverse gate as Gate type. If not exists, return None.

get_matrix() numpy.typing.NDArray | None

Get matrix representation of the gate. If cannot, None is returned.

get_target_qubit_list() list[int]

Get target qubits as list[int]. Control qubits is not included.

update_quantum_state(arg: StateVector, /) None

Apply gate to state_vector. state_vector in args is directly updated.

scaluq.RX(arg0: int, arg1: float, /) Gate

Generate general Gate class instance of RX.

class scaluq.RXGate(arg: Gate, /)

Specific class of X rotation gate, represented as \(e^{-i\frac{\mathrm{angle}}{2}X}\).

Note

Upcast is required to use gate-general functions (ex: add to Circuit).

angle() float

Get angle property.

copy() Gate

Copy gate as Gate type.

gate_type() GateType

Get gate type as GateType enum.

get_control_qubit_list() list[int]

Get control qubits as list[int].

get_inverse() Gate

Generate inverse gate as Gate type. If not exists, return None.

get_matrix() numpy.typing.NDArray | None

Get matrix representation of the gate. If cannot, None is returned.

get_target_qubit_list() list[int]

Get target qubits as list[int]. Control qubits is not included.

target() int
update_quantum_state(arg: StateVector, /) None

Apply gate to state_vector. state_vector in args is directly updated.

scaluq.RY(arg0: int, arg1: float, /) Gate

Generate general Gate class instance of RY.

class scaluq.RYGate(arg: Gate, /)

Specific class of Y rotation gate, represented as \(e^{-i\frac{\mathrm{angle}}{2}Y}\).

Note

Upcast is required to use gate-general functions (ex: add to Circuit).

angle() float

Get angle property.

copy() Gate

Copy gate as Gate type.

gate_type() GateType

Get gate type as GateType enum.

get_control_qubit_list() list[int]

Get control qubits as list[int].

get_inverse() Gate

Generate inverse gate as Gate type. If not exists, return None.

get_matrix() numpy.typing.NDArray | None

Get matrix representation of the gate. If cannot, None is returned.

get_target_qubit_list() list[int]

Get target qubits as list[int]. Control qubits is not included.

target() int
update_quantum_state(arg: StateVector, /) None

Apply gate to state_vector. state_vector in args is directly updated.

scaluq.RZ(arg0: int, arg1: float, /) Gate

Generate general Gate class instance of RZ.

class scaluq.RZGate(arg: Gate, /)

Specific class of Z rotation gate, represented as \(e^{-i\frac{\mathrm{angle}}{2}Z}\).

Note

Upcast is required to use gate-general functions (ex: add to Circuit).

angle() float

Get angle property.

copy() Gate

Copy gate as Gate type.

gate_type() GateType

Get gate type as GateType enum.

get_control_qubit_list() list[int]

Get control qubits as list[int].

get_inverse() Gate

Generate inverse gate as Gate type. If not exists, return None.

get_matrix() numpy.typing.NDArray | None

Get matrix representation of the gate. If cannot, None is returned.

get_target_qubit_list() list[int]

Get target qubits as list[int]. Control qubits is not included.

target() int
update_quantum_state(arg: StateVector, /) None

Apply gate to state_vector. state_vector in args is directly updated.

scaluq.S(arg: int, /) Gate

Generate general Gate class instance of S.

class scaluq.SGate(arg: Gate, /)

Specific class of S gate, represented as \(\begin{bmatrix} 1 & 0\\ 0 & i \end{bmatrix}\).

Note

Upcast is required to use gate-general functions (ex: add to Circuit).

copy() Gate

Copy gate as Gate type.

gate_type() GateType

Get gate type as GateType enum.

get_control_qubit_list() list[int]

Get control qubits as list[int].

get_inverse() Gate

Generate inverse gate as Gate type. If not exists, return None.

get_matrix() numpy.typing.NDArray | None

Get matrix representation of the gate. If cannot, None is returned.

get_target_qubit_list() list[int]

Get target qubits as list[int]. Control qubits is not included.

target() int
update_quantum_state(arg: StateVector, /) None

Apply gate to state_vector. state_vector in args is directly updated.

scaluq.Sdag(arg: int, /) Gate

Generate general Gate class instance of Sdag.

class scaluq.SdagGate(arg: Gate, /)

Specific class of inverse of S gate.

Note

Upcast is required to use gate-general functions (ex: add to Circuit).

copy() Gate

Copy gate as Gate type.

gate_type() GateType

Get gate type as GateType enum.

get_control_qubit_list() list[int]

Get control qubits as list[int].

get_inverse() Gate

Generate inverse gate as Gate type. If not exists, return None.

get_matrix() numpy.typing.NDArray | None

Get matrix representation of the gate. If cannot, None is returned.

get_target_qubit_list() list[int]

Get target qubits as list[int]. Control qubits is not included.

target() int
update_quantum_state(arg: StateVector, /) None

Apply gate to state_vector. state_vector in args is directly updated.

scaluq.SqrtX(arg: int, /) Gate

Generate general Gate class instance of SqrtX.

class scaluq.SqrtXGate(arg: Gate, /)

Specific class of sqrt(X) gate, represented as \(\begin{bmatrix} 1+i & 1-i\\ 1-i & 1+i \end{bmatrix}\).

Note

Upcast is required to use gate-general functions (ex: add to Circuit).

copy() Gate

Copy gate as Gate type.

gate_type() GateType

Get gate type as GateType enum.

get_control_qubit_list() list[int]

Get control qubits as list[int].

get_inverse() Gate

Generate inverse gate as Gate type. If not exists, return None.

get_matrix() numpy.typing.NDArray | None

Get matrix representation of the gate. If cannot, None is returned.

get_target_qubit_list() list[int]

Get target qubits as list[int]. Control qubits is not included.

target() int
update_quantum_state(arg: StateVector, /) None

Apply gate to state_vector. state_vector in args is directly updated.

scaluq.SqrtXdag(arg: int, /) Gate

Generate general Gate class instance of SqrtXdag.

class scaluq.SqrtXdagGate(arg: Gate, /)

Specific class of inverse of sqrt(X) gate.

Note

Upcast is required to use gate-general functions (ex: add to Circuit).

copy() Gate

Copy gate as Gate type.

gate_type() GateType

Get gate type as GateType enum.

get_control_qubit_list() list[int]

Get control qubits as list[int].

get_inverse() Gate

Generate inverse gate as Gate type. If not exists, return None.

get_matrix() numpy.typing.NDArray | None

Get matrix representation of the gate. If cannot, None is returned.

get_target_qubit_list() list[int]

Get target qubits as list[int]. Control qubits is not included.

target() int
update_quantum_state(arg: StateVector, /) None

Apply gate to state_vector. state_vector in args is directly updated.

scaluq.SqrtY(arg: int, /) Gate

Generate general Gate class instance of SqrtY.

class scaluq.SqrtYGate(arg: Gate, /)

Specific class of sqrt(Y) gate, represented as \(\begin{bmatrix} 1+i & -1-i \\ 1+i & 1+i \end{bmatrix}\).

Note

Upcast is required to use gate-general functions (ex: add to Circuit).

copy() Gate

Copy gate as Gate type.

gate_type() GateType

Get gate type as GateType enum.

get_control_qubit_list() list[int]

Get control qubits as list[int].

get_inverse() Gate

Generate inverse gate as Gate type. If not exists, return None.

get_matrix() numpy.typing.NDArray | None

Get matrix representation of the gate. If cannot, None is returned.

get_target_qubit_list() list[int]

Get target qubits as list[int]. Control qubits is not included.

target() int
update_quantum_state(arg: StateVector, /) None

Apply gate to state_vector. state_vector in args is directly updated.

scaluq.SqrtYdag(arg: int, /) Gate

Generate general Gate class instance of SqrtYdag.

class scaluq.SqrtYdagGate(arg: Gate, /)

Specific class of inverse of sqrt(Y) gate.

Note

Upcast is required to use gate-general functions (ex: add to Circuit).

copy() Gate

Copy gate as Gate type.

gate_type() GateType

Get gate type as GateType enum.

get_control_qubit_list() list[int]

Get control qubits as list[int].

get_inverse() Gate

Generate inverse gate as Gate type. If not exists, return None.

get_matrix() numpy.typing.NDArray | None

Get matrix representation of the gate. If cannot, None is returned.

get_target_qubit_list() list[int]

Get target qubits as list[int]. Control qubits is not included.

target() int
update_quantum_state(arg: StateVector, /) None

Apply gate to state_vector. state_vector in args is directly updated.

class scaluq.StateVector(arg: StateVector)

Vector representation of quantum state.

Note

Qubit index is start from 0. If the amplitudes of \(\ket{b_{n-1}\dots b_0}\) is \(b_i\), the state is \(\sum_i b_i 2^i\).

Haar_random_state(seed: int | None = None) StateVector

Constructing state vector with Haar random state. If seed is not specified, the value from random device is used.

UNMEASURED: int
add_state_vector(arg: StateVector, /) None

Add other state vector and make superposition. \(\ket{\mathrm{this}} \leftarrow \ket{\mathrm{this}} + \ket{\mathrm{state}}\).

add_state_vector_with_coef(arg0: complex, arg1: StateVector, /) None

add other state vector with multiplying the coef and make superposition. \(\ket{\mathrm{this}}\leftarrow\ket{\mathrm{this}}+\mathrm{coef}\ket{\mathrm{state}}\).

amplitudes() list[complex]

Get all amplitudes with as list[complex].

dim() int

Get dimension of the vector (\(=2^\mathrm{n\_qubits}\)).

get_amplitude_at_index(arg: int, /) complex

Get amplitude at one index.

Note

If you want to get all amplitudes, you should use StateVector::amplitudes().

get_entropy() float

Get the entropy of the vector.

get_marginal_probability(arg: list[int], /) float

Get the marginal probability to observe as specified. Specify the result as n-length list. 0 and 1 represent the qubit is observed and get the value. 2 represents the qubit is not observed.

get_squared_norm() float

Get squared norm of the state. \(\braket{\psi|\psi}\).

get_zero_probability(arg: int, /) float

Get the probability to observe \(\ket{0}\) at specified index.

load(arg: list[complex], /) None

Load amplitudes of list[int] with dim length.

multiply_coef(arg: complex, /) None

Multiply coef. \(\ket{\mathrm{this}}\leftarrow\mathrm{coef}\ket{\mathrm{this}}\).

n_qubits() int

Get num of qubits.

normalize() None

Normalize state (let \(\braket{\psi|\psi} = 1\) by multiplying coef).

sampling(sampling_count: int, seed: int | None = None) list[int]

Sampling specified times. Result is list[int] with the sampling_count length.

set_amplitude_at_index(arg0: int, arg1: complex, /) None

Manually set amplitude at one index.

set_computational_basis(arg: int, /) None

Initialize with computational basis ket{mathrm{basis}}.

set_zero_norm_state() None

Initialize with 0 (null vector).

set_zero_state() None

Initialize with computational basis \(\ket{00\dots0}\).

to_string() str

Information as str.

scaluq.Swap(arg0: int, arg1: int, /) Gate

Generate general Gate class instance of Swap.

class scaluq.SwapGate(arg: Gate, /)

Specific class of two-qubit swap gate.

Note

Upcast is required to use gate-general functions (ex: add to Circuit).

copy() Gate

Copy gate as Gate type.

gate_type() GateType

Get gate type as GateType enum.

get_control_qubit_list() list[int]

Get control qubits as list[int].

get_inverse() Gate

Generate inverse gate as Gate type. If not exists, return None.

get_matrix() numpy.typing.NDArray | None

Get matrix representation of the gate. If cannot, None is returned.

get_target_qubit_list() list[int]

Get target qubits as list[int]. Control qubits is not included.

target1() int

Get property target1.

target2() int

Get property target2.

update_quantum_state(arg: StateVector, /) None

Apply gate to state_vector. state_vector in args is directly updated.

scaluq.T(arg: int, /) Gate

Generate general Gate class instance of T.

class scaluq.TGate(arg: Gate, /)

Specific class of T gate, represented as \(\begin{bmatrix} 1 & 0\\ 0 & e^{i\pi/4} \end{bmatrix}\).

Note

Upcast is required to use gate-general functions (ex: add to Circuit).

copy() Gate

Copy gate as Gate type.

gate_type() GateType

Get gate type as GateType enum.

get_control_qubit_list() list[int]

Get control qubits as list[int].

get_inverse() Gate

Generate inverse gate as Gate type. If not exists, return None.

get_matrix() numpy.typing.NDArray | None

Get matrix representation of the gate. If cannot, None is returned.

get_target_qubit_list() list[int]

Get target qubits as list[int]. Control qubits is not included.

target() int
update_quantum_state(arg: StateVector, /) None

Apply gate to state_vector. state_vector in args is directly updated.

scaluq.Tdag(arg: int, /) Gate

Generate general Gate class instance of Tdag.

class scaluq.TdagGate(arg: Gate, /)

Specific class of inverse of T gate.

Note

Upcast is required to use gate-general functions (ex: add to Circuit).

copy() Gate

Copy gate as Gate type.

gate_type() GateType

Get gate type as GateType enum.

get_control_qubit_list() list[int]

Get control qubits as list[int].

get_inverse() Gate

Generate inverse gate as Gate type. If not exists, return None.

get_matrix() numpy.typing.NDArray | None

Get matrix representation of the gate. If cannot, None is returned.

get_target_qubit_list() list[int]

Get target qubits as list[int]. Control qubits is not included.

target() int
update_quantum_state(arg: StateVector, /) None

Apply gate to state_vector. state_vector in args is directly updated.

class scaluq.TwoQubitMatrixGate(arg: Gate, /)

Specific class of double-qubit dense matrix gate.

Note

Upcast is required to use gate-general functions (ex: add to Circuit).

copy() Gate

Copy gate as Gate type.

gate_type() GateType

Get gate type as GateType enum.

get_control_qubit_list() list[int]

Get control qubits as list[int].

get_inverse() Gate

Generate inverse gate as Gate type. If not exists, return None.

get_matrix() numpy.typing.NDArray | None

Get matrix representation of the gate. If cannot, None is returned.

get_target_qubit_list() list[int]

Get target qubits as list[int]. Control qubits is not included.

matrix() None

Get property matrix.

target1() int

Get property target1.

target2() int

Get property target2.

update_quantum_state(arg: StateVector, /) None

Apply gate to state_vector. state_vector in args is directly updated.

scaluq.U1(arg0: int, arg1: float, /) Gate

Generate general Gate class instance of U1.

class scaluq.U1Gate(arg: Gate, /)

Specific class of IBMQ’s U1 Gate, which is a rotation abount Z-axis, represented as \(\begin{bmatrix} 1 & 0\\ 0 & e^{i\lambda} \end{bmatrix}\).

Note

Upcast is required to use gate-general functions (ex: add to Circuit).

copy() Gate

Copy gate as Gate type.

gate_type() GateType

Get gate type as GateType enum.

get_control_qubit_list() list[int]

Get control qubits as list[int].

get_inverse() Gate

Generate inverse gate as Gate type. If not exists, return None.

get_matrix() numpy.typing.NDArray | None

Get matrix representation of the gate. If cannot, None is returned.

get_target_qubit_list() list[int]

Get target qubits as list[int]. Control qubits is not included.

lambda_() float

Get lambda property.

update_quantum_state(arg: StateVector, /) None

Apply gate to state_vector. state_vector in args is directly updated.

scaluq.U2(arg0: int, arg1: float, arg2: float, /) Gate

Generate general Gate class instance of U2.

class scaluq.U2Gate(arg: Gate, /)

Specific class of IBMQ’s U2 Gate, which is a rotation about X+Z-axis, represented as \(\frac{1}{\sqrt{2}} \begin{bmatrix}1 & -e^{-i\lambda}\\ e^{i\phi} & e^{i(\phi+\lambda)} \end{bmatrix}\).

Note

Upcast is required to use gate-general functions (ex: add to Circuit).

copy() Gate

Copy gate as Gate type.

gate_type() GateType

Get gate type as GateType enum.

get_control_qubit_list() list[int]

Get control qubits as list[int].

get_inverse() Gate

Generate inverse gate as Gate type. If not exists, return None.

get_matrix() numpy.typing.NDArray | None

Get matrix representation of the gate. If cannot, None is returned.

get_target_qubit_list() list[int]

Get target qubits as list[int]. Control qubits is not included.

lambda_() float

Get lambda property.

phi() float

Get phi property.

update_quantum_state(arg: StateVector, /) None

Apply gate to state_vector. state_vector in args is directly updated.

scaluq.U3(arg0: int, arg1: float, arg2: float, arg3: float, /) Gate

Generate general Gate class instance of U3.

class scaluq.U3Gate(arg: Gate, /)

Specific class of IBMQ’s U3 Gate, which is a rotation abount 3 axis, represented as \(\begin{bmatrix} \cos \frac{\theta}{2} & -e^{i\lambda}\sin\frac{\theta}{2}\\ e^{i\phi}\sin\frac{\theta}{2} & e^{i(\phi+\lambda)}\cos\frac{\theta}{2} \end{bmatrix}\).

Note

Upcast is required to use gate-general functions (ex: add to Circuit).

copy() Gate

Copy gate as Gate type.

gate_type() GateType

Get gate type as GateType enum.

get_control_qubit_list() list[int]

Get control qubits as list[int].

get_inverse() Gate

Generate inverse gate as Gate type. If not exists, return None.

get_matrix() numpy.typing.NDArray | None

Get matrix representation of the gate. If cannot, None is returned.

get_target_qubit_list() list[int]

Get target qubits as list[int]. Control qubits is not included.

lambda_() float

Get lambda property.

phi() float

Get phi property.

theta() float

Get theta property.

update_quantum_state(arg: StateVector, /) None

Apply gate to state_vector. state_vector in args is directly updated.

scaluq.X(arg: int, /) Gate

Generate general Gate class instance of X.

class scaluq.XGate(arg: Gate, /)

Specific class of Pauli-X gate.

Note

Upcast is required to use gate-general functions (ex: add to Circuit).

copy() Gate

Copy gate as Gate type.

gate_type() GateType

Get gate type as GateType enum.

get_control_qubit_list() list[int]

Get control qubits as list[int].

get_inverse() Gate

Generate inverse gate as Gate type. If not exists, return None.

get_matrix() numpy.typing.NDArray | None

Get matrix representation of the gate. If cannot, None is returned.

get_target_qubit_list() list[int]

Get target qubits as list[int]. Control qubits is not included.

target() int
update_quantum_state(arg: StateVector, /) None

Apply gate to state_vector. state_vector in args is directly updated.

scaluq.Y(arg: int, /) Gate

Generate general Gate class instance of Y.

class scaluq.YGate(arg: Gate, /)

Specific class of Pauli-Y gate.

Note

Upcast is required to use gate-general functions (ex: add to Circuit).

copy() Gate

Copy gate as Gate type.

gate_type() GateType

Get gate type as GateType enum.

get_control_qubit_list() list[int]

Get control qubits as list[int].

get_inverse() Gate

Generate inverse gate as Gate type. If not exists, return None.

get_matrix() numpy.typing.NDArray | None

Get matrix representation of the gate. If cannot, None is returned.

get_target_qubit_list() list[int]

Get target qubits as list[int]. Control qubits is not included.

target() int
update_quantum_state(arg: StateVector, /) None

Apply gate to state_vector. state_vector in args is directly updated.

scaluq.Z(arg: int, /) Gate

Generate general Gate class instance of Z.

class scaluq.ZGate(arg: Gate, /)

Specific class of Pauli-Z gate.

Note

Upcast is required to use gate-general functions (ex: add to Circuit).

copy() Gate

Copy gate as Gate type.

gate_type() GateType

Get gate type as GateType enum.

get_control_qubit_list() list[int]

Get control qubits as list[int].

get_inverse() Gate

Generate inverse gate as Gate type. If not exists, return None.

get_matrix() numpy.typing.NDArray | None

Get matrix representation of the gate. If cannot, None is returned.

get_target_qubit_list() list[int]

Get target qubits as list[int]. Control qubits is not included.

target() int
update_quantum_state(arg: StateVector, /) None

Apply gate to state_vector. state_vector in args is directly updated.

scaluq.finalize() None

Terminate the Kokkos execution environment. Release the resources.

scaluq.initialize(settings: InitializationSettings = ...) None

You must call this before any scaluq function. Initialize the Kokkos execution environment.

scaluq.is_finalized() bool

Return true if finalize() is already called.

scaluq.is_initialized() bool

Return true if initialize() is already called.