scaluq.default.f32

module for f32 precision

Subpackages

Classes

Gate

General class of QuantumGate.

ParamGate

General class of parametric quantum gate.

StateVector

Vector representation of quantum state.

StateVectorBatched

Batched vector representation of quantum state.

DensityMatrix

DensityMatrix representation of quantum state.

SparseMatrixGate

Specific class of sparse matrix gate.

DenseMatrixGate

Specific class of dense matrix gate.

Operator

General quantum operator class.

OperatorBatched

General quantum operator class for batched operators.

IGate

Specific class of I gate.

GlobalPhaseGate

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

XGate

Specific class of Pauli-X gate.

YGate

Specific class of Pauli-Y gate.

ZGate

Specific class of Pauli-Z gate.

HGate

Specific class of Hadamard gate.

SGate

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

SdagGate

Specific class of inverse of S gate.

TGate

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

TdagGate

Specific class of inverse of T gate.

SqrtXGate

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

SqrtXdagGate

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

SqrtYGate

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

SqrtYdagGate

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

P0Gate

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

P1Gate

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

RXGate

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

RYGate

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

RZGate

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

U1Gate

Specific class of IBMQ's U1 Gate, which is a rotation about Z-axis, represented as $begin{bmatrix} 1 & 0 \ 0 & e^{ilambda} end{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}\ e^{iphi} & e^{i(phi+lambda)} end{bmatrix}$.

U3Gate

Specific class of IBMQ's U3 Gate, which is a rotation about 3 axis, represented as $begin{bmatrix} cos frac{theta}{2} & -e^{ilambda}sinfrac{theta}{2}\ e^{iphi}sinfrac{theta}{2} & e^{i(phi+lambda)}cosfrac{theta}{2} end{bmatrix}$.

SwapGate

Specific class of two-qubit swap gate.

EcrGate

Specific class of two-qubit ecr gate.represented as $frac{1}{sqrt{2}}begin{bmatrix} 0 & 1 & 0 & i \ 1 & 0 & -i & 0 \ 0 & i & 0 & 1 \ -i & 0 & 1 & 0 end{bmatrix}$.

MeasurementGate

Specific class of computational-basis measurement gate.

PauliGate

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

PauliRotationGate

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

ParamRXGate

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

ParamRYGate

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

ParamRZGate

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

ParamPauliRotationGate

Parametric multi-qubit pauli-rotation gate, represented as $e^{-ifrac{theta}{2}P}$. theta is given as param * param_coef.

ParamProbabilisticGate

Specific class of parametric probabilistic gate. The gate to apply is picked from a certain distribution.

Circuit

Quantum circuit representation.

PauliOperator

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

Functions

merge_gate(arg0, arg1, /)

Merge two gates. return value is (merged gate, global phase).

Package Contents

class scaluq.default.f32.Gate(arg)

General class of QuantumGate.

Notes

Downcast to required to use gate-specific functions.

Parameters:

arg (Gate)

gate_type()

Get gate type as GateType enum.

Examples

>>> g = H(0)
>>> print(g.gate_type())
GateType.H
Return type:

scaluq.scaluq_core.GateType

target_qubit_list()

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

Examples

>>> gate = CX(0, 1)
>>> gate.target_qubit_list()
[1]
Return type:

list[int]

control_qubit_list()

Get control qubits as list[int].

Examples

>>> gate = CX(0, 1)
>>> gate.control_qubit_list()
[0]
Return type:

list[int]

control_value_list()

Get control values as list[int].

Examples

>>> gate = CX(0, 1)
>>> gate.control_value_list()
[1]
Return type:

list[int]

operand_qubit_list()

Get target and control qubits as list[int].

Examples

>>> gate = CX(0, 1)
>>> gate.operand_qubit_list()
[0, 1]
Return type:

list[int]

target_qubit_mask()

Get target qubits as mask. Control qubits are not included.

Examples

>>> gate = H(0, controls=[1, 2], control_values=[1, 0])
>>> print(bin(gate.target_qubit_mask()))
0b1
Return type:

int

control_qubit_mask()

Get control qubits as mask.

Examples

>>> gate = H(0, controls=[1, 2], control_values=[1, 0])
>>> print(bin(gate.control_qubit_mask()))
0b110
Return type:

int

control_value_mask()

Get control values as mask.

Examples

>>> gate = H(0, controls=[1, 2], control_values=[1, 0])
>>> print(bin(gate.control_value_mask()))
0b10
Return type:

int

operand_qubit_mask()

Get target and control qubits as mask.

Examples

>>> gate = H(0, controls=[1, 2], control_values=[1, 0])
>>> print(bin(gate.operand_qubit_mask()))
0b111
Return type:

int

get_inverse()

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

Examples

>>> s = S(0)
>>> print(s.get_inverse())
Gate Type: Sdag
  Target Qubits: {0}
  Control Qubits: {}
  Control Value: {}
Return type:

object

get_matrix()

Get matrix representation of the gate. Note: The matrix is constructed by reordering target qubits in ascending order of their indices. The qubit with the smaller index is treated as the first target, and the larger as the second.

Examples

>>> gate = H(0, controls=[1, 2], control_values=[1, 0])
>>> print(gate.get_matrix())
[[ 0.70710678+0.j  0.70710678+0.j]
 [ 0.70710678+0.j -0.70710678+0.j]]
Return type:

Annotated[numpy.typing.NDArray[numpy.complex128], dict(shape=(None, None), order=’C’)]

to_string()

Get string representation of the gate.

Examples

>>> g = H(0)
>>> print(g.to_string())
Gate Type: H  Target Qubits: {0}  Control Qubits: {}  Control Value: {}
Return type:

str

to_json()

Get JSON representation of the gate.

Examples

>>> g = H(0)
>>> print(g.to_json())
{"control":[],"control_value":[],"target":[0],"type":"H"}
Return type:

str

load_json(json_str)

Read an object from the JSON representation of the gate.

Parameters:

json_str (str)

Return type:

None

update_quantum_state(state_vector)

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

Examples

>>> state = StateVector(2)
>>> state.set_computational_basis(0)
>>> H(0).update_quantum_state(state)
>>> print(state)
Qubit Count : 2
Dimension : 4
State vector :
  00 : (0.707107,0)
  01 : (0.707107,0)
  10 : (0,0)
  11 : (0,0)
Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Examples

>>> states = StateVectorBatched(2, 1)
>>> states.set_computational_basis(0)
>>> H(0).update_quantum_state(states)
>>> print(states)
Qubit Count : 1
Dimension : 2
--------------------
Batch_id : 0
State vector :
  0 : (0.707107,0)
  1 : (0.707107,0)
--------------------
Batch_id : 1
State vector :
  0 : (0.707107,0)
  1 : (0.707107,0)
Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector)

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

Examples

>>> state = StateVector(2)
>>> state.set_computational_basis(0)
>>> H(0).update_quantum_state(state)
>>> print(state)
Qubit Count : 2
Dimension : 4
State vector :
  00 : (0.707107,0)
  01 : (0.707107,0)
  10 : (0,0)
  11 : (0,0)
Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Examples

>>> states = StateVectorBatched(2, 1)
>>> states.set_computational_basis(0)
>>> H(0).update_quantum_state(states)
>>> print(states)
Qubit Count : 1
Dimension : 2
--------------------
Batch_id : 0
State vector :
  0 : (0.707107,0)
  1 : (0.707107,0)
--------------------
Batch_id : 1
State vector :
  0 : (0.707107,0)
  1 : (0.707107,0)
Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

phase()

Get phase property. The phase is represented as \(\gamma\).

Return type:

float

class scaluq.default.f32.ParamGate(arg)

General class of parametric quantum gate.

Notes

Downcast to required to use gate-specific functions.

Parameters:

arg (ParamGate)

param_gate_type()

Get parametric gate type as ParamGateType enum.

Return type:

scaluq.scaluq_core.ParamGateType

param_coef()

Get coefficient of parameter.

Return type:

float

target_qubit_list()

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

Return type:

list[int]

control_qubit_list()

Get control qubits as list[int].

Return type:

list[int]

operand_qubit_list()

Get target and control qubits as list[int].

Return type:

list[int]

target_qubit_mask()

Get target qubits as mask. Control qubits is not included.

Return type:

int

control_qubit_mask()

Get control qubits as mask.

Return type:

int

operand_qubit_mask()

Get target and control qubits as mask.

Return type:

int

get_inverse()

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

Return type:

object

update_quantum_state(state, param)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • params (collections.abc.Sequence[float])

  • seed (int | None)

Return type:

None

update_quantum_state(state, classical_register, param, seed=None)

Apply gate to state_vector with classical_register, parameter, and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • params (collections.abc.Sequence[float])

  • seed (int | None)

Return type:

None

update_quantum_state(states, params)

updated.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • params (collections.abc.Sequence[float])

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, params, seed=None)

Apply gate to states with classical_register, parameters, and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • params (collections.abc.Sequence[float])

  • seed (int | None)

Return type:

None

update_quantum_state(state, param)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • params (collections.abc.Sequence[float])

  • seed (int | None)

Return type:

None

update_quantum_state(state, classical_register, param, seed=None)

Apply gate to state_vector with classical_register, parameter, and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • params (collections.abc.Sequence[float])

  • seed (int | None)

Return type:

None

update_quantum_state(states, params)

Apply gate to states with holding the parameters. states in args is directly updated.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • params (collections.abc.Sequence[float])

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, params, seed=None)

Apply gate to states with classical_register, parameters, and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • params (collections.abc.Sequence[float])

  • seed (int | None)

Return type:

None

get_matrix(param)

Get matrix representation of the gate with holding the parameter.

Parameters:

param (float)

Return type:

Annotated[numpy.typing.NDArray[numpy.complex128], dict(shape=(None, None), order=’C’)]

to_string()

Get string representation of the gate.

Return type:

str

to_json()

Get JSON representation of the gate.

Return type:

str

load_json(json_str)

Read an object from the JSON representation of the gate.

Parameters:

json_str (str)

Return type:

None

class scaluq.default.f32.StateVector(n_qubits)

Vector representation of quantum state.

Qubit index is start from 0. If the i-th value of the vector is \(a_i\), the state is \(\sum_i a_i \ket{i}\).

Given n_qubits: int, construct with bases \(\ket{0\dots 0}\) holding n_qubits number of qubits.

Examples

>>> state1 = StateVector(2)
>>> print(state1)
Qubit Count : 2
Dimension : 4
State vector :
  00 : (1,0)
  01 : (0,0)
  10 : (0,0)
  11 : (0,0)
Parameters:

n_qubits (int)

static Haar_random_state(n_qubits, seed=None)

Construct StateVector with Haar random state.

Parameters:
  • n_qubits (int) – number of qubits

  • seed (int | None, optional) –

    random seed

    If not specified, the value from random device is used.

Return type:

StateVector

Examples

>>> state = StateVector.Haar_random_state(2)
>>> print(state.get_amplitudes()) 
[(-0.3188299516496241+0.6723250989136779j), (-0.253461343768224-0.22430415678425403j), (0.24998142919420457+0.33096908710840045j), (0.2991187916479724+0.2650813322096342j)]
>>> print(StateVector.Haar_random_state(2).get_amplitudes()) # If seed is not specified, generated vector differs. 
[(-0.49336775961196616-0.3319437726884906j), (-0.36069529482031787+0.31413708595210815j), (-0.3654176892043237-0.10307602590749808j), (-0.18175679804035652+0.49033467421609994j)]
>>> print(StateVector.Haar_random_state(2, 0).get_amplitudes()) 
[(0.030776817573663098-0.7321137912473642j), (0.5679070655936114-0.14551095055034327j), (-0.0932995615041323-0.07123201881040941j), (0.15213024630399696-0.2871374092016799j)]
>>> print(StateVector.Haar_random_state(2, 0).get_amplitudes()) # If same seed is specified, same vector is generated. 
[(0.030776817573663098-0.7321137912473642j), (0.5679070655936114-0.14551095055034327j), (-0.0932995615041323-0.07123201881040941j), (0.15213024630399696-0.2871374092016799j)]
static uninitialized_state(n_qubits)

Construct StateVector without initializing.

Parameters:

n_qubits (int) – number of qubits

Return type:

StateVector

set_Haar_random_state(seed=None)

Set Haar random state.

Parameters:

seed (int | None, optional) –

random seed

If not specified, the value from random device is used.

Return type:

None

Examples

>>> state = StateVector(2)
>>> state.set_Haar_random_state()
>>> print(state.get_amplitudes()) 
[(-0.3188299516496241+0.6723250989136779j), (-0.253461343768224-0.22430415678425403j), (0.24998142919420457+0.33096908710840045j), (0.2991187916479724+0.2650813322096342j)]
set_amplitude_at(index, value)

Manually set amplitude at one index.

Parameters:
  • index (int) –

    index of state vector

    This is read as binary.k-th bit of index represents k-th qubit.

  • value (complex) – amplitude value to set at index

Return type:

None

Examples

>>> state = StateVector(2)
>>> state.get_amplitudes()
[(1+0j), 0j, 0j, 0j]
>>> state.set_amplitude_at(2, 3+1j)
>>> state.get_amplitudes()
[(1+0j), 0j, (3+1j), 0j]

Notes

If you want to set amplitudes at all indices, you should use load().

get_amplitude_at(index)

Get amplitude at one index.

Parameters:

index (int) –

index of state vector

This is read as binary. k-th bit of index represents k-th qubit.

Returns:

Amplitude at specified index

Return type:

complex

Examples

>>> state = StateVector(2)
>>> state.load([1+2j, 3+4j, 5+6j, 7+8j])
>>> state.get_amplitude_at(0)
(1+2j)
>>> state.get_amplitude_at(1)
(3+4j)
>>> state.get_amplitude_at(2)
(5+6j)
>>> state.get_amplitude_at(3)
(7+8j)

Notes

If you want to get amplitudes at all indices, you should use get_amplitudes().

set_zero_state()

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

Examples

>>> state = StateVector.Haar_random_state(2)
>>> state.get_amplitudes() 
[(-0.05726462181150916+0.3525270165415515j), (0.1133709060491142+0.3074930854078303j), (0.03542174692996924+0.18488950377672345j), (0.8530024105558827+0.04459332470844164j)]
>>> state.set_zero_state()
>>> state.get_amplitudes()
[(1+0j), 0j, 0j, 0j]
Return type:

None

set_zero_norm_state()

Initialize with \(0\) (null vector).

Examples

>>> state = StateVector(2)
>>> state.get_amplitudes()
[(1+0j), 0j, 0j, 0j]
>>> state.set_zero_norm_state()
>>> state.get_amplitudes()
[0j, 0j, 0j, 0j]
Return type:

None

set_computational_basis(basis)

Initialize with computational basis \(\ket{\mathrm{basis}}\).

Parameters:

basis (int) – basis as integer format (\(0 \leq \mathrm{basis} \leq 2^{\mathrm{n\_qubits}}-1\))

Return type:

None

Examples

>>> state = StateVector(2)
>>> state.set_computational_basis(0) # |00>
>>> state.get_amplitudes()
[(1+0j), 0j, 0j, 0j]
>>> state.set_computational_basis(1) # |01>
>>> state.get_amplitudes()
[0j, (1+0j), 0j, 0j]
>>> state.set_computational_basis(2) # |10>
>>> state.get_amplitudes()
[0j, 0j, (1+0j), 0j]
>>> state.set_computational_basis(3) # |11>
>>> state.get_amplitudes()
[0j, 0j, 0j, (1+0j)]
get_amplitudes()

Get all amplitudes as list[complex].

Returns:

amplitudes of list with len \(2^{\mathrm{n\_qubits}}\)

Return type:

list[complex]

Examples

