scaluq.host.f64.gate

Define gates.

Functions

DenseMatrix(targets, matrix[, controls, ...])

Generate general Gate class instance of DenseMatrixGate. Performs dense matrix operation.

SparseMatrix(targets, matrix[, controls, control_values])

Generate general Gate class instance of SparseMatrixGate. Performs sparse matrix operation.

I()

Generate general Gate class instance of IGate.

GlobalPhase(gamma[, controls, control_values])

Generate general Gate class instance of GlobalPhaseGate.

X(target[, controls, control_values])

Generate general Gate class instance of XGate. Performs bit flip operation.

Y(target[, controls, control_values])

Generate general Gate class instance of YGate. Performs bit flip and phase flip operation.

Z(target[, controls, control_values])

Generate general Gate class instance of ZGate. Performs bit flip and phase flip operation.

H(target[, controls, control_values])

Generate general Gate class instance of HGate. Performs superposition operation.

S(target[, controls, control_values])

Generate general Gate class instance of SGate.

Sdag(target[, controls, control_values])

Generate general Gate class instance of SdagGate.

T(target[, controls, control_values])

Generate general Gate class instance of TGate.

Tdag(target[, controls, control_values])

Generate general Gate class instance of TdagGate.

SqrtX(target[, controls, control_values])

Generate general Gate class instance of SqrtXGate, represented as $frac{1}{2}begin{bmatrix} 1+i & 1-i \ 1-i & 1+i end{bmatrix}$.

SqrtXdag(target[, controls, control_values])

Generate general Gate class instance of SqrtXdagGate, represented as $begin{bmatrix} 1-i & 1+i\ 1+i & 1-i end{bmatrix}$.

SqrtY(target[, controls, control_values])

Generate general Gate class instance of SqrtYGate, represented as $begin{bmatrix} 1+i & -1-i \ 1+i & 1+i end{bmatrix}$.

SqrtYdag(target[, controls, control_values])

Generate general Gate class instance of SqrtYdagGate, represented as $begin{bmatrix} 1-i & 1-i \ -1+i & 1-i end{bmatrix}$.

P0(target[, controls, control_values])

Generate general Gate class instance of P0Gate.

P1(target[, controls, control_values])

Generate general Gate class instance of P1Gate.

Measurement(target, classical_bit[, reset])

Generate computational-basis measurement gate.

RX(target, theta[, controls, control_values])

Generate rotation gate around X-axis. Rotation angle is specified in radians.

RY(target, theta[, controls, control_values])

Generate rotation gate around Y-axis. Rotation angle is specified in radians.

RZ(target, theta[, controls, control_values])

Generate rotation gate around Z-axis. Rotation angle is specified in radians.

U1(target, lambda_[, controls, control_values])

Generate general Gate class instance of U1Gate.

U2(target, phi, lambda_[, controls, control_values])

Generate general Gate class instance of U2Gate.

U3(target, theta, phi, lambda_[, controls, control_values])

Generate general Gate class instance of U3Gate.

Swap(target1, target2[, controls, control_values])

Generate SWAP gate. Swaps the states of two qubits.

Ecr(physical_control, physical_target[, controls, ...])

Generate ECR gate. Echoed cross-resonance gate.

CX(control, target)

Generate general Gate class instance of XGate with one control qubit. Performs controlled-X operation.

CNot(control, target)

Generate general Gate class instance of XGate with one control qubit. Performs controlled-X operation.

CZ(control, target)

Generate general Gate class instance of ZGate with one control qubit. Performs controlled-Z operation.

CCX(control1, control2, target)

Generate general Gate class instance of XGate with two control qubits. Performs controlled-controlled-X operation.

CCNot(control1, control2, target)

Generate general Gate class instance of XGate with two control qubits. Performs controlled-controlled-X operation.

Toffoli(control1, control2, target)

Generate general Gate class instance of XGate with two control qubits. Performs controlled-controlled-X operation.

Pauli(pauli[, controls, control_values])

Generate general Gate class instance of PauliGate. Performs Pauli operation.

PauliRotation(pauli, theta[, controls, control_values])

Generate general Gate class instance of PauliRotationGate. Performs Pauli rotation operation.

Probabilistic(distribution, gate_list)

Generate general Gate class instance of ProbabilisticGate. Performs probabilistic operation.

BitFlipNoise(target, error_rate)