>>> state = StateVector(2)
>>> state.get_amplitudes()
[(1+0j), 0j, 0j, 0j]
n_qubits()

Get num of qubits.

Returns:

num of qubits

Return type:

int

Examples

>>> state = StateVector(2)
>>> state.n_qubits()
2
dim()

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

Returns:

dimension of the vector

Return type:

int

Examples

>>> state = StateVector(2)
>>> state.dim()
4
get_squared_norm()

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

Returns:

squared norm of the state

Return type:

float

Examples

>>> v = [1+2j, 3+4j, 5+6j, 7+8j]
>>> state = StateVector(2)
>>> state.load(v)
>>> state.get_squared_norm()
204.0
>>> sum([abs(a)**2 for a in v])
204.0
normalize()

Normalize state.

Let \(\braket{\psi|\psi} = 1\) by multiplying constant.

Examples

>>> v = [1+2j, 3+4j, 5+6j, 7+8j]
>>> state = StateVector(2)
>>> state.load(v)
>>> norm = state.get_squared_norm()**.5
>>> state.normalize()
>>> state.get_amplitudes()
[(0.07001400420140048+0.14002800840280097j), (0.21004201260420147+0.28005601680560194j), (0.3500700210070024+0.42008402520840293j), (0.4900980294098034+0.5601120336112039j)]
>>> [a / norm for a in v]
[(0.07001400420140048+0.14002800840280097j), (0.21004201260420147+0.28005601680560194j), (0.3500700210070024+0.42008402520840293j), (0.4900980294098034+0.5601120336112039j)]
Return type:

None

get_zero_probability(index)

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

State must be normalized.

Parameters:

index (int) – qubit index to be observed

Returns:

probability to observe \(\ket{0}\)

Return type:

float

Examples

>>> v = [1 / 6**.5, 2j / 6**.5 * 1j, -1 / 6**.5, -2j / 6**.5]
>>> state = StateVector(2)
>>> state.load(v)
>>> state.get_zero_probability(0)
0.3333333333333334
>>> state.get_zero_probability(1)
0.8333333333333336
>>> abs(v[0])**2+abs(v[2])**2
0.3333333333333334
>>> abs(v[0])**2+abs(v[1])**2
0.8333333333333336
get_marginal_probability(measured_values)

Get the marginal probability to observe as given.

State must be normalized.

Parameters:

measured_values (list[int]) –

list with len n_qubits.

0, 1 or UNMEASURED is allowed for each elements. 0 or 1 shows the qubit is observed and the value is got. UNMEASURED shows the the qubit is not observed.

Returns:

probability to observe as given

Return type:

float

Examples

>>> v = [1/4, 1/2, 0, 1/4, 1/4, 1/2, 1/4, 1/2]
>>> state = StateVector(3)
>>> state.load(v)
>>> state.get_marginal_probability([0, 1, StateVector.UNMEASURED])
0.0625
>>> abs(v[2])**2 + abs(v[6])**2
0.0625
get_computational_basis_entropy()

Get the Shannon entropy of the Z-basis measurement distribution.

State must be normalized.

Returns:

entropy

Return type:

float

Examples

>>> v = [1/4, 1/2, 0, 1/4, 1/4, 1/2, 1/4, 1/2]
>>> state = StateVector(3)
>>> state.load(v)
>>> state.get_computational_basis_entropy()
2.5
>>> import math
>>> sum(-abs(a)**2 * math.log2(abs(a)**2) for a in v if a != 0)
2.5

Notes

The result of this function differs from qulacs. This is because scaluq adopted 2 for the base of log in the definition of entropy \(\sum_i -p_i \log p_i\) however qulacs adopted e.

add_state_vector_with_coef(coef, state)

Add other state vector with multiplying the coef and make superposition.

\(\ket{\mathrm{this}}\leftarrow\ket{\mathrm{this}}+\mathrm{coef} \ket{\mathrm{state}}\).

Parameters:
  • coef (complex) – coefficient to multiply to state

  • state (StateVector) – state to be added

Return type:

None

Examples

>>> state1 = StateVector(1)
>>> state1.load([1, 2])
>>> state2 = StateVector(1)
>>> state2.load([3, 4])
>>> state1.add_state_vector_with_coef(2j, state2)
>>> state1.get_amplitudes()
[(1+6j), (2+8j)]
multiply_coef(coef)

Multiply coef.

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

Parameters:

coef (complex) – coefficient to multiply

Return type:

None

Examples

>>> state = StateVector(1)
>>> state.load([1, 2])
>>> state.multiply_coef(2j)
>>> state.get_amplitudes()
[2j, 4j]
sampling(sampling_count, seed=None)

Sampling state vector independently and get list of computational basis

Parameters:
  • sampling_count (int) – how many times to apply sampling

  • seed (int | None, optional) –

    random seed

    If not specified, the value from random device is used.

Returns:

result of sampling

list of sampling_count length. Each element is in \([0,2^{\mathrm{n\_qubits}})\)

Return type:

list[int]

Examples

>>> state = StateVector(2)
>>> state.load([1/2, 0, -3**.5/2, 0])
>>> state.sampling(8) 
[0, 2, 2, 2, 2, 0, 0, 2]
to_string()

Information as str.

Returns:

information as str

Return type:

str

Examples

>>> state = StateVector(1)
>>> state.to_string()
'Qubit Count : 1\nDimension : 2\nState vector : \n  0 : (1,0)\n  1 : (0,0)\n'
load(other)

Load amplitudes of Sequence

Parameters:

other (collections.abc.Sequence[complex]) – list of complex amplitudes with len \(2^{\mathrm{n\_qubits}}\)

Return type:

None

load(other)

Load amplitudes of StateVector

Parameters:

other (StateVector) – State vector to load from.

Return type:

None

copy_to_default_space()

Return a deep copy in the default execution space.

Returns:

Copied state vector.

Return type:

scaluq.default.f32.StateVector

copy_to_host_space()

Return a deep copy in the host execution space.

Returns:

Copied state vector.

Return type:

scaluq.host.f32.StateVector

static inner_product(a, b)

Calculate inner product \(\braket{a | b}\).

Parameters:
Returns:

inner product \(\braket{a | b}\)

Return type:

complex

Examples

>>> state1 = StateVector(2)
>>> state1.load([1/2, 0, 0, 1/2]) # (|00> + |11>)/sqrt(2)
>>> state2 = StateVector(2)
>>> state2.load([1/2, 0, 0, -1/2]) # (|00> - |11>)/sqrt(2)
>>> StateVector.inner_product(state1, state2)
0j
UNMEASURED: int = Ellipsis

Constant used for StateVector::get_marginal_probability to express the the qubit is not measured.

to_json()

Information as json style.

Returns:

information as json style

Return type:

str

Examples

>>> state = StateVector(1)
>>> state.to_json()
'{"amplitudes":[{"imag":0.0,"real":1.0},{"imag":0.0,"real":0.0}],"n_qubits":1}'
load_json(json_str)

Read an object from the JSON representation of the state vector.

Parameters:

json_str (str)

Return type:

None

class scaluq.default.f32.StateVectorBatched(batch_size, n_qubits)

Batched vector representation of quantum state.

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

Given batch_size: int, n_qubits: int, construct a batched state vector with specified batch size and qubits.

Given other: StateVectorBatched, Construct a batched state vector by copying another batched state.

Examples

>>> states = StateVectorBatched(3, 2)
>>> print(states)
Qubit Count : 2
Dimension : 4
--------------------
Batch_id : 0
State vector :
  00 : (1,0)
  01 : (0,0)
  10 : (0,0)
  11 : (0,0)
--------------------
Batch_id : 1
State vector :
  00 : (1,0)
  01 : (0,0)
  10 : (0,0)
  11 : (0,0)
--------------------
Batch_id : 2
State vector :
  00 : (1,0)
  01 : (0,0)
  10 : (0,0)
  11 : (0,0)
Parameters:
  • batch_size (int)

  • n_qubits (int)

n_qubits()

Get the number of qubits in each state vector.

Returns:

The number of qubits.

Return type:

int

dim()

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

Returns:

The dimension of the vector.

Return type:

int

batch_size()

Get the batch size (number of state vectors).

Returns:

The batch size.

Return type:

int

set_state_vector(state)

Set all state vectors in the batch to the given state.

Parameters:

state (StateVector) – State to set for all batches.

Return type:

None

set_state_vector_at(batch_id, state)

Set the state vector at a specific batch index.

Parameters:
  • batch_id (int) – Index in batch to set.

  • state (StateVector) – State to set at the specified index.

Return type:

None

get_state_vector_at(batch_id)

Get the state vector at a specific batch index.

Parameters:

batch_id (int) – Index in batch to get.

Returns:

The state vector at the specified batch index.

Return type:

StateVector

view_state_vector_at(batch_id)

Return a view of the state vector at a specific batch index.

Parameters:

batch_id (int) – Index in batch to view.

Returns:

A view of the state vector at the specified batch index.

Return type:

StateVector

set_zero_state()

Initialize all states to |0…0⟩.

Return type:

None

set_computational_basis(basis)

Set all states to the specified computational basis state.

Parameters:

basis (int) – Index of the computational basis state.

Return type:

None

set_zero_norm_state()

Set all amplitudes to zero.

Return type:

None

set_Haar_random_state(set_same_state, seed=None)

Initialize with Haar random states.

Parameters:
  • batch_size (int) – Number of states in batch.

  • n_qubits (int) – Number of qubits per state.

  • set_same_state (bool) – Whether to set all states to the same random state.

  • seed (int, optional) – Random seed (default: random).

Return type:

None

static Haar_random_state(batch_size, n_qubits, set_same_state, seed=None)

Construct StateVectorBatched with Haar random state.

Parameters:
  • batch_size (int) – Number of states in batch.

  • n_qubits (int) – Number of qubits per state.

  • set_same_state (bool) – Whether to set all states to the same random state.

  • seed (int, optional) – Random seed (default: random).

Returns:

New batched state vector with random states.

Return type:

StateVectorBatched

static uninitialized_state(batch_size, n_qubits)

Construct StateVectorBatched without initializing.

Parameters:
  • batch_size (int) – Number of states in batch.

  • n_qubits (int) – number of qubits

Return type:

StateVectorBatched

get_squared_norm()

Get squared norm for each state in the batch.

Returns:

List of squared norms.

Return type:

list[float]

normalize()

Normalize all states in the batch.

Return type:

None

get_zero_probability(target_qubit_index)

Get probability of measuring |0⟩ on specified qubit for each state.

Parameters:

target_qubit_index (int) – Index of qubit to measure.

Returns:

Probabilities for each state in batch.

Return type:

list[float]

get_marginal_probability(measured_values)

Get marginal probabilities for specified measurement outcomes.

Parameters:

measured_values (list[int]) – Measurement configuration.

Returns:

Probabilities for each state in batch.

Return type:

list[float]

get_computational_basis_entropy()

Calculate the Shannon entropy of the Z-basis measurement distribution for each state.

Returns:

Entropy values for each state.

Return type:

list[float]

sampling(sampling_count, seed=None)

Sample from the probability distribution of each state.

Parameters:
  • sampling_count (int) – Number of samples to take.

  • seed (int, optional) – Random seed (default: random).

Returns:

Samples for each state in batch.

Return type:

list[list[int]]

add_state_vector_with_coef(coef, states)

Add another batched state vector multiplied by a coefficient.

Parameters:
  • coef (complex) – Coefficient to multiply with states.

  • states (StateVectorBatched) – States to add.

Return type:

None

multiply_coef(coef)

Multiply all states by a coefficient.

Parameters:

coef (complex) – Coefficient to multiply.

Return type:

None

load(states)

Load amplitudes for all states in batch.

Parameters:
Return type:

None

load(other)

Load states from another StateVectorBatched.

Parameters:

other (StateVectorBatched) – Batched state vector to load from.

Return type:

None

get_reduced_state()

Get the sum of all states in the batch as a single state vector.

Returns:

Reduced state vector.

Return type:

StateVector

get_amplitudes()

Get amplitudes of all states in batch.

Returns:

Amplitudes for each state.

Return type:

list[list[complex]]

copy()

Create a deep copy of this batched state vector.

Returns:

New copy of the states.

Return type:

StateVectorBatched

copy_to_default_space()

Return a deep copy in the default execution space.

Returns:

Copied batched state vector.

Return type:

scaluq.default.f32.StateVectorBatched

copy_to_host_space()

Return a deep copy in the host execution space.

Returns:

Copied batched state vector.

Return type:

scaluq.host.f32.StateVectorBatched

to_string()

Get string representation of the batched states.

Returns:

String representation of states.

Return type:

str

Examples

>>> states = StateVectorBatched(2, 3)
>>> print(states.to_string())
Qubit Count : 3
Dimension : 8
--------------------
Batch_id : 0
State vector :
  000 : (1,0)
  001 : (0,0)
  010 : (0,0)
  011 : (0,0)
  100 : (0,0)
  101 : (0,0)
  110 : (0,0)
  111 : (0,0)
--------------------
Batch_id : 1
State vector :
  000 : (1,0)
  001 : (0,0)
  010 : (0,0)
  011 : (0,0)
  100 : (0,0)
  101 : (0,0)
  110 : (0,0)
  111 : (0,0)
to_json()

Convert states to JSON string.

Returns:

JSON representation of states.

Return type:

str

Examples

>>> states = StateVectorBatched(2, 3)
>>> print(states.to_json())
{"amplitudes":[[{"imag":0.0,"real":1.0},{"imag":0.0,"real":0.0},{"imag":0.0,"real":0.0},{"imag":0.0,"real":0.0},{"imag":0.0,"real":0.0},{"imag":0.0,"real":0.0},{"imag":0.0,"real":0.0},{"imag":0.0,"real":0.0}],[{"imag":0.0,"real":1.0},{"imag":0.0,"real":0.0},{"imag":0.0,"real":0.0},{"imag":0.0,"real":0.0},{"imag":0.0,"real":0.0},{"imag":0.0,"real":0.0},{"imag":0.0,"real":0.0},{"imag":0.0,"real":0.0}]],"batch_size":2,"n_qubits":3}
load_json(json_str)

Load states from JSON string.

Parameters:

json_str (str) – JSON string to load from.

Return type:

None

class scaluq.default.f32.DensityMatrix(n_qubits)

DensityMatrix representation of quantum state.

Qubit index is start from 0. If the (i,j)-th value of the matrix is \(a_{ij}\), the state is \(\sum_{i,j} a_{ij} \ket{i}\bra{j}\).

Parameters:

n_qubits (int)

n_qubits()

Get the number of qubits.

Returns:

number of qubits

Return type:

int

Examples

>>> state = DensityMatrix(3)
>>> state.n_qubits()
3
dim()

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

Returns:

dimension of the density matrix

Return type:

int

Examples

>>> state = DensityMatrix(2)
>>> state.dim()
4
is_hermitian()

Check if the density matrix is guaranteed to be Hermitian.

Returns:

True if the density matrix is Hermitian, False if it may not be Hermitian

Return type:

bool

Examples

>>> state = DensityMatrix(2)
>>> state.is_hermitian()
True
force_hermitian()

Force the density matrix to be treated as Hermitian. This may enable certain optimizations but should only be used if you are sure the matrix is actually Hermitian.

Examples

>>> state = DensityMatrix(2)
>>> state.multiply_coef(1j)
>>> state.multiply_coef(-1j)
>>> state.is_hermitian()
False
>>> state.force_hermitian()
>>> state.is_hermitian()
True
Return type:

None

get_coherence_at(row_index, col_index)

Get coherence at specified position.

This is a very slow operation. Use get_matrix() instead if possible.

Parameters:
  • row_index (int) – row index

  • col_index (int) – column index

Returns:

coherence at the specified position

Return type:

complex

Examples

>>> state = DensityMatrix(2)
>>> state.get_coherence_at(0, 0)
(1+0j)
>>> state.get_coherence_at(0, 1)
0j
set_coherence_at(row_index, col_index, value)

Set coherence at specified position.

This is a very slow operation. Use load() instead if possible.

is_hermitian is set to False unless diagonal element and real value is passed in.

Parameters:
  • row_index (int) – row index

  • col_index (int) – column index

  • value (complex) – value to set at the specified position

Return type:

None

Examples

>>> state = DensityMatrix(2)
>>> print(state.get_matrix())
[[1.+0.j 0.+0.j 0.+0.j 0.+0.j]
 [0.+0.j 0.+0.j 0.+0.j 0.+0.j]
 [0.+0.j 0.+0.j 0.+0.j 0.+0.j]
 [0.+0.j 0.+0.j 0.+0.j 0.+0.j]]
>>> state.set_coherence_at(0, 1, 0.5+0.5j)
>>> print(state.get_matrix())
[[1. +0.j  0.5+0.5j 0. +0.j  0. +0.j ]
 [0. +0.j  0. +0.j  0. +0.j  0. +0.j ]
 [0. +0.j  0. +0.j  0. +0.j  0. +0.j ]
 [0. +0.j  0. +0.j  0. +0.j  0. +0.j ]]
set_coherence_pair_at(row_index, col_index, value)

Set coherence at specified position and its conjugate position to maintain Hermitian property.

This is a very slow operation. Use load() instead if possible.

Parameters:
  • row_index (int) – row index

  • col_index (int) – column index

  • value (complex) – value to set at the specified position

Return type:

None

Examples

>>> state = DensityMatrix(2)
>>> print(state.get_matrix())
[[1.+0.j 0.+0.j 0.+0.j 0.+0.j]
 [0.+0.j 0.+0.j 0.+0.j 0.+0.j]
 [0.+0.j 0.+0.j 0.+0.j 0.+0.j]
 [0.+0.j 0.+0.j 0.+0.j 0.+0.j]]
>>> state.set_coherence_pair_at(0, 1, 0.5+0.5j)
>>> print(state.get_matrix())
[[1. +0.j  0.5+0.5j 0. +0.j  0. +0.j ]
 [0.5-0.5j 0. +0.j  0. +0.j  0. +0.j ]
 [0. +0.j  0. +0.j  0. +0.j  0. +0.j ]
 [0. +0.j  0. +0.j  0. +0.j  0. +0.j ]]
get_matrix()

Get the density matrix as ndarray.

Returns:

density matrix as 2D array

Return type:

Annotated[numpy.typing.NDArray[numpy.complex128], dict(shape=(None, None), order=’C’)]

Examples

>>> state = DensityMatrix(2)
>>> print(state.get_matrix())
[[1.+0.j 0.+0.j 0.+0.j 0.+0.j]
 [0.+0.j 0.+0.j 0.+0.j 0.+0.j]
 [0.+0.j 0.+0.j 0.+0.j 0.+0.j]
 [0.+0.j 0.+0.j 0.+0.j 0.+0.j]]
copy()

Get a copy of the density matrix.

Returns:

a copy of the density matrix

Return type:

DensityMatrix

Examples

>>> state1 = DensityMatrix(2)
>>> state2 = state1.copy()
>>> print(state1.get_matrix())
[[1.+0.j 0.+0.j 0.+0.j 0.+0.j]
 [0.+0.j 0.+0.j 0.+0.j 0.+0.j]
 [0.+0.j 0.+0.j 0.+0.j 0.+0.j]
 [0.+0.j 0.+0.j 0.+0.j 0.+0.j]]
>>> print(state2.get_matrix())
[[1.+0.j 0.+0.j 0.+0.j 0.+0.j]
 [0.+0.j 0.+0.j 0.+0.j 0.+0.j]
 [0.+0.j 0.+0.j 0.+0.j 0.+0.j]
 [0.+0.j 0.+0.j 0.+0.j 0.+0.j]]
copy_to_default_space()

Get a copy of the density matrix in the default execution space.

Returns:

a copy of the density matrix in the default execution space

Return type:

scaluq.default.f32.DensityMatrix

Examples

>>> state_host = DensityMatrix(2)
>>> state_default = state_host.copy_to_default_space()
>>> print(state_default.get_matrix())
[[1.+0.j 0.+0.j 0.+0.j 0.+0.j]
 [0.+0.j 0.+0.j 0.+0.j 0.+0.j]
 [0.+0.j 0.+0.j 0.+0.j 0.+0.j]
 [0.+0.j 0.+0.j 0.+0.j 0.+0.j]]
copy_to_host_space()

Get a copy of the density matrix in the host execution space.

Returns:

a copy of the density matrix in the host execution space

Return type:

scaluq.host.f32.DensityMatrix

Examples

>>> state_default = DensityMatrix(2)
>>> state_host = state_default.copy_to_host_space()
>>> print(state_host.get_matrix())
[[1.+0.j 0.+0.j 0.+0.j 0.+0.j]
 [0.+0.j 0.+0.j 0.+0.j 0.+0.j]
 [0.+0.j 0.+0.j 0.+0.j 0.+0.j]
 [0.+0.j 0.+0.j 0.+0.j 0.+0.j]]
load(matrix, is_hermitian=False)

Load the density matrix from a 2D array.

Parameters:
  • matrix (Annotated[numpy.typing.NDArray[numpy.complex128], dict(shape=(None, None), order=’C’)]) – 2D array representing the density matrix

  • is_hermitian (bool) – Whether the input matrix is guaranteed to be Hermitian.

  • state_vector (StateVector)

Return type:

None

Examples

>>> import numpy as np
>>> state = DensityMatrix(1)
>>> matrix = np.array([[0.5+0.5j, 0], [0, 0.5-0.5j]])
>>> state.load(matrix, is_hermitian=True)
>>> print(state.get_matrix())
[[0.5+0.5j 0. +0.j ]
 [0. +0.j  0.5-0.5j]]
load(other)

Load the density matrix from another DensityMatrix.

Parameters:
Return type:

None

Examples

>>> state1 = DensityMatrix.Haar_random_state(1)
>>> print(state1.get_matrix()) 
[[ 0.35920411+8.30722924e-18j -0.29205502-3.80631554e-01j]
 [-0.29205502+3.80631554e-01j  0.64079589+5.48595618e-18j]]
>>> state2 = DensityMatrix(1)
>>> state2.load(state1)
>>> print(state2.get_matrix()) 
[[ 0.35920411+8.30722924e-18j -0.29205502-3.80631554e-01j]
 [-0.29205502+3.80631554e-01j  0.64079589+5.48595618e-18j]]
load(state_vector)

Load the density matrix from a StateVector. The density matrix is set to \(\ket{\psi}\bra{\psi}\) where \(\ket{\psi}\) is the input state vector.

Parameters:

state_vector (StateVector) – StateVector to load from

Return type:

None

Examples

>>> sv = StateVector(2)
>>> sv.set_computational_basis(1)
>>> dm = DensityMatrix(2)
>>> dm.load(sv)
>>> print(dm.get_matrix())
[[0.+0.j 0.+0.j 0.+0.j 0.+0.j]
 [0.+0.j 1.+0.j 0.+0.j 0.+0.j]
 [0.+0.j 0.+0.j 0.+0.j 0.+0.j]
 [0.+0.j 0.+0.j 0.+0.j 0.+0.j]]
static uninitialized_state(n_qubits)

Create an uninitialized density matrix with specified number of qubits.

Parameters:

n_qubits (int) – number of qubits

Returns:

an uninitialized density matrix

Return type:

DensityMatrix

static Haar_random_state(n_qubits, seed=None)

Create a density matrix representing a Haar random state.

Parameters:
  • n_qubits (int) – number of qubits

  • seed (int | None, optional) –

    random seed

    If not specified, the value from random device is used.

Returns:

a density matrix representing a Haar random state

Return type:

DensityMatrix

Examples

>>> state = DensityMatrix.Haar_random_state(1)
>>> print(state.get_matrix()) 
[[ 0.35920411+8.30722924e-18j -0.29205502-3.80631554e-01j]
 [-0.29205502+3.80631554e-01j  0.64079589+5.48595618e-18j]]
>>> state1 = DensityMatrix.Haar_random_state(1, seed=42)
>>> state2 = DensityMatrix.Haar_random_state(1, seed=42)
>>> print(state1.get_matrix()) 
[[ 0.7662367 -2.34701458e-17j -0.35360255-2.32558070e-01j]
 [-0.35360255+2.32558070e-01j  0.2337633 -7.47914693e-19j]]
>>> print(state2.get_matrix()) 
[[ 0.7662367 -2.34701458e-17j -0.35360255-2.32558070e-01j]
 [-0.35360255+2.32558070e-01j  0.2337633 -7.47914693e-19j]]
set_zero_state()

Set the density matrix to the zero state \(\ket{0\dots0}\bra{0\dots0}\).

Examples

>>> state = DensityMatrix.uninitialized_state(2)
>>> state.set_zero_state()
>>> print(state.get_matrix())
[[1.+0.j 0.+0.j 0.+0.j 0.+0.j]
 [0.+0.j 0.+0.j 0.+0.j 0.+0.j]
 [0.+0.j 0.+0.j 0.+0.j 0.+0.j]
 [0.+0.j 0.+0.j 0.+0.j 0.+0.j]]
Return type:

None

set_zero_norm_state()

Set the density matrix to the 0 (zero matrix).

Examples

>>> state = DensityMatrix.uninitialized_state(2)
>>> state.set_zero_norm_state()
>>> print(state.get_matrix())
[[0.+0.j 0.+0.j 0.+0.j 0.+0.j]
 [0.+0.j 0.+0.j 0.+0.j 0.+0.j]
 [0.+0.j 0.+0.j 0.+0.j 0.+0.j]
 [0.+0.j 0.+0.j 0.+0.j 0.+0.j]]
Return type:

None

set_computational_basis(basis_index)

Set the density matrix to a computational basis state \(\ket{b}\bra{b}\) where \(b\) is the binary representation of the input basis index.

Parameters:

basis_index (int) – index of the computational basis state to set (0-based)

Return type:

None

Examples

>>> state = DensityMatrix.uninitialized_state(2)
>>> state.set_computational_basis(2) # sets state to |10><10|
>>> print(state.get_matrix())
[[0.+0.j 0.+0.j 0.+0.j 0.+0.j]
 [0.+0.j 0.+0.j 0.+0.j 0.+0.j]
 [0.+0.j 0.+0.j 1.+0.j 0.+0.j]
 [0.+0.j 0.+0.j 0.+0.j 0.+0.j]]
set_Haar_random_state(seed=None)

Set the density matrix to represent a Haar random state.

Parameters:

seed (int | None, optional) –

random seed

If not specified, the value from random device is used.

Return type:

None

Examples

>>> state = DensityMatrix(1)
>>> state.set_Haar_random_state(seed=42)
>>> print(state.get_matrix()) 
[[ 0.7662367 -2.34701458e-17j -0.35360255-2.32558070e-01j]
 [-0.35360255+2.32558070e-01j  0.2337633 -7.47914693e-19j]]
get_trace()

Calculate the trace of the density matrix.

Returns:

trace of the density matrix

Return type:

complex

Examples

>>> state = DensityMatrix(2)
>>> state.get_trace()
(1+0j)
get_partial_trace(traced_out_qubits)

Calculate the partial trace of the density matrix by tracing out the specified qubits.

Parameters:

traced_out_qubits (collections.abc.Sequence[int]) – indices of qubits to be traced out

Returns:

the resulting density matrix after partial trace

Return type:

DensityMatrix

Examples

>>> state = DensityMatrix.Haar_random_state(2)
>>> print(state.get_matrix()) 
[[ 0.51491987-2.74660016e-17j -0.23762498-1.56281696e-01j
   0.10531599+3.49755601e-01j -0.13503799+1.31271109e-01j]
 [-0.23762498+1.56281696e-01j  0.15709162+1.84452504e-20j
  -0.15475438-1.29440927e-01j  0.02247559-1.01563879e-01j]
 [ 0.10531599-3.49755601e-01j -0.15475438+1.29440927e-01j
   0.25910912-1.49078030e-18j  0.06154578+1.18572309e-01j]
 [-0.13503799-1.31271109e-01j  0.02247559+1.01563879e-01j
   0.06154578-1.18572309e-01j  0.06887938-1.44012992e-19j]]
>>> reduced_state = state.get_partial_trace([1])
>>> print(reduced_state.get_matrix()) 
[[ 0.774029  -2.89567819e-17j -0.17607919-3.77093869e-02j]
 [-0.17607919+3.77093869e-02j  0.225971  -1.25567742e-19j]]
normalize()

Normalize the density matrix so that its trace becomes 1.

Examples

>>> state = DensityMatrix(2)
>>> state.multiply_coef(2)
>>> state.normalize()
>>> print(state.get_trace())
(1+0j)
Return type:

None

get_purity()

Calculate the purity of the quantum state represented by the density matrix. Purity is defined as \(\mathrm{Tr}(\rho^2)\) where \(\rho\) is the density matrix.

Returns:

purity of the quantum state

Return type:

float

Examples

>>> state1 = DensityMatrix.Haar_random_state(2, 0)
>>> print(state1.get_purity()) 
1.0000000000000002
>>> state2 = DensityMatrix.Haar_random_state(2, 1)
>>> state1.multiply_coef(0.5)
>>> state1.add_density_matrix_with_coef(0.5, state2)
>>> print(state1.get_purity()) 
0.6238584782007198

Notes

The matrix must be hermitian and normalized

get_zero_probability(target_qubit_index)

Calculate the probability of measuring 0 on the target qubit.

Parameters:

target_qubit_index (int) – index of the target qubit

Returns:

probability of measuring 0 on the target qubit

Return type:

float

Examples

>>> state = DensityMatrix(2)
>>> state.set_computational_basis(2) # sets state to |10><10|
>>> state.get_zero_probability(0)
1.0
>>> state.get_zero_probability(1)
0.0

Notes

The matrix must be hermitian and normalized

get_marginal_probability(measured_values)

Get the marginal probability to observe as given.

Parameters:

measured_values (list[int]) –

list with len n_qubits.

0, 1 or UNMEASURED is allowed for each elements. 0 or 1 shows the qubit is observed and the value is got. UNMEASURED shows the the qubit is not observed.

Returns:

probability to observe as given

Return type:

float

Examples

>>> state = DensityMatrix(2)
>>> state.set_computational_basis(2) # sets state to |10><10|
>>> state.get_marginal_probability([0, 1])
1.0
>>> state.get_marginal_probability([0, DensityMatrix.UNMEASURED])
1.0
>>> state.get_marginal_probability([DensityMatrix.UNMEASURED, 1])
1.0
>>> state.get_marginal_probability([1, DensityMatrix.UNMEASURED])
0.0

Notes

The matrix must be hermitian and normalized

sampling(sampling_count, seed=None)

Sampling density matrix independently and get list of computational basis

Parameters:
  • sampling_count (int) – number of samples to draw

  • seed (int | None, optional) –

    random seed

    If not specified, the value from random device is used.

Returns:

list of sampled computational basis represented as integers

Return type:

List[int]

Examples

>>> import numpy as np
>>> state = DensityMatrix.uninitialized_state(1)
>>> state.load(np.array([[0.5, -0.5j], [0.5j, 0.5]]), True)
>>> print(state.sampling(10, seed=42)) 
[0, 1, 1, 0, 0, 0, 1, 0, 1, 1]

Notes

The matrix must be hermitian and normalized

get_computational_basis_entropy()