Generates a general Gate class instance of BitFlipNoise. error_rate is the probability of a bit-flip noise, corresponding to the X gate.

DephasingNoise(target, error_rate)

Generates a general Gate class instance of DephasingNoise. error_rate is the probability of a dephasing noise, corresponding to the Z gate.

BitFlipAndDephasingNoise(target, error_rate)

Generates a general Gate class instance of BitFlipAndDephasingNoise. error_rate is the probability of both bit-flip noise and dephasing noise, corresponding to the X gate and Z gate.

DepolarizingNoise(target, error_rate)

Generates a general Gate class instance of DepolarizingNoise. error_rate is the total probability of depolarizing noise, where an X, Y, or Z gate is applied with a probability of error_rate / 3 each.

ParamRX(target[, coef, controls, control_values])

Generate general ParamGate class instance of ParamRXGate.

ParamRY(target[, coef, controls, control_values])

Generate general ParamGate class instance of ParamRYGate.

ParamRZ(target[, coef, controls, control_values])

Generate general ParamGate class instance of ParamRZGate.

ParamPauliRotation(pauli[, coef, controls, control_values])

Generate general ParamGate class instance of ParamPauliRotationGate.

ParamProbabilistic(prob_gate_list)

Generate general ParamGate class instance of ParamProbabilisticGate.

ParamProbabilistic(prob_gate_list)

Generate general ParamGate class instance of ParamProbabilisticGate.

Package Contents

scaluq.host.f64.gate.DenseMatrix(targets, matrix, controls=[], control_values=[], is_unitary=False)

Generate general Gate class instance of DenseMatrixGate. Performs dense matrix operation.

Parameters:
  • targets (list[int]) – Target qubit indices

  • matrix (numpy.ndarray) – Matrix to be applied

  • controls (list[int], optional) – Control qubit indices

  • control_values (list[int], optional) – Control qubit values

  • is_unitary (bool, optional) – Whether the matrix is unitary. When the flag indicating that the gate is unitary is set to True, a more efficient implementation is used.

Returns:

DenseMatrix gate instance

Return type:

Gate

Examples

>>> import numpy as np
>>> matrix = np.array([[1, 0], [0, 1]])
>>> gate = DenseMatrix([0], matrix)
>>> gate = DenseMatrix([0], matrix, [1])  # Controlled-DenseMatrix

Notes

If you need to use functions specific to the DenseMatrixGate class, please downcast it.

scaluq.host.f64.gate.SparseMatrix(targets, matrix, controls=[], control_values=[])

Generate general Gate class instance of SparseMatrixGate. Performs sparse matrix operation.

Parameters:
  • targets (list[int]) – Target qubit indices

  • matrix (scipy.sparse.csr_matrix) – Matrix to be applied

  • controls (list[int], optional) – Control qubit indices

  • control_values (list[int], optional) – Control qubit values

Returns:

SparseMatrix gate instance

Return type:

Gate

Examples

>>> import scipy
>>> matrix = scipy.sparse.csr_matrix([[1, 0], [0, 1]])
>>> gate = SparseMatrix([0], matrix)
>>> gate = SparseMatrix([0], matrix, [1])  # Controlled-SparseMatrix

Notes

If you need to use functions specific to the SparseMatrixGate class, please downcast it.

scaluq.host.f64.gate.I()

Generate general Gate class instance of IGate.

Returns:

Identity gate instance

Return type:

Gate

Examples

>>> gate = I()
>>> print(gate)
Gate Type: I
  Target Qubits: {}
  Control Qubits: {}
  Control Value: {}
scaluq.host.f64.gate.GlobalPhase(gamma, controls=[], control_values=[])

Generate general Gate class instance of GlobalPhaseGate.

Parameters:
  • gamma (float) – Global phase angle in radians

  • controls (list[int], optional) – Control qubit indices

  • control_values (list[int], optional) – Control qubit values

Returns:

Global phase gate instance

Return type:

Gate

Examples

>>> import math
>>> gate = GlobalPhase(math.pi/2)
>>> print(gate)
Gate Type: GlobalPhase
  Phase: 1.5708
  Target Qubits: {}
  Control Qubits: {}
  Control Value: {}

Notes

If you need to use functions specific to the GlobalPhaseGate class, please downcast it.

scaluq.host.f64.gate.X(target, controls=[], control_values=[])