Calculate the computational basis entropy of the quantum state represented by the density matrix. Computational basis entropy is defined as \(-\sum_i p_i \log_2 p_i\) where \(p_i\) is the probability of measuring the computational basis state \(\ket{i}\), which can be calculated as the (i,i)-th element of the density matrix.

Returns:

computational basis entropy of the quantum state

Return type:

float

Examples

>>> state = DensityMatrix(2)
>>> state.set_computational_basis(2) # sets state to |10><10|
>>> state.get_computational_basis_entropy()
0.0
>>> import numpy as np
>>> state = DensityMatrix.uninitialized_state(1)
>>> state.load(np.array([[0.5, -0.5j], [0.5j, 0.5]]), True)
>>> state.get_computational_basis_entropy()
1.0

Notes

The matrix must be hermitian and normalized

add_density_matrix_with_coef(coef, other)

Add another density matrix to this density matrix with a coefficient. This performs the operation \(\rho \leftarrow \rho + c \sigma\) where \(\rho\) is this density matrix, \(c\) is the coefficient and \(\sigma\) is the other density matrix.

Parameters:
  • coef (complex) – coefficient to multiply the other density matrix

  • other (DensityMatrix) – the other density matrix to be added

Return type:

None

Examples

>>> state1 = DensityMatrix.Haar_random_state(1, 1)
>>> state2 = DensityMatrix.Haar_random_state(1, 2)
>>> print(state1.get_matrix()) 
[[ 0.51823805+2.35020398e-18j -0.20611927-4.55172737e-01j]
 [-0.20611927+4.55172737e-01j  0.48176195+2.36023838e-19j]]
>>> print(state2.get_matrix()) 
[[0.20777367+3.60776697e-18j 0.36552629-1.76051983e-01j]
 [0.36552629+1.76051983e-01j 0.79222633-1.66856281e-17j]]
>>> state1.add_density_matrix_with_coef(0.5, state2)
>>> print(state1.get_matrix()) 
[[ 0.62212489+4.15408747e-18j -0.02335612-5.43198728e-01j]
 [-0.02335612+5.43198728e-01j  0.87787511-8.10679023e-18j]]
multiply_coef(coef)

Multiply this density matrix by a coefficient. This performs the operation \(\rho \leftarrow c \rho\) where \(\rho\) is this density matrix and \(c\) is the coefficient.

Parameters:

coef (complex) – coefficient to multiply the density matrix

Return type:

None

Examples

>>> state = DensityMatrix.Haar_random_state(1, 1)
>>> print(state.get_matrix()) 
[[ 0.51823805+2.35020398e-18j -0.20611927-4.55172737e-01j]
 [-0.20611927+4.55172737e-01j  0.48176195+2.36023838e-19j]]
>>> state.multiply_coef(2)
>>> print(state.get_matrix()) 
[[ 1.0364761 +4.70040797e-18j -0.41223854-9.10345474e-01j]
 [-0.41223854+9.10345474e-01j  0.9635239 +4.72047677e-19j]]
to_string()

Convert the density matrix to a string representation.

Return type:

str

to_json()

Information as json style.

Returns:

information as json style

Return type:

str

Examples

>>> state = DensityMatrix(2)
>>> print(state.to_json())
{"is_hermitian":true,"matrix":[[{"imag":0.0,"real":1.0},{"imag":0.0,"real":0.0},{"imag":0.0,"real":0.0},{"imag":0.0,"real":0.0}],[{"imag":0.0,"real":0.0},{"imag":0.0,"real":0.0},{"imag":0.0,"real":0.0},{"imag":0.0,"real":0.0}],[{"imag":0.0,"real":0.0},{"imag":0.0,"real":0.0},{"imag":0.0,"real":0.0},{"imag":0.0,"real":0.0}],[{"imag":0.0,"real":0.0},{"imag":0.0,"real":0.0},{"imag":0.0,"real":0.0},{"imag":0.0,"real":0.0}]],"n_qubits":2}
load_json(json_str)

Read an object from the JSON representation of the density matrix.

Parameters:

json_str (str)

Return type:

None

UNMEASURED: int = Ellipsis

Constant used for DensityMatrix::get_marginal_probability to express the the qubit is not measured.

class scaluq.default.f32.SparseMatrixGate(arg)

Specific class of sparse matrix gate.

Notes

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

Parameters:

arg (SparseMatrixGate)

gate_type()

Get gate type as GateType enum.

Return type:

scaluq.scaluq_core.GateType

target_qubit_list()

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

Return type:

list[int]

control_qubit_list()

Get control qubits as list[int].

Return type:

list[int]

control_value_list()

Get control values as list[int].

Return type:

list[int]

operand_qubit_list()

Get target and control qubits as list[int].

Return type:

list[int]

target_qubit_mask()

Get target qubits as mask. Control qubits are not included.

Return type:

int

control_qubit_mask()

Get control qubits as mask.

Return type:

int

control_value_mask()

Get control values as mask.

Return type:

int

operand_qubit_mask()

Get target and control qubits as mask.

Return type:

int

get_inverse()

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

Return type:

object

get_matrix()

Get matrix representation of the gate. Note: The matrix is constructed by reordering target qubits in ascending order of their indices. The qubit with the smaller index is treated as the first target, and the larger as the second.

Return type:

Annotated[numpy.typing.NDArray[numpy.complex128], dict(shape=(None, None), order=’C’)]

to_string()

Get string representation of the gate.

Return type:

str

to_json()

Get JSON representation of the gate.

Return type:

str

load_json(json_str)

Read an object from the JSON representation of the gate.

Parameters:

json_str (str)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

class scaluq.default.f32.DenseMatrixGate(arg)

Specific class of dense matrix gate.

Notes

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

Parameters:

arg (DenseMatrixGate)

gate_type()

Get gate type as GateType enum.

Return type:

scaluq.scaluq_core.GateType

target_qubit_list()

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

Return type:

list[int]

control_qubit_list()

Get control qubits as list[int].

Return type:

list[int]

control_value_list()

Get control values as list[int].

Return type:

list[int]

operand_qubit_list()

Get target and control qubits as list[int].

Return type:

list[int]

target_qubit_mask()

Get target qubits as mask. Control qubits are not included.

Return type:

int

control_qubit_mask()

Get control qubits as mask.

Return type:

int

control_value_mask()

Get control values as mask.

Return type:

int

operand_qubit_mask()

Get target and control qubits as mask.

Return type:

int

get_inverse()

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

Return type:

object

get_matrix()

Get matrix representation of the gate. Note: The matrix is constructed by reordering target qubits in ascending order of their indices. The qubit with the smaller index is treated as the first target, and the larger as the second.

Return type:

Annotated[numpy.typing.NDArray[numpy.complex128], dict(shape=(None, None), order=’C’)]

to_string()

Get string representation of the gate.

Return type:

str

to_json()

Get JSON representation of the gate.

Return type:

str

load_json(json_str)

Read an object from the JSON representation of the gate.

Parameters:

json_str (str)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

scaluq.default.f32.merge_gate(arg0, arg1, /)

Merge two gates. return value is (merged gate, global phase).

Parameters:
Return type:

tuple[Gate, float]

class scaluq.default.f32.Operator(n_terms)

General quantum operator class.

Given qubit_count: int, Initialize operator with specified number of qubits.

Examples

>>> terms = [PauliOperator("X 0 Y 2"), PauliOperator("Z 1 X 3", 2j)]
>>> op = Operator(terms)
>>> pauli = PauliOperator("X 1", -1j)
>>> op *= pauli
>>> print(op.to_json())
{"terms":[{"coef":{"imag":-1.0,"real":0.0},"pauli_string":"X 0 X 1 Y 2"},{"coef":{"imag":2.0,"real":0.0},"pauli_string":"Y 1 X 3"}]}
Parameters:

n_terms (int)

class GroundState

Structure to hold the ground state information.

property eigenvalue: complex
Return type:

complex

property state: StateVector
Return type:

StateVector

is_hermitian()

Check if the operator is Hermitian.

Return type:

bool

load(terms)

Load the operator with a list of Pauli operators.

Parameters:

terms (collections.abc.Sequence[PauliOperator])

Return type:

None

static uninitialized_operator(n_terms)

Create an uninitialized operator with a specified number of terms.

Parameters:

n_terms (int)

Return type:

Operator

n_terms()

Get the number of terms in the operator.

Return type:

int

get_terms()

Get the list of Pauli terms that make up the operator.

Return type:

list[PauliOperator]

to_string()

Get string representation of the operator.

Return type:

str

to_string()
Return type:

str

optimize()

Optimize the operator by combining like terms.

Return type:

None

get_dagger()

Get the adjoint (Hermitian conjugate) of the operator.

Return type:

Operator

apply_to_state(state)

Apply the operator to a state vector.

Parameters:

state (StateVector)

Return type:

None

get_expectation_value(state)

Get the expectation value of the operator with respect to a state vector.

Parameters:

states (StateVectorBatched)

Return type:

list[complex]

get_expectation_value(states)

Get the expectation values of the operator for a batch of state vectors.

Parameters:

states (StateVectorBatched)

Return type:

list[complex]

get_expectation_values(state)

Get the expectation values of the pauli operators with respect to a state vector.

Parameters:

state (StateVector)

Return type:

list[complex]

get_transition_amplitude(source, target)

Get the transition amplitude of the operator between two state vectors.

Parameters:
Return type:

list[complex]

get_transition_amplitude(states_source, states_target)

Get the transition amplitudes of the operator for a batch of state vectors.

Parameters:
Return type:

list[complex]

get_matrix(arg, /)

Get matrix representation of the Operator. Tensor product is applied from n_qubits-1 to 0.

Parameters:

arg (int)

Return type:

Annotated[numpy.typing.NDArray[numpy.complex128], dict(shape=(None, None), order=’C’)]

solve_ground_state_by_power_method(initial_state, iter_count, mu=None)

Solve for the ground state using the power method.

Parameters:
  • initial_state (StateVector) – Initial state vector for the iteration. Passing Haar_random_state is often nice.

  • iter_count (int) – Number of iterations to perform.

  • mu (complex, optional) – Shift value to accelerate convergence. The value must be larger than largest eigenvalue. If not provided, a default value is calculated internally.

Returns:

The ground state information including eigenvalue and ground state vector.

Return type:

Operator.GroundState

Examples

>>> terms = [PauliOperator("", -3.8505), PauliOperator("X 1", -0.2288), PauliOperator("Z 1", -1.0466), PauliOperator("X 0", -0.2288), PauliOperator("X 0 X 1", 0.2613), PauliOperator("X 0 Z 1", 0.2288), PauliOperator("Z 0", -1.0466), PauliOperator("Z 0 X 1", 0.2288), PauliOperator("Z 0 Z 1", 0.2356)]
>>> op = Operator(terms)
>>> op *= .5
>>> ground_state = op.solve_ground_state_by_power_method(StateVector.Haar_random_state(2, seed=0), 200)
>>> ground_state.eigenvalue.real 
-2.862620764...
>>> print(ground_state.state.get_amplitudes()) 
[(0.593378420...-0.801949191...j), (-0.00937288681...+0.0126674290...j), (-0.00937288706...+0.0126674292...j), (-0.0389261878...+0.0526086285...j)]
solve_ground_state_by_arnoldi_method(initial_state, iter_count, mu=None)

Solve for the ground state using the Arnoldi method.

Parameters:
  • initial_state (StateVector) – Initial state vector for the iteration. Passing Haar_random_state is often nice.

  • iter_count (int) – Number of iterations to perform. Too large value causes error on calculating eigenvalue of Hessenberg matrix.

  • mu (complex, optional) – Shift value to accelerate convergence. The value must be larger than largest eigenvalue. If not provided, a default value is calculated internally.

Returns:

The ground state information including eigenvalue and ground state vector.

Return type:

Operator.GroundState

Examples

>>> terms = [PauliOperator("", -3.8505), PauliOperator("X 1", -0.2288), PauliOperator("Z 1", -1.0466), PauliOperator("X 0", -0.2288), PauliOperator("X 0 X 1", 0.2613), PauliOperator("X 0 Z 1", 0.2288), PauliOperator("Z 0", -1.0466), PauliOperator("Z 0 X 1", 0.2288), PauliOperator("Z 0 Z 1", 0.2356)]
>>> op = Operator(terms)
>>> op *= .5
>>> ground_state = op.solve_ground_state_by_arnoldi_method(StateVector.Haar_random_state(2, seed=0), 40)
>>> ground_state.eigenvalue.real 
-2.862620764...
>>> ground_state.state.get_amplitudes() 
[(0.593378420...-0.801949191...j), (-0.00937288693...+0.0126674291...j), (-0.00937288693...+0.0126674291...j), (-0.0389261878...+0.0526086285...j)]

Notes

This works even if it is not Hermitian. An eigenvalue with the smallest real part is returned as the ground state.

calculate_default_mu()

Calculate a default shift value mu for ground state solvers.

Returns:

Calculated shift value mu.

Return type:

complex

copy_to_default_space()

Return a deep copy in the default execution space.

Return type:

Operator

copy_to_host_space()

Return a deep copy in the host execution space.

Return type:

Operator

to_json()

Information as json style.

Return type:

str

load_json(json_str)

Read an object from the JSON representation of the operator.

Parameters:

json_str (str)

Return type:

None

class scaluq.default.f32.OperatorBatched

General quantum operator class for batched operators.

copy()

Return a copy.

Return type:

OperatorBatched

load(terms)

Load a vector of Pauli operators.

Parameters:

terms (A vector of Pauli operators.)

Return type:

None

load(terms)

Load a vector of Operators.

Parameters:

terms (A vector of Operators.)

Return type:

None

to_string()

Return a string representation of the operator.

Return type:

str

to_string()

Get string representation of the OperatorBatched.

Return type:

str

batch_size()

Return the batch size of the operator.

Return type:

int

get_dagger()

Return the Hermitian conjugate of the operator.

Return type:

OperatorBatched

get_applied_states(state_vector, batch_size=1)

Apply the batched operator to a state vector.

Parameters:
  • state_vector (A state vector to be applied.)

  • batch_size (In the update process, the batch size to be processed simultaneously.)

Return type:

StateVectorBatched

get_expectation_value(state_vector)

Return a vector of expectation values for each operator.

Parameters:

state_vector (A state vector to compute expectation values.)

Return type:

list[complex]

get_transition_amplitude(state_vector_bra, state_vector_ket)

Return a vector of transition amplitudes for each operator.

Parameters:
  • state_vector_bra (A bra state vector.)

  • state_vector_ket (A ket state vector.)

Return type:

list[complex]

get_operator_at(index)

Return the operator at the specified index.

Parameters:

index (Index of the operator.)

Return type:

Operator

view_operator_at(index)

Return a view of the operator at the specified index.

Parameters:

index (Index of the operator.)

Return type:

Operator

get_operators()

Return a vector of all operators.

Return type:

list[Operator]

copy_to_default_space()

Return a deep copy in the default execution space.

Return type:

OperatorBatched

copy_to_host_space()

Return a deep copy in the host execution space.

Return type:

OperatorBatched

to_json()

Information as json style.

Return type:

str

load_json(json_str)

Read an object from the JSON representation of the OperatorBatched.

Parameters:

json_str (str)

Return type:

None

class scaluq.default.f32.IGate(arg)

Specific class of I gate.

Notes

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

Parameters:

arg (IGate)

gate_type()

Get gate type as GateType enum.

Return type:

scaluq.scaluq_core.GateType

target_qubit_list()

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

Return type:

list[int]

control_qubit_list()

Get control qubits as list[int].

Return type:

list[int]

control_value_list()

Get control values as list[int].

Return type:

list[int]

operand_qubit_list()

Get target and control qubits as list[int].

Return type:

list[int]

target_qubit_mask()

Get target qubits as mask. Control qubits are not included.

Return type:

int

control_qubit_mask()

Get control qubits as mask.

Return type:

int

control_value_mask()

Get control values as mask.

Return type:

int

operand_qubit_mask()

Get target and control qubits as mask.

Return type:

int

get_inverse()

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

Return type:

object

get_matrix()

Get matrix representation of the gate. Note: The matrix is constructed by reordering target qubits in ascending order of their indices. The qubit with the smaller index is treated as the first target, and the larger as the second.

Return type:

Annotated[numpy.typing.NDArray[numpy.complex128], dict(shape=(None, None), order=’C’)]

to_string()

Get string representation of the gate.

Return type:

str

to_json()

Get JSON representation of the gate.

Return type:

str

load_json(json_str)

Read an object from the JSON representation of the gate.

Parameters:

json_str (str)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

class scaluq.default.f32.GlobalPhaseGate(arg)

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

Notes

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

Parameters:

arg (GlobalPhaseGate)

gate_type()

Get gate type as GateType enum.

Return type:

scaluq.scaluq_core.GateType

target_qubit_list()

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

Return type:

list[int]

control_qubit_list()

Get control qubits as list[int].

Return type:

list[int]

control_value_list()

Get control values as list[int].

Return type:

list[int]

operand_qubit_list()

Get target and control qubits as list[int].

Return type:

list[int]

target_qubit_mask()

Get target qubits as mask. Control qubits are not included.

Return type:

int

control_qubit_mask()

Get control qubits as mask.

Return type:

int

control_value_mask()

Get control values as mask.

Return type:

int

operand_qubit_mask()

Get target and control qubits as mask.

Return type:

int

get_inverse()

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

Return type:

object

get_matrix()

Get matrix representation of the gate. Note: The matrix is constructed by reordering target qubits in ascending order of their indices. The qubit with the smaller index is treated as the first target, and the larger as the second.

Return type:

Annotated[numpy.typing.NDArray[numpy.complex128], dict(shape=(None, None), order=’C’)]

to_string()

Get string representation of the gate.

Return type:

str

to_json()

Get JSON representation of the gate.

Return type:

str

load_json(json_str)

Read an object from the JSON representation of the gate.

Parameters:

json_str (str)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

class scaluq.default.f32.XGate(arg)

Specific class of Pauli-X gate.

Notes

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

Parameters:

arg (XGate)

gate_type()

Get gate type as GateType enum.

Return type:

scaluq.scaluq_core.GateType

target_qubit_list()

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

Return type:

list[int]

control_qubit_list()

Get control qubits as list[int].

Return type:

list[int]

control_value_list()

Get control values as list[int].

Return type:

list[int]

operand_qubit_list()

Get target and control qubits as list[int].

Return type:

list[int]

target_qubit_mask()

Get target qubits as mask. Control qubits are not included.

Return type:

int

control_qubit_mask()

Get control qubits as mask.

Return type:

int

control_value_mask()

Get control values as mask.

Return type:

int

operand_qubit_mask()

Get target and control qubits as mask.

Return type:

int

get_inverse()

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

Return type:

object

get_matrix()

Get matrix representation of the gate. Note: The matrix is constructed by reordering target qubits in ascending order of their indices. The qubit with the smaller index is treated as the first target, and the larger as the second.

Return type:

Annotated[numpy.typing.NDArray[numpy.complex128], dict(shape=(None, None), order=’C’)]

to_string()

Get string representation of the gate.

Return type:

str

to_json()

Get JSON representation of the gate.

Return type:

str

load_json(json_str)

Read an object from the JSON representation of the gate.

Parameters:

json_str (str)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

class scaluq.default.f32.YGate(arg)

Specific class of Pauli-Y gate.

Notes

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

Parameters:

arg (YGate)

gate_type()

Get gate type as GateType enum.

Return type:

scaluq.scaluq_core.GateType

target_qubit_list()

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

Return type:

list[int]

control_qubit_list()

Get control qubits as list[int].

Return type:

list[int]

control_value_list()

Get control values as list[int].

Return type:

list[int]

operand_qubit_list()

Get target and control qubits as list[int].

Return type:

list[int]

target_qubit_mask()

Get target qubits as mask. Control qubits are not included.

Return type:

int

control_qubit_mask()

Get control qubits as mask.

Return type:

int

control_value_mask()

Get control values as mask.

Return type:

int

operand_qubit_mask()

Get target and control qubits as mask.

Return type:

int

get_inverse()

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

Return type:

object

get_matrix()

Get matrix representation of the gate. Note: The matrix is constructed by reordering target qubits in ascending order of their indices. The qubit with the smaller index is treated as the first target, and the larger as the second.

Return type:

Annotated[numpy.typing.NDArray[numpy.complex128], dict(shape=(None, None), order=’C’)]

to_string()

Get string representation of the gate.

Return type:

str

to_json()

Get JSON representation of the gate.

Return type:

str

load_json(json_str)

Read an object from the JSON representation of the gate.

Parameters:

json_str (str)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

class scaluq.default.f32.ZGate(arg)

Specific class of Pauli-Z gate.

Notes

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

Parameters:

arg (ZGate)

gate_type()

Get gate type as GateType enum.

Return type:

scaluq.scaluq_core.GateType

target_qubit_list()

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

Return type:

list[int]

control_qubit_list()

Get control qubits as list[int].

Return type:

list[int]

control_value_list()

Get control values as list[int].

Return type:

list[int]

operand_qubit_list()

Get target and control qubits as list[int].

Return type:

list[int]

target_qubit_mask()

Get target qubits as mask. Control qubits are not included.

Return type:

int

control_qubit_mask()

Get control qubits as mask.

Return type:

int

control_value_mask()

Get control values as mask.

Return type:

int

operand_qubit_mask()

Get target and control qubits as mask.

Return type:

int

get_inverse()

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

Return type:

object

get_matrix()

Get matrix representation of the gate. Note: The matrix is constructed by reordering target qubits in ascending order of their indices. The qubit with the smaller index is treated as the first target, and the larger as the second.

Return type:

Annotated[numpy.typing.NDArray[numpy.complex128], dict(shape=(None, None), order=’C’)]

to_string()

Get string representation of the gate.

Return type:

str

to_json()

Get JSON representation of the gate.

Return type:

str

load_json(json_str)

Read an object from the JSON representation of the gate.

Parameters:

json_str (str)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

class scaluq.default.f32.HGate(arg)

Specific class of Hadamard gate.

Notes

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

Parameters:

arg (HGate)

gate_type()

Get gate type as GateType enum.

Return type:

scaluq.scaluq_core.GateType

target_qubit_list()

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

Return type:

list[int]

control_qubit_list()

Get control qubits as list[int].

Return type:

list[int]

control_value_list()

Get control values as list[int].

Return type:

list[int]

operand_qubit_list()

Get target and control qubits as list[int].

Return type:

list[int]

target_qubit_mask()

Get target qubits as mask. Control qubits are not included.

Return type:

int

control_qubit_mask()

Get control qubits as mask.

Return type:

int

control_value_mask()

Get control values as mask.

Return type:

int

operand_qubit_mask()

Get target and control qubits as mask.

Return type:

int

get_inverse()

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

Return type:

object

get_matrix()

Get matrix representation of the gate. Note: The matrix is constructed by reordering target qubits in ascending order of their indices. The qubit with the smaller index is treated as the first target, and the larger as the second.

Return type:

Annotated[numpy.typing.NDArray[numpy.complex128], dict(shape=(None, None), order=’C’)]

to_string()

Get string representation of the gate.

Return type:

str

to_json()

Get JSON representation of the gate.

Return type:

str

load_json(json_str)

Read an object from the JSON representation of the gate.

Parameters:

json_str (str)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

class scaluq.default.f32.SGate(arg)

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

Notes

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

Parameters:

arg (SGate)

gate_type()

Get gate type as GateType enum.

Return type:

scaluq.scaluq_core.GateType

target_qubit_list()

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

Return type:

list[int]

control_qubit_list()

Get control qubits as list[int].

Return type:

list[int]

control_value_list()

Get control values as list[int].

Return type:

list[int]

operand_qubit_list()

Get target and control qubits as list[int].

Return type:

list[int]

target_qubit_mask()

Get target qubits as mask. Control qubits are not included.

Return type:

int

control_qubit_mask()

Get control qubits as mask.

Return type:

int

control_value_mask()

Get control values as mask.

Return type:

int

operand_qubit_mask()

Get target and control qubits as mask.

Return type:

int

get_inverse()

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

Return type:

object

get_matrix()

Get matrix representation of the gate. Note: The matrix is constructed by reordering target qubits in ascending order of their indices. The qubit with the smaller index is treated as the first target, and the larger as the second.

Return type:

Annotated[numpy.typing.NDArray[numpy.complex128], dict(shape=(None, None), order=’C’)]

to_string()

Get string representation of the gate.

Return type:

str

to_json()

Get JSON representation of the gate.

Return type:

str

load_json(json_str)

Read an object from the JSON representation of the gate.

Parameters:

json_str (str)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

class scaluq.default.f32.SdagGate(arg)

Specific class of inverse of S gate.

Notes

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

Parameters:

arg (SdagGate)

gate_type()

Get gate type as GateType enum.

Return type:

scaluq.scaluq_core.GateType

target_qubit_list()

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

Return type:

list[int]

control_qubit_list()

Get control qubits as list[int].

Return type:

list[int]

control_value_list()

Get control values as list[int].

Return type:

list[int]

operand_qubit_list()

Get target and control qubits as list[int].

Return type:

list[int]

target_qubit_mask()

Get target qubits as mask. Control qubits are not included.

Return type:

int

control_qubit_mask()

Get control qubits as mask.

Return type:

int

control_value_mask()

Get control values as mask.

Return type:

int

operand_qubit_mask()

Get target and control qubits as mask.

Return type:

int

get_inverse()

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

Return type:

object

get_matrix()

Get matrix representation of the gate. Note: The matrix is constructed by reordering target qubits in ascending order of their indices. The qubit with the smaller index is treated as the first target, and the larger as the second.

Return type:

Annotated[numpy.typing.NDArray[numpy.complex128], dict(shape=(None, None), order=’C’)]

to_string()

Get string representation of the gate.

Return type:

str

to_json()

Get JSON representation of the gate.

Return type:

str

load_json(json_str)

Read an object from the JSON representation of the gate.

Parameters:

json_str (str)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

class scaluq.default.f32.TGate(arg)

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

Notes

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

Parameters:

arg (TGate)

gate_type()

Get gate type as GateType enum.

Return type:

scaluq.scaluq_core.GateType

target_qubit_list()

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

Return type:

list[int]

control_qubit_list()

Get control qubits as list[int].

Return type:

list[int]

control_value_list()

Get control values as list[int].

Return type:

list[int]

operand_qubit_list()

Get target and control qubits as list[int].

Return type:

list[int]

target_qubit_mask()

Get target qubits as mask. Control qubits are not included.

Return type:

int

control_qubit_mask()

Get control qubits as mask.

Return type:

int

control_value_mask()

Get control values as mask.

Return type:

int

operand_qubit_mask()

Get target and control qubits as mask.

Return type:

int

get_inverse()

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

Return type:

object

get_matrix()

Get matrix representation of the gate. Note: The matrix is constructed by reordering target qubits in ascending order of their indices. The qubit with the smaller index is treated as the first target, and the larger as the second.

Return type:

Annotated[numpy.typing.NDArray[numpy.complex128], dict(shape=(None, None), order=’C’)]

to_string()

Get string representation of the gate.

Return type:

str

to_json()

Get JSON representation of the gate.

Return type:

str

load_json(json_str)

Read an object from the JSON representation of the gate.

Parameters:

json_str (str)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

class scaluq.default.f32.TdagGate(arg)

Specific class of inverse of T gate.

Notes

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

Parameters:

arg (TdagGate)

gate_type()

Get gate type as GateType enum.

Return type:

scaluq.scaluq_core.GateType

target_qubit_list()

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

Return type:

list[int]

control_qubit_list()

Get control qubits as list[int].

Return type:

list[int]

control_value_list()

Get control values as list[int].

Return type:

list[int]

operand_qubit_list()

Get target and control qubits as list[int].

Return type:

list[int]

target_qubit_mask()

Get target qubits as mask. Control qubits are not included.

Return type:

int

control_qubit_mask()

Get control qubits as mask.

Return type:

int

control_value_mask()

Get control values as mask.

Return type:

int

operand_qubit_mask()

Get target and control qubits as mask.

Return type:

int

get_inverse()

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

Return type:

object

get_matrix()

Get matrix representation of the gate. Note: The matrix is constructed by reordering target qubits in ascending order of their indices. The qubit with the smaller index is treated as the first target, and the larger as the second.

Return type:

Annotated[numpy.typing.NDArray[numpy.complex128], dict(shape=(None, None), order=’C’)]

to_string()

Get string representation of the gate.

Return type:

str

to_json()

Get JSON representation of the gate.

Return type:

str

load_json(json_str)

Read an object from the JSON representation of the gate.

Parameters:

json_str (str)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

class scaluq.default.f32.SqrtXGate(arg)

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

Notes

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

Parameters:

arg (SqrtXGate)

gate_type()

Get gate type as GateType enum.

Return type:

scaluq.scaluq_core.GateType

target_qubit_list()

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

Return type:

list[int]

control_qubit_list()

Get control qubits as list[int].

Return type:

list[int]

control_value_list()

Get control values as list[int].

Return type:

list[int]

operand_qubit_list()

Get target and control qubits as list[int].

Return type:

list[int]

target_qubit_mask()

Get target qubits as mask. Control qubits are not included.

Return type:

int

control_qubit_mask()

Get control qubits as mask.

Return type:

int

control_value_mask()

Get control values as mask.

Return type:

int

operand_qubit_mask()

Get target and control qubits as mask.

Return type:

int

get_inverse()

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

Return type:

object

get_matrix()

Get matrix representation of the gate. Note: The matrix is constructed by reordering target qubits in ascending order of their indices. The qubit with the smaller index is treated as the first target, and the larger as the second.

Return type:

Annotated[numpy.typing.NDArray[numpy.complex128], dict(shape=(None, None), order=’C’)]

to_string()

Get string representation of the gate.

Return type:

str

to_json()

Get JSON representation of the gate.

Return type:

str

load_json(json_str)

Read an object from the JSON representation of the gate.

Parameters:

json_str (str)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

class scaluq.default.f32.SqrtXdagGate(arg)

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

Notes

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

Parameters:

arg (SqrtXdagGate)

gate_type()

Get gate type as GateType enum.

Return type:

scaluq.scaluq_core.GateType

target_qubit_list()

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

Return type:

list[int]

control_qubit_list()

Get control qubits as list[int].

Return type:

list[int]

control_value_list()

Get control values as list[int].

Return type:

list[int]

operand_qubit_list()

Get target and control qubits as list[int].

Return type:

list[int]

target_qubit_mask()

Get target qubits as mask. Control qubits are not included.

Return type:

int

control_qubit_mask()

Get control qubits as mask.

Return type:

int

control_value_mask()

Get control values as mask.

Return type:

int

operand_qubit_mask()

Get target and control qubits as mask.

Return type:

int

get_inverse()

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

Return type:

object

get_matrix()

Get matrix representation of the gate. Note: The matrix is constructed by reordering target qubits in ascending order of their indices. The qubit with the smaller index is treated as the first target, and the larger as the second.

Return type:

Annotated[numpy.typing.NDArray[numpy.complex128], dict(shape=(None, None), order=’C’)]

to_string()

Get string representation of the gate.

Return type:

str

to_json()

Get JSON representation of the gate.