Generate general Gate class instance of XGate. Performs bit flip operation.

Parameters:
  • target (int) – Target qubit index

  • controls (list[int], optional) – Control qubit indices

  • control_values (list[int], optional) – Control qubit values

Returns:

Pauli-X gate instance

Return type:

Gate

Examples

>>> gate = X(0)  # X gate on qubit 0
>>> gate = X(1, [0])  # Controlled-X with control on qubit 0

Notes

XGate represents the Pauli-X (NOT) gate class.If you need to use functions specific to the XGate class, please downcast it.

scaluq.host.f64.gate.Y(target, controls=[], control_values=[])

Generate general Gate class instance of YGate. Performs bit flip and phase flip operation.

Parameters:
  • target (int) – Target qubit index

  • controls (list[int], optional) – Control qubit indices

  • control_values (list[int], optional) – Control qubit values

Returns:

Pauli-Y gate instance

Return type:

Gate

Examples

>>> gate = Y(0)  # Y gate on qubit 0
>>> gate = Y(1, [0])  # Controlled-Y with control on qubit 0

Notes

YGate represents the Pauli-Y gate class. If you need to use functions specific to the YGate class, please downcast it.

scaluq.host.f64.gate.Z(target, controls=[], control_values=[])

Generate general Gate class instance of ZGate. Performs bit flip and phase flip operation.

Parameters:
  • target (int) – Target qubit index

  • controls (list[int], optional) – Control qubit indices

  • control_values (list[int], optional) – Control qubit values

Returns:

Pauli-Z gate instance

Return type:

Gate

Examples

>>> gate = Z(0)  # Z gate on qubit 0
>>> gate = Z(1, [0])  # Controlled-Z with control on qubit 0

Notes

ZGate represents the Pauli-Z gate class. If you need to use functions specific to the ZGate class, please downcast it.

scaluq.host.f64.gate.H(target, controls=[], control_values=[])

Generate general Gate class instance of HGate. Performs superposition operation.

Parameters:
  • target (int) – Target qubit index

  • controls (list[int], optional) – Control qubit indices

  • control_values (list[int], optional) – Control qubit values

Returns:

Hadamard gate instance

Return type:

Gate

Examples

>>> gate = H(0)  # H gate on qubit 0
>>> gate = H(1, [0])  # Controlled-H with control on qubit 0

Notes

If you need to use functions specific to the HGate class, please downcast it.

scaluq.host.f64.gate.S(target, controls=[], control_values=[])

Generate general Gate class instance of SGate.

Parameters:
  • target (int) – Target qubit index

  • controls (list[int], optional) – Control qubit indices

  • control_values (list[int], optional) – Control qubit values

Returns:

S gate instance

Return type:

Gate

Examples

>>> gate = S(0)  # S gate on qubit 0
>>> gate = S(1, [0])  # Controlled-S with control on qubit 0

Notes

If you need to use functions specific to the SGate class, please downcast it.

scaluq.host.f64.gate.Sdag(target, controls=[], control_values=[])

Generate general Gate class instance of SdagGate.

Parameters:
  • target (int) – Target qubit index

  • controls (list[int], optional) – Control qubit indices

  • control_values (list[int], optional) – Control qubit values

Returns:

Sdag gate instance

Return type:

Gate

Examples

>>> gate = Sdag(0)  # Sdag gate on qubit 0
>>> gate = Sdag(1, [0])  # Controlled-Sdag with control on qubit 0

Notes

If you need to use functions specific to the SdagGate class, please downcast it.

scaluq.host.f64.gate.T(target, controls=[], control_values=[])

Generate general Gate class instance of TGate.

Parameters:
  • target (int) – Target qubit index

  • controls (list[int], optional) – Control qubit indices

  • control_values (list[int], optional) – Control qubit values

Returns:

T gate instance

Return type:

Gate

Examples

>>> gate = T(0)  # T gate on qubit 0
>>> gate = T(1, [0])  # Controlled-T with control on qubit 0

Notes

If you need to use functions specific to the TGate class, please downcast it.

scaluq.host.f64.gate.Tdag(target, controls=[], control_values=[])

Generate general Gate class instance of TdagGate.

Parameters:
  • target (int) – Target qubit index

  • controls (list[int], optional) – Control qubit indices

  • control_values (list[int], optional) – Control qubit values

Returns:

Tdag gate instance

Return type:

Gate

Examples

>>> gate = Tdag(0)  # Tdag gate on qubit 0
>>> gate = Tdag(1, [0])  # Controlled-Tdag with control on qubit 0

Notes

If you need to use functions specific to the TdagGate class, please downcast it.

scaluq.host.f64.gate.SqrtX(target, controls=[], control_values=[])

Generate general Gate class instance of SqrtXGate, represented as \(\frac{1}{2}\begin{bmatrix} 1+i & 1-i \\ 1-i & 1+i \end{bmatrix}\).

Parameters:
  • target (int) – Target qubit index

  • controls (list[int], optional) – Control qubit indices

  • control_values (list[int], optional) – Control qubit values

Returns:

SqrtX gate instance

Return type:

Gate

Examples

>>> gate = SqrtX(0)  # SqrtX gate on qubit 0
>>> gate = SqrtX(1, [0])  # Controlled-SqrtX

Notes

If you need to use functions specific to the SqrtXGate class, please downcast it.

scaluq.host.f64.gate.SqrtXdag(target, controls=[], control_values=[])

Generate general Gate class instance of SqrtXdagGate, represented as \(\begin{bmatrix} 1-i & 1+i\\ 1+i & 1-i \end{bmatrix}\).

Parameters:
  • target (int) – Target qubit index

  • controls (list[int], optional) – Control qubit indices

  • control_values (list[int], optional) – Control qubit values

Returns:

SqrtXdag gate instance

Return type:

Gate

Examples

>>> gate = SqrtXdag(0)  # SqrtXdag gate on qubit 0
>>> gate = SqrtXdag(1, [0])  # Controlled-SqrtXdag

Notes

If you need to use functions specific to the SqrtXdagGate class, please downcast it.

scaluq.host.f64.gate.SqrtY(target, controls=[], control_values=[])

Generate general Gate class instance of SqrtYGate, represented as \(\begin{bmatrix} 1+i & -1-i \\ 1+i & 1+i \end{bmatrix}\).

Parameters:
  • target (int) – Target qubit index

  • controls (list[int], optional) – Control qubit indices

  • control_values (list[int], optional) – Control qubit values

Returns:

SqrtY gate instance

Return type:

Gate

Examples

>>> gate = SqrtY(0)  # SqrtY gate on qubit 0
>>> gate = SqrtY(1, [0])  # Controlled-SqrtY

Notes

If you need to use functions specific to the SqrtYGate class, please downcast it.

scaluq.host.f64.gate.SqrtYdag(target, controls=[], control_values=[])

Generate general Gate class instance of SqrtYdagGate, represented as \(\begin{bmatrix} 1-i & 1-i \\ -1+i & 1-i \end{bmatrix}\).

Parameters:
  • target (int) – Target qubit index

  • controls (list[int], optional) – Control qubit indices

  • control_values (list[int], optional) – Control qubit values

Returns:

SqrtYdag gate instance

Return type:

Gate

Examples

>>> gate = SqrtYdag(0)  # SqrtYdag gate on qubit 0
>>> gate = SqrtYdag(1, [0])  # Controlled-SqrtYdag

Notes

If you need to use functions specific to the SqrtYdagGate class, please downcast it.

scaluq.host.f64.gate.P0(target, controls=[], control_values=[])

Generate general Gate class instance of P0Gate.

Parameters:
  • target (int) – Target qubit index

  • controls (list[int], optional) – Control qubit indices

  • control_values (list[int], optional) – Control qubit values

Returns:

P0 gate instance

Return type:

Gate

Examples

>>> gate = P0(0)  # P0 gate on qubit 0
>>> gate = P0(1, [0])  # Controlled-P0

Notes

If you need to use functions specific to the P0Gate class, please downcast it.

scaluq.host.f64.gate.P1(target, controls=[], control_values=[])

Generate general Gate class instance of P1Gate.

Parameters:
  • target (int) – Target qubit index

  • controls (list[int], optional) – Control qubit indices

  • control_values (list[int], optional) – Control qubit values

Returns:

P1 gate instance

Return type:

Gate

Examples

>>> gate = P1(0)  # P1 gate on qubit 0
>>> gate = P1(1, [0])  # Controlled-P1

Notes

If you need to use functions specific to the P1Gate class, please downcast it.