Return type:

str

load_json(json_str)

Read an object from the JSON representation of the gate.

Parameters:

json_str (str)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

class scaluq.default.f32.SqrtYGate(arg)

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

Notes

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

Parameters:

arg (SqrtYGate)

gate_type()

Get gate type as GateType enum.

Return type:

scaluq.scaluq_core.GateType

target_qubit_list()

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

Return type:

list[int]

control_qubit_list()

Get control qubits as list[int].

Return type:

list[int]

control_value_list()

Get control values as list[int].

Return type:

list[int]

operand_qubit_list()

Get target and control qubits as list[int].

Return type:

list[int]

target_qubit_mask()

Get target qubits as mask. Control qubits are not included.

Return type:

int

control_qubit_mask()

Get control qubits as mask.

Return type:

int

control_value_mask()

Get control values as mask.

Return type:

int

operand_qubit_mask()

Get target and control qubits as mask.

Return type:

int

get_inverse()

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

Return type:

object

get_matrix()

Get matrix representation of the gate. Note: The matrix is constructed by reordering target qubits in ascending order of their indices. The qubit with the smaller index is treated as the first target, and the larger as the second.

Return type:

Annotated[numpy.typing.NDArray[numpy.complex128], dict(shape=(None, None), order=’C’)]

to_string()

Get string representation of the gate.

Return type:

str

to_json()

Get JSON representation of the gate.

Return type:

str

load_json(json_str)

Read an object from the JSON representation of the gate.

Parameters:

json_str (str)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

class scaluq.default.f32.SqrtYdagGate(arg)

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

Notes

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

Parameters:

arg (SqrtYdagGate)

gate_type()

Get gate type as GateType enum.

Return type:

scaluq.scaluq_core.GateType

target_qubit_list()

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

Return type:

list[int]

control_qubit_list()

Get control qubits as list[int].

Return type:

list[int]

control_value_list()

Get control values as list[int].

Return type:

list[int]

operand_qubit_list()

Get target and control qubits as list[int].

Return type:

list[int]

target_qubit_mask()

Get target qubits as mask. Control qubits are not included.

Return type:

int

control_qubit_mask()

Get control qubits as mask.

Return type:

int

control_value_mask()

Get control values as mask.

Return type:

int

operand_qubit_mask()

Get target and control qubits as mask.

Return type:

int

get_inverse()

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

Return type:

object

get_matrix()

Get matrix representation of the gate. Note: The matrix is constructed by reordering target qubits in ascending order of their indices. The qubit with the smaller index is treated as the first target, and the larger as the second.

Return type:

Annotated[numpy.typing.NDArray[numpy.complex128], dict(shape=(None, None), order=’C’)]

to_string()

Get string representation of the gate.

Return type:

str

to_json()

Get JSON representation of the gate.

Return type:

str

load_json(json_str)

Read an object from the JSON representation of the gate.

Parameters:

json_str (str)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

class scaluq.default.f32.P0Gate(arg)

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

Notes

This gate is not unitary.

Notes

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

Parameters:

arg (P0Gate)

gate_type()

Get gate type as GateType enum.

Return type:

scaluq.scaluq_core.GateType

target_qubit_list()

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

Return type:

list[int]

control_qubit_list()

Get control qubits as list[int].

Return type:

list[int]

control_value_list()

Get control values as list[int].

Return type:

list[int]

operand_qubit_list()

Get target and control qubits as list[int].

Return type:

list[int]

target_qubit_mask()

Get target qubits as mask. Control qubits are not included.

Return type:

int

control_qubit_mask()

Get control qubits as mask.

Return type:

int

control_value_mask()

Get control values as mask.

Return type:

int

operand_qubit_mask()

Get target and control qubits as mask.

Return type:

int

get_inverse()

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

Return type:

object

get_matrix()

Get matrix representation of the gate. Note: The matrix is constructed by reordering target qubits in ascending order of their indices. The qubit with the smaller index is treated as the first target, and the larger as the second.

Return type:

Annotated[numpy.typing.NDArray[numpy.complex128], dict(shape=(None, None), order=’C’)]

to_string()

Get string representation of the gate.

Return type:

str

to_json()

Get JSON representation of the gate.

Return type:

str

load_json(json_str)

Read an object from the JSON representation of the gate.

Parameters:

json_str (str)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

class scaluq.default.f32.P1Gate(arg)

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

Notes

This gate is not unitary.

Notes

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

Parameters:

arg (P1Gate)

gate_type()

Get gate type as GateType enum.

Return type:

scaluq.scaluq_core.GateType

target_qubit_list()

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

Return type:

list[int]

control_qubit_list()

Get control qubits as list[int].

Return type:

list[int]

control_value_list()

Get control values as list[int].

Return type:

list[int]

operand_qubit_list()

Get target and control qubits as list[int].

Return type:

list[int]

target_qubit_mask()

Get target qubits as mask. Control qubits are not included.

Return type:

int

control_qubit_mask()

Get control qubits as mask.

Return type:

int

control_value_mask()

Get control values as mask.

Return type:

int

operand_qubit_mask()

Get target and control qubits as mask.

Return type:

int

get_inverse()

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

Return type:

object

get_matrix()

Get matrix representation of the gate. Note: The matrix is constructed by reordering target qubits in ascending order of their indices. The qubit with the smaller index is treated as the first target, and the larger as the second.

Return type:

Annotated[numpy.typing.NDArray[numpy.complex128], dict(shape=(None, None), order=’C’)]

to_string()

Get string representation of the gate.

Return type:

str

to_json()

Get JSON representation of the gate.

Return type:

str

load_json(json_str)

Read an object from the JSON representation of the gate.

Parameters:

json_str (str)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

class scaluq.default.f32.RXGate(arg)

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

Notes

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

Parameters:

arg (RXGate)

gate_type()

Get gate type as GateType enum.

Return type:

scaluq.scaluq_core.GateType

target_qubit_list()

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

Return type:

list[int]

control_qubit_list()

Get control qubits as list[int].

Return type:

list[int]

control_value_list()

Get control values as list[int].

Return type:

list[int]

operand_qubit_list()

Get target and control qubits as list[int].

Return type:

list[int]

target_qubit_mask()

Get target qubits as mask. Control qubits are not included.

Return type:

int

control_qubit_mask()

Get control qubits as mask.

Return type:

int

control_value_mask()

Get control values as mask.

Return type:

int

operand_qubit_mask()

Get target and control qubits as mask.

Return type:

int

get_inverse()

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

Return type:

object

get_matrix()

Get matrix representation of the gate. Note: The matrix is constructed by reordering target qubits in ascending order of their indices. The qubit with the smaller index is treated as the first target, and the larger as the second.

Return type:

Annotated[numpy.typing.NDArray[numpy.complex128], dict(shape=(None, None), order=’C’)]

to_string()

Get string representation of the gate.

Return type:

str

to_json()

Get JSON representation of the gate.

Return type:

str

load_json(json_str)

Read an object from the JSON representation of the gate.

Parameters:

json_str (str)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

angle()

Get angle property.

Return type:

float

class scaluq.default.f32.RYGate(arg)

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

Notes

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

Parameters:

arg (RYGate)

gate_type()

Get gate type as GateType enum.

Return type:

scaluq.scaluq_core.GateType

target_qubit_list()

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

Return type:

list[int]

control_qubit_list()

Get control qubits as list[int].

Return type:

list[int]

control_value_list()

Get control values as list[int].

Return type:

list[int]

operand_qubit_list()

Get target and control qubits as list[int].

Return type:

list[int]

target_qubit_mask()

Get target qubits as mask. Control qubits are not included.

Return type:

int

control_qubit_mask()

Get control qubits as mask.

Return type:

int

control_value_mask()

Get control values as mask.

Return type:

int

operand_qubit_mask()

Get target and control qubits as mask.

Return type:

int

get_inverse()

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

Return type:

object

get_matrix()

Get matrix representation of the gate. Note: The matrix is constructed by reordering target qubits in ascending order of their indices. The qubit with the smaller index is treated as the first target, and the larger as the second.

Return type:

Annotated[numpy.typing.NDArray[numpy.complex128], dict(shape=(None, None), order=’C’)]

to_string()

Get string representation of the gate.

Return type:

str

to_json()

Get JSON representation of the gate.

Return type:

str

load_json(json_str)

Read an object from the JSON representation of the gate.

Parameters:

json_str (str)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

angle()

Get angle property.

Return type:

float

class scaluq.default.f32.RZGate(arg)

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

Notes

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

Parameters:

arg (RZGate)

gate_type()

Get gate type as GateType enum.

Return type:

scaluq.scaluq_core.GateType

target_qubit_list()

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

Return type:

list[int]

control_qubit_list()

Get control qubits as list[int].

Return type:

list[int]

control_value_list()

Get control values as list[int].

Return type:

list[int]

operand_qubit_list()

Get target and control qubits as list[int].

Return type:

list[int]

target_qubit_mask()

Get target qubits as mask. Control qubits are not included.

Return type:

int

control_qubit_mask()

Get control qubits as mask.

Return type:

int

control_value_mask()

Get control values as mask.

Return type:

int

operand_qubit_mask()

Get target and control qubits as mask.

Return type:

int

get_inverse()

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

Return type:

object

get_matrix()

Get matrix representation of the gate. Note: The matrix is constructed by reordering target qubits in ascending order of their indices. The qubit with the smaller index is treated as the first target, and the larger as the second.

Return type:

Annotated[numpy.typing.NDArray[numpy.complex128], dict(shape=(None, None), order=’C’)]

to_string()

Get string representation of the gate.

Return type:

str

to_json()

Get JSON representation of the gate.

Return type:

str

load_json(json_str)

Read an object from the JSON representation of the gate.

Parameters:

json_str (str)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

angle()

Get angle property.

Return type:

float

class scaluq.default.f32.U1Gate(arg)

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

Notes

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

Parameters:

arg (U1Gate)

gate_type()

Get gate type as GateType enum.

Return type:

scaluq.scaluq_core.GateType

target_qubit_list()

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

Return type:

list[int]

control_qubit_list()

Get control qubits as list[int].

Return type:

list[int]

control_value_list()

Get control values as list[int].

Return type:

list[int]

operand_qubit_list()

Get target and control qubits as list[int].

Return type:

list[int]

target_qubit_mask()

Get target qubits as mask. Control qubits are not included.

Return type:

int

control_qubit_mask()

Get control qubits as mask.

Return type:

int

control_value_mask()

Get control values as mask.

Return type:

int

operand_qubit_mask()

Get target and control qubits as mask.

Return type:

int

get_inverse()

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

Return type:

object

get_matrix()

Get matrix representation of the gate. Note: The matrix is constructed by reordering target qubits in ascending order of their indices. The qubit with the smaller index is treated as the first target, and the larger as the second.

Return type:

Annotated[numpy.typing.NDArray[numpy.complex128], dict(shape=(None, None), order=’C’)]

to_string()

Get string representation of the gate.

Return type:

str

to_json()

Get JSON representation of the gate.

Return type:

str

load_json(json_str)

Read an object from the JSON representation of the gate.

Parameters:

json_str (str)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

class scaluq.default.f32.U2Gate(arg)

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}\).

Notes

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

Parameters:

arg (U2Gate)

gate_type()

Get gate type as GateType enum.

Return type:

scaluq.scaluq_core.GateType

target_qubit_list()

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

Return type:

list[int]

control_qubit_list()

Get control qubits as list[int].

Return type:

list[int]

control_value_list()

Get control values as list[int].

Return type:

list[int]

operand_qubit_list()

Get target and control qubits as list[int].

Return type:

list[int]

target_qubit_mask()

Get target qubits as mask. Control qubits are not included.

Return type:

int

control_qubit_mask()

Get control qubits as mask.

Return type:

int

control_value_mask()

Get control values as mask.

Return type:

int

operand_qubit_mask()

Get target and control qubits as mask.

Return type:

int

get_inverse()

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

Return type:

object

get_matrix()

Get matrix representation of the gate. Note: The matrix is constructed by reordering target qubits in ascending order of their indices. The qubit with the smaller index is treated as the first target, and the larger as the second.

Return type:

Annotated[numpy.typing.NDArray[numpy.complex128], dict(shape=(None, None), order=’C’)]

to_string()

Get string representation of the gate.

Return type:

str

to_json()

Get JSON representation of the gate.

Return type:

str

load_json(json_str)

Read an object from the JSON representation of the gate.

Parameters:

json_str (str)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

phi()

Get phi property.

Return type:

float

class scaluq.default.f32.U3Gate(arg)

Specific class of IBMQ’s U3 Gate, which is a rotation about 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}\).

Notes

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

Parameters:

arg (U3Gate)

gate_type()

Get gate type as GateType enum.

Return type:

scaluq.scaluq_core.GateType

target_qubit_list()

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

Return type:

list[int]

control_qubit_list()

Get control qubits as list[int].

Return type:

list[int]

control_value_list()

Get control values as list[int].

Return type:

list[int]

operand_qubit_list()

Get target and control qubits as list[int].

Return type:

list[int]

target_qubit_mask()

Get target qubits as mask. Control qubits are not included.

Return type:

int

control_qubit_mask()

Get control qubits as mask.

Return type:

int

control_value_mask()

Get control values as mask.

Return type:

int

operand_qubit_mask()

Get target and control qubits as mask.

Return type:

int

get_inverse()

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

Return type:

object

get_matrix()

Get matrix representation of the gate. Note: The matrix is constructed by reordering target qubits in ascending order of their indices. The qubit with the smaller index is treated as the first target, and the larger as the second.

Return type:

Annotated[numpy.typing.NDArray[numpy.complex128], dict(shape=(None, None), order=’C’)]

to_string()

Get string representation of the gate.

Return type:

str

to_json()

Get JSON representation of the gate.

Return type:

str

load_json(json_str)

Read an object from the JSON representation of the gate.

Parameters:

json_str (str)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

theta()

Get theta property.

Return type:

float

phi()

Get phi property.

Return type:

float

class scaluq.default.f32.SwapGate(arg)

Specific class of two-qubit swap gate.

Notes

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

Parameters:

arg (SwapGate)

gate_type()

Get gate type as GateType enum.

Return type:

scaluq.scaluq_core.GateType

target_qubit_list()

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

Return type:

list[int]

control_qubit_list()

Get control qubits as list[int].

Return type:

list[int]

control_value_list()

Get control values as list[int].

Return type:

list[int]

operand_qubit_list()

Get target and control qubits as list[int].

Return type:

list[int]

target_qubit_mask()

Get target qubits as mask. Control qubits are not included.

Return type:

int

control_qubit_mask()

Get control qubits as mask.

Return type:

int

control_value_mask()

Get control values as mask.

Return type:

int

operand_qubit_mask()

Get target and control qubits as mask.

Return type:

int

get_inverse()

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

Return type:

object

get_matrix()

Get matrix representation of the gate. Note: The matrix is constructed by reordering target qubits in ascending order of their indices. The qubit with the smaller index is treated as the first target, and the larger as the second.

Return type:

Annotated[numpy.typing.NDArray[numpy.complex128], dict(shape=(None, None), order=’C’)]

to_string()

Get string representation of the gate.

Return type:

str

to_json()

Get JSON representation of the gate.

Return type:

str

load_json(json_str)

Read an object from the JSON representation of the gate.

Parameters:

json_str (str)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

class scaluq.default.f32.EcrGate(arg)

Specific class of two-qubit ecr gate.represented as \(\frac{1}{\sqrt{2}}\begin{bmatrix} 0 & 1 & 0 & i \\ 1 & 0 & -i & 0 \\ 0 & i & 0 & 1 \\ -i & 0 & 1 & 0 \end{bmatrix}\).

Notes

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

Parameters:

arg (EcrGate)

gate_type()

Get gate type as GateType enum.

Return type:

scaluq.scaluq_core.GateType

target_qubit_list()

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

Return type:

list[int]

control_qubit_list()

Get control qubits as list[int].

Return type:

list[int]

control_value_list()

Get control values as list[int].

Return type:

list[int]

operand_qubit_list()

Get target and control qubits as list[int].

Return type:

list[int]

target_qubit_mask()

Get target qubits as mask. Control qubits are not included.

Return type:

int

control_qubit_mask()

Get control qubits as mask.

Return type:

int

control_value_mask()

Get control values as mask.

Return type:

int

operand_qubit_mask()

Get target and control qubits as mask.

Return type:

int

get_inverse()

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

Return type:

object

get_matrix()

Get matrix representation of the gate. Note: The matrix is constructed by reordering target qubits in ascending order of their indices. The qubit with the smaller index is treated as the first target, and the larger as the second.

Return type:

Annotated[numpy.typing.NDArray[numpy.complex128], dict(shape=(None, None), order=’C’)]

to_string()

Get string representation of the gate.

Return type:

str

to_json()

Get JSON representation of the gate.

Return type:

str

load_json(json_str)

Read an object from the JSON representation of the gate.

Parameters:

json_str (str)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

physical_control()

Get physical_control_indices property.

Return type:

list[int]

physical_target()

Get physical_target_indices property.

Return type:

list[int]

class scaluq.default.f32.MeasurementGate(arg)

Specific class of computational-basis measurement gate.

Notes

This gate is not unitary and requires a classical register when applied.

Notes

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

Parameters:

arg (MeasurementGate)

gate_type()

Get gate type as GateType enum.

Return type:

scaluq.scaluq_core.GateType

target_qubit_list()

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

Return type:

list[int]

control_qubit_list()

Get control qubits as list[int].

Return type:

list[int]

control_value_list()

Get control values as list[int].

Return type:

list[int]

operand_qubit_list()

Get target and control qubits as list[int].

Return type:

list[int]

target_qubit_mask()

Get target qubits as mask. Control qubits are not included.

Return type:

int

control_qubit_mask()

Get control qubits as mask.

Return type:

int

control_value_mask()

Get control values as mask.

Return type:

int

operand_qubit_mask()

Get target and control qubits as mask.

Return type:

int

get_inverse()

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

Return type:

object

get_matrix()

Get matrix representation of the gate. Note: The matrix is constructed by reordering target qubits in ascending order of their indices. The qubit with the smaller index is treated as the first target, and the larger as the second.

Return type:

Annotated[numpy.typing.NDArray[numpy.complex128], dict(shape=(None, None), order=’C’)]

to_string()

Get string representation of the gate.

Return type:

str

to_json()

Get JSON representation of the gate.

Return type:

str

load_json(json_str)

Read an object from the JSON representation of the gate.

Parameters:

json_str (str)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

classical_bit_index()

Get classical_bit_index property.

Return type:

int

reset()

Return whether this measurement resets the target qubit to |0>.

Return type:

bool

class scaluq.default.f32.PauliGate(arg)

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

Notes

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

Parameters:

arg (PauliGate)

gate_type()

Get gate type as GateType enum.

Return type:

scaluq.scaluq_core.GateType

target_qubit_list()

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

Return type:

list[int]

control_qubit_list()

Get control qubits as list[int].

Return type:

list[int]

control_value_list()

Get control values as list[int].

Return type:

list[int]

operand_qubit_list()

Get target and control qubits as list[int].

Return type:

list[int]

target_qubit_mask()

Get target qubits as mask. Control qubits are not included.

Return type:

int

control_qubit_mask()

Get control qubits as mask.

Return type:

int

control_value_mask()

Get control values as mask.

Return type:

int

operand_qubit_mask()

Get target and control qubits as mask.

Return type:

int

get_inverse()

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

Return type:

object

get_matrix()

Get matrix representation of the gate. Note: The matrix is constructed by reordering target qubits in ascending order of their indices. The qubit with the smaller index is treated as the first target, and the larger as the second.

Return type:

Annotated[numpy.typing.NDArray[numpy.complex128], dict(shape=(None, None), order=’C’)]

to_string()

Get string representation of the gate.

Return type:

str

to_json()

Get JSON representation of the gate.

Return type:

str

load_json(json_str)

Read an object from the JSON representation of the gate.

Parameters:

json_str (str)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

class scaluq.default.f32.PauliRotationGate(arg)

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

Notes

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

Parameters:

arg (PauliRotationGate)

gate_type()

Get gate type as GateType enum.

Return type:

scaluq.scaluq_core.GateType

target_qubit_list()

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

Return type:

list[int]

control_qubit_list()

Get control qubits as list[int].

Return type:

list[int]

control_value_list()

Get control values as list[int].

Return type:

list[int]

operand_qubit_list()

Get target and control qubits as list[int].

Return type:

list[int]

target_qubit_mask()

Get target qubits as mask. Control qubits are not included.

Return type:

int

control_qubit_mask()

Get control qubits as mask.

Return type:

int

control_value_mask()

Get control values as mask.

Return type:

int

operand_qubit_mask()

Get target and control qubits as mask.

Return type:

int

get_inverse()

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

Return type:

object

get_matrix()

Get matrix representation of the gate. Note: The matrix is constructed by reordering target qubits in ascending order of their indices. The qubit with the smaller index is treated as the first target, and the larger as the second.

Return type:

Annotated[numpy.typing.NDArray[numpy.complex128], dict(shape=(None, None), order=’C’)]

to_string()

Get string representation of the gate.

Return type:

str

to_json()

Get JSON representation of the gate.

Return type:

str

load_json(json_str)

Read an object from the JSON representation of the gate.

Parameters:

json_str (str)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(state_vector, classical_register, seed=None)

Apply gate to state_vector with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, seed=None)

Apply gate to states with classical_register and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • seed (int | None)

Return type:

None

class scaluq.default.f32.ParamRXGate(arg)

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

Notes

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

Parameters:

arg (ParamRXGate)

param_gate_type()

Get parametric gate type as ParamGateType enum.

Return type:

scaluq.scaluq_core.ParamGateType

param_coef()

Get coefficient of parameter.

Return type:

float

target_qubit_list()

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

Return type:

list[int]

control_qubit_list()

Get control qubits as list[int].

Return type:

list[int]

operand_qubit_list()

Get target and control qubits as list[int].

Return type:

list[int]

target_qubit_mask()

Get target qubits as mask. Control qubits is not included.

Return type:

int

control_qubit_mask()

Get control qubits as mask.

Return type:

int

operand_qubit_mask()

Get target and control qubits as mask.

Return type:

int

get_inverse()

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

Return type:

object

update_quantum_state(state, param)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • params (collections.abc.Sequence[float])

  • seed (int | None)

Return type:

None

update_quantum_state(state, classical_register, param, seed=None)

Apply gate to state_vector with classical_register, parameter, and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • params (collections.abc.Sequence[float])

  • seed (int | None)

Return type:

None

update_quantum_state(states, params)

updated.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • params (collections.abc.Sequence[float])

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, params, seed=None)

Apply gate to states with classical_register, parameters, and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • params (collections.abc.Sequence[float])

  • seed (int | None)

Return type:

None

update_quantum_state(state, param)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • params (collections.abc.Sequence[float])

  • seed (int | None)

Return type:

None

update_quantum_state(state, classical_register, param, seed=None)

Apply gate to state_vector with classical_register, parameter, and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • params (collections.abc.Sequence[float])

  • seed (int | None)

Return type:

None

update_quantum_state(states, params)

Apply gate to states with holding the parameters. states in args is directly updated.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • params (collections.abc.Sequence[float])

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, params, seed=None)

Apply gate to states with classical_register, parameters, and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • params (collections.abc.Sequence[float])

  • seed (int | None)

Return type:

None

get_matrix(param)

Get matrix representation of the gate with holding the parameter.

Parameters:

param (float)

Return type:

Annotated[numpy.typing.NDArray[numpy.complex128], dict(shape=(None, None), order=’C’)]

to_string()

Get string representation of the gate.

Return type:

str

to_json()

Get JSON representation of the gate.

Return type:

str

load_json(json_str)

Read an object from the JSON representation of the gate.

Parameters:

json_str (str)

Return type:

None

class scaluq.default.f32.ParamRYGate(arg)

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

Notes

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

Parameters:

arg (ParamRYGate)

param_gate_type()

Get parametric gate type as ParamGateType enum.

Return type:

scaluq.scaluq_core.ParamGateType

param_coef()

Get coefficient of parameter.

Return type:

float

target_qubit_list()

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

Return type:

list[int]

control_qubit_list()

Get control qubits as list[int].

Return type:

list[int]

operand_qubit_list()

Get target and control qubits as list[int].

Return type:

list[int]

target_qubit_mask()

Get target qubits as mask. Control qubits is not included.

Return type:

int

control_qubit_mask()

Get control qubits as mask.

Return type:

int

operand_qubit_mask()

Get target and control qubits as mask.

Return type:

int

get_inverse()

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

Return type:

object

update_quantum_state(state, param)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • params (collections.abc.Sequence[float])

  • seed (int | None)

Return type:

None

update_quantum_state(state, classical_register, param, seed=None)

Apply gate to state_vector with classical_register, parameter, and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • params (collections.abc.Sequence[float])

  • seed (int | None)

Return type:

None

update_quantum_state(states, params)

updated.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • params (collections.abc.Sequence[float])

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, params, seed=None)

Apply gate to states with classical_register, parameters, and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • params (collections.abc.Sequence[float])

  • seed (int | None)

Return type:

None

update_quantum_state(state, param)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • params (collections.abc.Sequence[float])

  • seed (int | None)

Return type:

None

update_quantum_state(state, classical_register, param, seed=None)

Apply gate to state_vector with classical_register, parameter, and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • params (collections.abc.Sequence[float])

  • seed (int | None)

Return type:

None

update_quantum_state(states, params)

Apply gate to states with holding the parameters. states in args is directly updated.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • params (collections.abc.Sequence[float])

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, params, seed=None)

Apply gate to states with classical_register, parameters, and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • params (collections.abc.Sequence[float])

  • seed (int | None)

Return type:

None

get_matrix(param)

Get matrix representation of the gate with holding the parameter.

Parameters:

param (float)

Return type:

Annotated[numpy.typing.NDArray[numpy.complex128], dict(shape=(None, None), order=’C’)]

to_string()

Get string representation of the gate.

Return type:

str

to_json()

Get JSON representation of the gate.

Return type:

str

load_json(json_str)

Read an object from the JSON representation of the gate.

Parameters:

json_str (str)

Return type:

None

class scaluq.default.f32.ParamRZGate(arg)

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

Notes

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

Parameters:

arg (ParamRZGate)

param_gate_type()

Get parametric gate type as ParamGateType enum.

Return type:

scaluq.scaluq_core.ParamGateType

param_coef()

Get coefficient of parameter.

Return type:

float

target_qubit_list()

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

Return type:

list[int]

control_qubit_list()

Get control qubits as list[int].

Return type:

list[int]

operand_qubit_list()

Get target and control qubits as list[int].

Return type:

list[int]

target_qubit_mask()

Get target qubits as mask. Control qubits is not included.

Return type:

int

control_qubit_mask()

Get control qubits as mask.

Return type:

int

operand_qubit_mask()

Get target and control qubits as mask.

Return type:

int

get_inverse()

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

Return type:

object

update_quantum_state(state, param)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • params (collections.abc.Sequence[float])

  • seed (int | None)

Return type:

None

update_quantum_state(state, classical_register, param, seed=None)

Apply gate to state_vector with classical_register, parameter, and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • params (collections.abc.Sequence[float])

  • seed (int | None)

Return type:

None

update_quantum_state(states, params)

updated.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • params (collections.abc.Sequence[float])

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, params, seed=None)

Apply gate to states with classical_register, parameters, and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • params (collections.abc.Sequence[float])

  • seed (int | None)

Return type:

None

update_quantum_state(state, param)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • params (collections.abc.Sequence[float])

  • seed (int | None)

Return type:

None

update_quantum_state(state, classical_register, param, seed=None)

Apply gate to state_vector with classical_register, parameter, and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • params (collections.abc.Sequence[float])

  • seed (int | None)

Return type:

None

update_quantum_state(states, params)

Apply gate to states with holding the parameters. states in args is directly updated.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • params (collections.abc.Sequence[float])

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, params, seed=None)

Apply gate to states with classical_register, parameters, and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • params (collections.abc.Sequence[float])

  • seed (int | None)

Return type:

None

get_matrix(param)

Get matrix representation of the gate with holding the parameter.

Parameters:

param (float)

Return type:

Annotated[numpy.typing.NDArray[numpy.complex128], dict(shape=(None, None), order=’C’)]

to_string()

Get string representation of the gate.

Return type:

str

to_json()

Get JSON representation of the gate.

Return type:

str

load_json(json_str)

Read an object from the JSON representation of the gate.

Parameters:

json_str (str)

Return type:

None

class scaluq.default.f32.ParamPauliRotationGate(arg)

Parametric multi-qubit pauli-rotation gate, represented as \(e^{-i\frac{\theta}{2}P}\). theta is given as param * param_coef.

Notes

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

Parameters:

arg (ParamPauliRotationGate)

param_gate_type()

Get parametric gate type as ParamGateType enum.

Return type:

scaluq.scaluq_core.ParamGateType

param_coef()

Get coefficient of parameter.

Return type:

float

target_qubit_list()

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

Return type:

list[int]

control_qubit_list()

Get control qubits as list[int].

Return type:

list[int]

operand_qubit_list()

Get target and control qubits as list[int].

Return type:

list[int]

target_qubit_mask()

Get target qubits as mask. Control qubits is not included.

Return type:

int

control_qubit_mask()

Get control qubits as mask.

Return type:

int

operand_qubit_mask()

Get target and control qubits as mask.

Return type:

int

get_inverse()

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

Return type:

object

update_quantum_state(state, param)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • params (collections.abc.Sequence[float])

  • seed (int | None)

Return type:

None

update_quantum_state(state, classical_register, param, seed=None)

Apply gate to state_vector with classical_register, parameter, and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • params (collections.abc.Sequence[float])

  • seed (int | None)

Return type:

None

update_quantum_state(states, params)

updated.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • params (collections.abc.Sequence[float])

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, params, seed=None)

Apply gate to states with classical_register, parameters, and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • params (collections.abc.Sequence[float])

  • seed (int | None)

Return type:

None

update_quantum_state(state, param)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • params (collections.abc.Sequence[float])

  • seed (int | None)

Return type:

None

update_quantum_state(state, classical_register, param, seed=None)

Apply gate to state_vector with classical_register, parameter, and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • params (collections.abc.Sequence[float])

  • seed (int | None)

Return type:

None

update_quantum_state(states, params)

Apply gate to states with holding the parameters. states in args is directly updated.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • params (collections.abc.Sequence[float])

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, params, seed=None)

Apply gate to states with classical_register, parameters, and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • params (collections.abc.Sequence[float])

  • seed (int | None)

Return type:

None

get_matrix(param)

Get matrix representation of the gate with holding the parameter.

Parameters:

param (float)

Return type:

Annotated[numpy.typing.NDArray[numpy.complex128], dict(shape=(None, None), order=’C’)]

to_string()

Get string representation of the gate.

Return type:

str

to_json()

Get JSON representation of the gate.

Return type:

str

load_json(json_str)

Read an object from the JSON representation of the gate.

Parameters:

json_str (str)

Return type:

None

class scaluq.default.f32.ParamProbabilisticGate(arg)

Specific class of parametric probabilistic gate. The gate to apply is picked from a certain distribution.