scaluq.host.f64.gate.Measurement(target, classical_bit, reset=False)

Generate computational-basis measurement gate.

Parameters:
  • target (int) – Target qubit index

  • classical_bit (int) – Destination classical bit index

  • reset (bool, optional) – Whether to reset the target qubit to |0>

Returns:

Measurement gate instance

Return type:

Gate

Examples

>>> gate = Measurement(0, 1)

Notes

Applying this gate requires a classical register whose size is greater than classical_bit. If reset is true, the target qubit is reset to |0> after the measurement.

scaluq.host.f64.gate.RX(target, theta, controls=[], control_values=[])

Generate rotation gate around X-axis. Rotation angle is specified in radians.

Parameters:
  • target (int) – Target qubit index

  • theta (float) – Rotation angle in radians

  • controls (list[int], optional) – Control qubit indices

  • control_values (list[int], optional) – Control qubit values

Returns:

RX gate instance

Return type:

Gate

Examples

>>> import math
>>> gate = RX(0, math.pi/2)  # π/2 rotation around X-axis
>>> gate = RX(1, math.pi, [0])  # Controlled-RX

Notes

If you need to use functions specific to the RXGate class, please downcast it.

scaluq.host.f64.gate.RY(target, theta, controls=[], control_values=[])

Generate rotation gate around Y-axis. Rotation angle is specified in radians.

Parameters:
  • target (int) – Target qubit index

  • theta (float) – Rotation angle in radians

  • controls (list[int], optional) – Control qubit indices

  • control_values (list[int], optional) – Control qubit values

Returns:

RY gate instance

Return type:

Gate

Examples

>>> import math
>>> gate = RY(0, math.pi/2)  # π/2 rotation around Y-axis
>>> gate = RY(1, math.pi, [0])  # Controlled-RY

Notes

If you need to use functions specific to the RYGate class, please downcast it.

scaluq.host.f64.gate.RZ(target, theta, controls=[], control_values=[])

Generate rotation gate around Z-axis. Rotation angle is specified in radians.

Parameters:
  • target (int) – Target qubit index

  • theta (float) – Rotation angle in radians

  • controls (list[int], optional) – Control qubit indices

  • control_values (list[int], optional) – Control qubit values

Returns:

RZ gate instance

Return type:

Gate

Examples

>>> import math
>>> gate = RZ(0, math.pi/2)  # π/2 rotation around Z-axis
>>> gate = RZ(1, math.pi, [0])  # Controlled-RZ

Notes

If you need to use functions specific to the RZGate class, please downcast it.

scaluq.host.f64.gate.U1(target, lambda_, controls=[], control_values=[])

Generate general Gate class instance of U1Gate.

Parameters:
  • target (int) – Target qubit index

  • lambda (float) – Rotation angle in radians

  • controls (list[int], optional) – Control qubit indices

  • control_values (list[int], optional) – Control qubit values

  • lambda_ (float)

Returns:

U1 gate instance

Return type:

Gate

Examples

>>> import math
>>> gate = U1(0, math.pi/2)  # π/2 rotation around Z-axis
>>> gate = U1(1, math.pi, [0])  # Controlled-U1

Notes

If you need to use functions specific to the U1Gate class, please downcast it.

scaluq.host.f64.gate.U2(target, phi, lambda_, controls=[], control_values=[])

Generate general Gate class instance of U2Gate.

Parameters:
  • target (int) – Target qubit index

  • phi (float) – Rotation angle in radians

  • lambda (float) – Rotation angle in radians

  • controls (list[int], optional) – Control qubit indices

  • control_values (list[int], optional) – Control qubit values

  • lambda_ (float)

Returns:

U2 gate instance

Return type:

Gate

Examples

>>> import math
>>> gate = U2(0, math.pi/2, math.pi)  # π/2 rotation around Z-axis
>>> gate = U2(1, math.pi, math.pi/2, [0])  # Controlled-U2

Notes

If you need to use functions specific to the U2Gate class, please downcast it.

scaluq.host.f64.gate.U3(target, theta, phi, lambda_, controls=[], control_values=[])

Generate general Gate class instance of U3Gate.

Parameters:
  • target (int) – Target qubit index

  • theta (float) – Rotation angle in radians

  • phi (float) – Rotation angle in radians

  • lambda (float) – Rotation angle in radians

  • controls (list[int], optional) – Control qubit indices

  • control_values (list[int], optional) – Control qubit values

  • lambda_ (float)

Returns:

U3 gate instance

Return type:

Gate

Examples

>>> import math
>>> gate = U3(0, math.pi/2, math.pi, math.pi)  # π/2 rotation around Z-axis
>>> gate = U3(1, math.pi, math.pi/2, math.pi, [0])  # Controlled-U3

Notes

If you need to use functions specific to the U3Gate class, please downcast it.

scaluq.host.f64.gate.Swap(target1, target2, controls=[], control_values=[])

Generate SWAP gate. Swaps the states of two qubits.

Parameters:
  • target1 (int) – First target qubit index

  • target2 (int) – Second target qubit index

  • controls (list[int], optional) – Control qubit indices

  • control_values (list[int], optional) – Control qubit values

Returns:

SWAP gate instance

Return type:

Gate

Examples

>>> gate = Swap(0, 1)  # Swap qubits 0 and 1
>>> gate = Swap(1, 2, [0])  # Controlled-SWAP

Notes

If you need to use functions specific to the SwapGate class, please downcast it.

scaluq.host.f64.gate.Ecr(physical_control, physical_target, controls=[], control_values=[])

Generate ECR gate. Echoed cross-resonance gate.

Parameters:
  • physical_control (int) – Physical control qubit index

  • physical_target (int) – Physical target qubit index

  • controls (list[int], optional) – Control qubit indices

  • control_values (list[int], optional) – Control qubit values

Returns:

Ecr gate instance

Return type:

Gate

Examples

>>> gate = Ecr(0, 1)  # control : 0 and target : 1
>>> gate = Ecr(1, 2, [0])  #Controlled-ECR

Notes

If you need to use functions specific to the EcrGate class, please downcast it.

scaluq.host.f64.gate.CX(control, target)

Generate general Gate class instance of XGate with one control qubit. Performs controlled-X operation.

Parameters:
  • control (int) – Control qubit index

  • target (int) – Target qubit index

Returns:

CX gate instance

Return type:

Gate

Examples

>>> gate = CX(0, 1)  # CX gate with control on qubit 0
>>> gate = CX(1, 2)  # CX gate with control on qubit 1

Notes

CX is a specialization of X. If you need to use functions specific to the XGate class, please downcast it.

scaluq.host.f64.gate.CNot(control, target)

Generate general Gate class instance of XGate with one control qubit. Performs controlled-X operation.

Parameters:
  • control (int) – Control qubit index

  • target (int) – Target qubit index

Returns:

CNot gate instance

Return type:

Gate

Examples

>>> gate = CNot(0, 1)  # CNot gate with control on qubit 0
>>> gate = CNot(1, 2)  # CNot gate with control on qubit 1

Notes

CNot is an alias of CX. If you need to use functions specific to the XGate class, please downcast it.

scaluq.host.f64.gate.CZ(control, target)

Generate general Gate class instance of ZGate with one control qubit. Performs controlled-Z operation.

Parameters:
  • control (int) – Control qubit index

  • target (int) – Target qubit index

Returns:

CZ gate instance

Return type:

Gate

Examples

>>> gate = CZ(0, 1)  # CZ gate with control on qubit 0
>>> gate = CZ(1, 2)  # CZ gate with control on qubit 1

Notes

CZ is a specialization of Z. If you need to use functions specific to the ZGate class, please downcast it.

scaluq.host.f64.gate.CCX(control1, control2, target)

Generate general Gate class instance of XGate with two control qubits. Performs controlled-controlled-X operation.

Parameters:
  • control1 (int) – First control qubit index

  • control2 (int) – Second control qubit index

  • target (int) – Target qubit index

Returns:

CCX gate instance

Return type:

Gate

Examples

>>> gate = CCX(0, 1, 2)  # CCX gate with controls on qubits 0 and 1
>>> gate = CCX(1, 2, 3)  # CCX gate with controls on qubits 1 and 2

Notes

If you need to use functions specific to the XGate class, please downcast it.

scaluq.host.f64.gate.CCNot(control1, control2, target)

Generate general Gate class instance of XGate with two control qubits. Performs controlled-controlled-X operation.

Parameters:
  • control1 (int) – First control qubit index

  • control2 (int) – Second control qubit index

  • target (int) – Target qubit index