Notes

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

Parameters:

arg (ParamProbabilisticGate)

param_gate_type()

Get parametric gate type as ParamGateType enum.

Return type:

scaluq.scaluq_core.ParamGateType

param_coef()

Get coefficient of parameter.

Return type:

float

target_qubit_list()

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

Return type:

list[int]

control_qubit_list()

Get control qubits as list[int].

Return type:

list[int]

operand_qubit_list()

Get target and control qubits as list[int].

Return type:

list[int]

target_qubit_mask()

Get target qubits as mask. Control qubits is not included.

Return type:

int

control_qubit_mask()

Get control qubits as mask.

Return type:

int

operand_qubit_mask()

Get target and control qubits as mask.

Return type:

int

get_inverse()

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

Return type:

object

update_quantum_state(state, param)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • params (collections.abc.Sequence[float])

  • seed (int | None)

Return type:

None

update_quantum_state(state, classical_register, param, seed=None)

Apply gate to state_vector with classical_register, parameter, and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • params (collections.abc.Sequence[float])

  • seed (int | None)

Return type:

None

update_quantum_state(states, params)

updated.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • params (collections.abc.Sequence[float])

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, params, seed=None)

Apply gate to states with classical_register, parameters, and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • params (collections.abc.Sequence[float])

  • seed (int | None)

Return type:

None

update_quantum_state(state, param)

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

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • params (collections.abc.Sequence[float])

  • seed (int | None)

Return type:

None

update_quantum_state(state, classical_register, param, seed=None)

Apply gate to state_vector with classical_register, parameter, and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • params (collections.abc.Sequence[float])

  • seed (int | None)

Return type:

None

update_quantum_state(states, params)

Apply gate to states with holding the parameters. states in args is directly updated.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • params (collections.abc.Sequence[float])

  • seed (int | None)

Return type:

None

update_quantum_state(states, classical_register, params, seed=None)

Apply gate to states with classical_register, parameters, and seed.

Parameters:
  • states (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

  • params (collections.abc.Sequence[float])

  • seed (int | None)

Return type:

None

get_matrix(param)

Get matrix representation of the gate with holding the parameter.

Parameters:

param (float)

Return type:

Annotated[numpy.typing.NDArray[numpy.complex128], dict(shape=(None, None), order=’C’)]

to_string()

Get string representation of the gate.

Return type:

str

to_json()

Get JSON representation of the gate.

Return type:

str

load_json(json_str)

Read an object from the JSON representation of the gate.

Parameters:

json_str (str)

Return type:

None

gate_list()
Return type:

list[Gate | ParamGate]

distribution()
Return type:

list[float]

class scaluq.default.f32.Circuit

Quantum circuit representation.

Examples

>>> circuit = Circuit()
>>> print(circuit.to_json())
{"gate_list":[]}
gate_list()

Get property of gate_list.

Returns:

List of gates.

Return type:

list

Examples

>>> circuit = Circuit()
>>> circuit.add_gate(gate.X(0))
>>> len(circuit.gate_list())
1
n_gates()

Get property of n_gates.

Returns:

Property of n_gates.

Return type:

int

Examples

>>> circuit = Circuit()
>>> circuit.add_gate(gate.X(0))
>>> circuit.add_gate(gate.CX(0, 1))
>>> print(circuit.n_gates())
2
key_set()

Get set of keys of parameters.

Returns:

Set of keys.

Return type:

set[str]

Examples

>>> circuit = Circuit()
>>> circuit.add_param_gate(gate.ParamRX(0, 0.0), "theta")
>>> circuit.add_param_gate(gate.ParamRY(1, 2.0), "phi")
>>> print(sorted(circuit.key_set()))
['phi', 'theta']
get_gate_at(index)

Get reference of i-th gate.

Parameters:

index (int) – Index of gate

Returns:

Gate at i-th index

Return type:

Gate

Examples

>>> circuit = Circuit()
>>> circuit.add_gate(gate.X(0))
>>> print(circuit.get_gate_at(0))
Gate Type: X
  Target Qubits: {0}
  Control Qubits: {}
  Control Value: {}
get_param_key_at(index)

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

Parameters:

index (int) – Index of gate

Returns:

Parameter key

Return type:

str | None

Examples

>>> circuit = Circuit()
>>> circuit.add_param_gate(gate.ParamRX(0, 0.0), "theta")
>>> circuit.add_gate(gate.X(1))
>>> circuit.get_param_key_at(0)
'theta'
>>> circuit.get_param_key_at(1) is None
True
calculate_depth()

Get depth of circuit.

Returns:

Depth of circuit

Return type:

int

Examples

>>> circuit = Circuit()
>>> circuit.add_gate(gate.X(0))
>>> circuit.add_gate(gate.Y(1))
>>> circuit.add_gate(gate.CX(0, 1))
>>> print(circuit.calculate_depth())
2
add_gate(gate)

Add gate to circuit.

Parameters:

gate (Gate) – Gate to add

Return type:

None

Examples

>>> circuit = Circuit()
>>> circuit.add_gate(gate.X(0))
add_conditional_gate(gate, condition)

Add gate with a user-defined classical condition.

Parameters:
  • gate (Gate)

  • classical_bit_index (int)

  • expected_value (bool)

Return type:

None

add_conditional_gate(gate, classical_bit_index, expected_value)

Add gate with a condition on a classical bit.

Parameters:
  • gate (Gate)

  • classical_bit_index (int)

  • expected_value (bool)

Return type:

None

add_param_gate(param_gate, param_key)

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

Parameters:
  • param_gate (ParamGate) – Parametric gate to add

  • param_key (str) – Parameter key

Return type:

None

Examples

>>> circuit = Circuit()
>>> circuit.add_param_gate(gate.ParamRX(0, 0.0), "theta")
add_conditional_param_gate(param_gate, param_key, condition)

Add parametric gate with a user-defined classical condition.

Parameters:
  • param_gate (ParamGate)

  • param_key (str)

  • classical_bit_index (int)

  • expected_value (bool)

Return type:

None

add_conditional_param_gate(param_gate, param_key, classical_bit_index, expected_value)

Add parametric gate with a condition on a classical bit.

Parameters:
  • param_gate (ParamGate)

  • param_key (str)

  • classical_bit_index (int)

  • expected_value (bool)

Return type:

None

add_circuit(other)

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

Parameters:

other (Circuit) – Circuit to add

Return type:

None

Examples

>>> circuit = Circuit()
>>> circuit.add_gate(gate.X(0))
>>> circuit2 = Circuit()
>>> circuit2.add_gate(gate.Y(1))
>>> circuit.add_circuit(circuit2)
>>> circuit.n_gates()
2
copy()

Copy circuit. Returns a new circuit instance with all gates copied by reference.

Return type:

Circuit

get_inverse()

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

Return type:

Circuit

to_json()

Information as json style.

Return type:

str

load_json(json_str)

Read an object from the JSON representation of the circuit.

Parameters:

json_str (str)

Return type:

None

update_quantum_state(state, **kwargs)

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.

Parameters:
  • state (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

Return type:

None

update_quantum_state(state, params={}, seed=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.

Parameters:
  • state (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

Return type:

None

update_quantum_state(state, classical_register, params={}, seed=None)

Apply gate to the StateVector with classical register and optional seed.

Parameters:
  • state (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

Return type:

None

update_quantum_state(state, classical_register, **kwargs)

Apply gate to the StateVector with classical register. If the circuit contains parametric gate, give parameter values as “name=value” in kwargs.

Parameters:
  • state (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

Return type:

None

update_quantum_state(state, **kwargs)

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

Parameters:
  • state (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

Return type:

None

update_quantum_state(state, params={}, seed=None)

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

Parameters:
  • state (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

Return type:

None

update_quantum_state(state, classical_register, params={}, seed=None)

Apply gate to the StateVectorBatched with classical register and optional seed.

Parameters:
  • state (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

Return type:

None

update_quantum_state(state, classical_register, **kwargs)

Apply gate to the StateVectorBatched with classical register. If the circuit contains parametric gate, give parameter values as “name=[value1, value2, …]” in kwargs.

Parameters:
  • state (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

Return type:

None

update_quantum_state(state, **kwargs)

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.

Parameters:
  • state (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

Return type:

None

update_quantum_state(state, params={}, seed=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.

Parameters:
  • state (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

Return type:

None

update_quantum_state(state, classical_register, params={}, seed=None)

Apply gate to the StateVector with classical register and optional seed.

Parameters:
  • state (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

Return type:

None

update_quantum_state(state, classical_register, **kwargs)

Apply gate to the StateVector with classical register. If the circuit contains parametric gate, give parameter values as “name=value” in kwargs.

Parameters:
  • state (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

Return type:

None

update_quantum_state(state, **kwargs)

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

Parameters:
  • state (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

Return type:

None

update_quantum_state(state, params={}, seed=None)

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

Parameters:
  • state (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

Return type:

None

update_quantum_state(state, classical_register, params={}, seed=None)

Apply gate to the StateVectorBatched with classical register and optional seed.

Parameters:
  • state (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

Return type:

None

update_quantum_state(state, classical_register, **kwargs)

Apply gate to the StateVectorBatched with classical register. If the circuit contains parametric gate, give parameter values as “name=[value1, value2, …]” in kwargs.

Parameters:
  • state (scaluq.scaluq_core.host_serial.f32.StateVectorBatched)

  • classical_register (scaluq.scaluq_core.ClassicalRegisterBatched)

Return type:

None

optimize(max_block_size=3)

Optimize circuit. Create qubit dependency tree and merge neighboring gates if the new gate has less than or equal to max_block_size or the new gate is Pauli.

Parameters:

max_block_size (int)

Return type:

None

optimize(max_block_size=3)
Parameters:

max_block_size (int)

Return type:

None

simulate_noise(initial_state, sampling_count, parameters={}, seed=None)

Simulate noise circuit. Return all the possible states and their counts.

Parameters:
  • initial_state (scaluq.scaluq_core.host_serial.f32.StateVector)

  • sampling_count (int)

  • parameters (collections.abc.Mapping[str, float])

  • seed (int | None)

Return type:

list[tuple[scaluq.scaluq_core.host_serial.f32.StateVector, int]]

simulate_noise(initial_state, sampling_count, parameters={}, seed=None)
Parameters:
  • initial_state (scaluq.scaluq_core.host_serial.f32.StateVector)

  • sampling_count (int)

  • parameters (collections.abc.Mapping[str, float])

  • seed (int | None)

Return type:

list[tuple[scaluq.scaluq_core.host_serial.f32.StateVector, int]]

compute_expectation_gradient_backprop(state, bistate, parameters)

Low-level implementation for expectation gradient that assumes the forward state and observable-applied bistate are already prepared, and computes gradient using back propagation.

Parameters:
  • state (scaluq.scaluq_core.host_serial.f32.StateVector)

  • bistate (scaluq.scaluq_core.host_serial.f32.StateVector)

  • parameters (collections.abc.Mapping[str, float])

Return type:

dict[str, float]

compute_expectation_gradient_backprop(state, bistate, parameters)
Parameters:
  • state (scaluq.scaluq_core.host_serial.f32.StateVector)

  • bistate (scaluq.scaluq_core.host_serial.f32.StateVector)

  • parameters (collections.abc.Mapping[str, float])

Return type:

dict[str, float]

compute_expectation_gradient(observable, parameters)

Compute gradient of expectation value of observable using back propagation.

Parameters:
  • observable (scaluq.scaluq_core.host_serial.f32.Operator)

  • parameters (collections.abc.Mapping[str, float])

Return type:

dict[str, float]

compute_expectation_gradient(observable, parameters)
Parameters:
  • observable (scaluq.scaluq_core.host_serial.f32.Operator)

  • parameters (collections.abc.Mapping[str, float])

Return type:

dict[str, float]

add_observable_rotation_gate(observable, angle, num_repeats)

Add observable rotation gate.

Parameters:
  • observable (Operator) – observable

  • angle (float) – angle

  • num_repeats (int) – repeats num

Return type:

None

Examples

>>> circuit = Circuit()
>>> terms = []
>>> terms.append(PauliOperator("Z 0 Z 1"))
>>> observable = Operator(terms)
>>> circuit.add_observable_rotation_gate(observable, 0.1, 100)
add_observable_rotation_gate(observable, angle, num_repeats)
Parameters:
  • observable (scaluq.scaluq_core.host_serial.f32.Operator)

  • angle (float)

  • num_repeats (int)

Return type:

None

class scaluq.default.f32.PauliOperator(coef=1.0)

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

Given coef: complex, Initialize operator which just multiplying coef.

Given target_qubit_list: list[int], pauli_id_list: list[int], coef: complex, Initialize pauli operator. For each i, single pauli correspond to pauli_id_list[i] is applied to target_qubit_list[i]-th qubit.

Given pauli_string: str, coef: complex, Initialize pauli operator. For each i, single pauli correspond to pauli_id_list[i] is applied to target_qubit_list[i]-th qubit.

Given pauli_id_par_qubit: list[int], coef: complex, Initialize pauli operator. For each i, single pauli correspond to paul_id_per_qubit[i] is applied to i-th qubit.

Given bit_flip_mask: int, phase_flip_mask: int, coef: complex, Initialize pauli operator. For each i, single pauli applied to i-th qubit is got from i-th bit of bit_flip_mask and phase_flip_mask as follows.

bit_flip

phase_flip

pauli

0

0

I

0

1

Z

1

0

X

1

1

Y

Examples

>>> pauli = PauliOperator("X 3 Y 2")
>>> print(pauli.to_json())
{"coef":{"imag":0.0,"real":1.0},"pauli_string":"Y 2 X 3"}
Parameters:

coef (complex)

coef()

Get property coef.

Return type:

complex

target_qubit_list()

Get qubits to be applied pauli.

Return type:

list[int]

pauli_id_list()

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

Return type:

list[int]

get_XZ_mask_representation()

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.

Return type:

tuple[int, int]

get_pauli_string()

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

Return type:

str

get_dagger()

Get adjoint operator.

Return type:

PauliOperator

apply_to_state(state)

Apply pauli to state vector.

Parameters:

state (StateVector)

Return type:

None

get_expectation_value(state)

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

Parameters:

state (StateVector)

Return type:

complex

get_transition_amplitude(source, target)

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

Parameters:
Return type:

complex

get_matrix()

Get matrix representation of the PauliOperator. Tensor product is applied from \((n-1)\) -th qubit to \(0\) -th qubit. Only the X, Y, and Z components are taken into account in the result.

Return type:

Annotated[numpy.typing.NDArray[numpy.complex128], dict(shape=(None, None), order=’C’)]

get_full_matrix(n_qubits)

Get matrix representation of the PauliOperator. Tensor product is applied from \((n-1)\) -th qubit to \(0\) -th qubit.

Parameters:

n_qubits (int)

Return type:

Annotated[numpy.typing.NDArray[numpy.complex128], dict(shape=(None, None), order=’C’)]

get_matrix_ignoring_coef()

Get matrix representation of the PauliOperator, but with forcing `coef=1.`Only the X, Y, and Z components are taken into account in the result.

Return type:

Annotated[numpy.typing.NDArray[numpy.complex128], dict(shape=(None, None), order=’C’)]

get_full_matrix_ignoring_coef(n_qubits)

Get matrix representation of the PauliOperator, but with forcing coef=1.

Parameters:

n_qubits (int)

Return type:

Annotated[numpy.typing.NDArray[numpy.complex128], dict(shape=(None, None), order=’C’)]

to_json()

Information as json style.

Return type:

str

load_json(json_str)

Read an object from the JSON representation of the Pauli operator.

Parameters:

json_str (str)

Return type:

None

to_string()

Get string representation of the Pauli operator.

Return type:

str