Returns:

CCNot gate instance

Return type:

Gate

Examples

>>> gate = CCNot(0, 1, 2)  # CCNot gate with controls on qubits 0 and 1
>>> gate = CCNot(1, 2, 3)  # CCNot gate with controls on qubits 1 and 2

Notes

CCNot is an alias of CCX. If you need to use functions specific to the XGate class, please downcast it.

scaluq.host.f64.gate.Toffoli(control1, control2, target)

Generate general Gate class instance of XGate with two control qubits. Performs controlled-controlled-X operation.

Parameters:
  • control1 (int) – First control qubit index

  • control2 (int) – Second control qubit index

  • target (int) – Target qubit index

Returns:

Toffoli gate instance

Return type:

Gate

Examples

>>> gate = Toffoli(0, 1, 2)  # Toffoli gate with controls on qubits 0 and 1
>>> gate = Toffoli(1, 2, 3)  # Toffoli gate with controls on qubits 1 and 2

Notes

Toffoli is an alias of CCX. If you need to use functions specific to the XGate class, please downcast it.

scaluq.host.f64.gate.Pauli(pauli, controls=[], control_values=[])

Generate general Gate class instance of PauliGate. Performs Pauli operation.

Parameters:
  • pauli (PauliOperator) – Pauli operator

  • controls (list[int], optional) – Control qubit indices

  • control_values (list[int], optional) – Control qubit values

Returns:

Pauli gate instance

Return type:

Gate

Examples

>>> pauli = PauliOperator('X 0')
>>> gate = Pauli(pauli)
>>> gate = Pauli(pauli, [1])  # Controlled-Pauli

Notes

If you need to use functions specific to the PauliGate class, please downcast it.

scaluq.host.f64.gate.PauliRotation(pauli, theta, controls=[], control_values=[])

Generate general Gate class instance of PauliRotationGate. Performs Pauli rotation operation.

Parameters:
  • pauli (PauliOperator) – Pauli operator

  • theta (float) – Rotation angle in radians

  • controls (list[int], optional) – Control qubit indices

  • control_values (list[int], optional) – Control qubit values

Returns:

PauliRotation gate instance

Return type:

Gate

Examples

>>> pauli = PauliOperator('X 0')
>>> import math
>>> gate = PauliRotation(pauli, math.pi/2)
>>> gate = PauliRotation(pauli, math.pi/2, [1])  # Controlled-Pauli

Notes

If you need to use functions specific to the PauliRotationGate class, please downcast it.

scaluq.host.f64.gate.Probabilistic(distribution, gate_list)

Generate general Gate class instance of ProbabilisticGate. Performs probabilistic operation.

Parameters:
  • distribution (list[float]) – Probabilistic distribution

  • gate_list (list[Gate]) – List of gates

Returns:

Probabilistic gate instance

Return type:

Gate

Examples

>>> distribution = [0.3, 0.7]
>>> gate_list = [X(0), Y(0)]
>>> # X is applied with probability 0.3, Y is applied with probability 0.7
>>> gate = Probabilistic(distribution, gate_list)

Notes

If you need to use functions specific to the ProbabilisticGate class, please downcast it.

scaluq.host.f64.gate.BitFlipNoise(target, error_rate)

Generates a general Gate class instance of BitFlipNoise. error_rate is the probability of a bit-flip noise, corresponding to the X gate.

Parameters:
  • target (int)

  • error_rate (float)

Return type:

scaluq.scaluq_core.default.f64.Gate

scaluq.host.f64.gate.DephasingNoise(target, error_rate)

Generates a general Gate class instance of DephasingNoise. error_rate is the probability of a dephasing noise, corresponding to the Z gate.

Parameters:
  • target (int)

  • error_rate (float)

Return type:

scaluq.scaluq_core.default.f64.Gate

scaluq.host.f64.gate.BitFlipAndDephasingNoise(target, error_rate)

Generates a general Gate class instance of BitFlipAndDephasingNoise. error_rate is the probability of both bit-flip noise and dephasing noise, corresponding to the X gate and Z gate.

Parameters:
  • target (int)

  • error_rate (float)

Return type:

scaluq.scaluq_core.default.f64.Gate

scaluq.host.f64.gate.DepolarizingNoise(target, error_rate)

Generates a general Gate class instance of DepolarizingNoise. error_rate is the total probability of depolarizing noise, where an X, Y, or Z gate is applied with a probability of error_rate / 3 each.

Parameters:
  • target (int)

  • error_rate (float)

Return type:

scaluq.scaluq_core.default.f64.Gate

scaluq.host.f64.gate.ParamRX(target, coef=1.0, controls=[], control_values=[])

Generate general ParamGate class instance of ParamRXGate.

Parameters:
  • target (int) – Target qubit index

  • coef (float, optional) – Parameter coefficient

  • controls (list[int], optional) – Control qubit indices

  • control_values (list[int], optional) – Control qubit values

Returns:

ParamRX gate instance

Return type:

ParamGate

Examples

>>> gate = ParamRX(0)  # ParamRX gate on qubit 0
>>> gate = ParamRX(1, controls=[0])  # Controlled-ParamRX

Notes

If you need to use functions specific to the ParamRXGate class, please downcast it.

scaluq.host.f64.gate.ParamRY(target, coef=1.0, controls=[], control_values=[])

Generate general ParamGate class instance of ParamRYGate.

Parameters:
  • target (int) – Target qubit index

  • coef (float, optional) – Parameter coefficient

  • controls (list[int], optional) – Control qubit indices

  • control_values (list[int], optional) – Control qubit values

Returns:

ParamRY gate instance

Return type:

ParamGate

Examples

>>> gate = ParamRY(0)  # ParamRY gate on qubit 0
>>> gate = ParamRY(1, controls=[0])  # Controlled-ParamRY

Notes

If you need to use functions specific to the ParamRYGate class, please downcast it.

scaluq.host.f64.gate.ParamRZ(target, coef=1.0, controls=[], control_values=[])

Generate general ParamGate class instance of ParamRZGate.

Parameters:
  • target (int) – Target qubit index

  • coef (float, optional) – Parameter coefficient

  • controls (list[int], optional) – Control qubit indices

  • control_values (list[int], optional) – Control qubit values

Returns:

ParamRZ gate instance

Return type:

ParamGate

Examples

>>> gate = ParamRZ(0)  # ParamRZ gate on qubit 0
>>> gate = ParamRZ(1, controls=[0])  # Controlled-ParamRZ

Notes

If you need to use functions specific to the ParamRZGate class, please downcast it.

scaluq.host.f64.gate.ParamPauliRotation(pauli, coef=1.0, controls=[], control_values=[])

Generate general ParamGate class instance of ParamPauliRotationGate.

Parameters:
  • pauli (PauliOperator) – Pauli operator

  • coef (float, optional) – Parameter coefficient

  • controls (list[int], optional) – Control qubit indices

  • control_values (list[int], optional) – Control qubit values

Returns:

ParamPauliRotation gate instance

Return type:

ParamGate

Examples

>>> gate = ParamPauliRotation(PauliOperator(), 0.5)  # Pauli rotation gate with PauliOperator and coefficient 0.5
>>> gate = ParamPauliRotation(PauliOperator(), 0.5, [0])  # Controlled-ParamPauliRotation

Notes

If you need to use functions specific to the ParamPauliRotationGate class, please downcast it.

scaluq.host.f64.gate.ParamProbabilistic(distribution, gate_list)

Generate general ParamGate class instance of ParamProbabilisticGate.

Parameters:
  • distribution (list[float]) – List of probability

  • gate_list (list[Union[Gate, ParamGate]]) – List of gates

  • prob_gate_list (collections.abc.Sequence[tuple[float, scaluq.scaluq_core.default.f64.Gate | scaluq.scaluq_core.default.f64.ParamGate]])

Returns:

ParamProbabilistic gate instance

Return type:

ParamGate

Examples

>>> gate = ParamProbabilistic([0.1, 0.9], [X(0), ParamRX(0, 0.5)])  # probabilistic gate with X and ParamRX
scaluq.host.f64.gate.ParamProbabilistic(prob_gate_list)

Generate general ParamGate class instance of ParamProbabilisticGate.

Parameters:

prob_gate_list (list[tuple[float, Union[Gate, ParamGate]]]) – List of tuple of probability and gate

Returns:

ParamProbabilistic gate instance

Return type:

ParamGate

Examples

>>> gate = ParamProbabilistic([(0.1, X(0)), (0.9, I())])  # probabilistic gate with X and I