paddle_quantum.gate.matrix

The library of gate matrices.

paddle_quantum.gate.matrix.h_gate(dtype=None)

Generate the matrix

H=12[1111]
Parameters:

dtype (str | None) – the dtype of this matrix. Defaults to None.

Returns:

the matrix of H gate.

Return type:

Tensor

paddle_quantum.gate.matrix.s_gate(dtype=None)

Generate the matrix

S=[100i]
Parameters:

dtype (str | None) – the dtype of this matrix. Defaults to None.

Returns:

the matrix of S gate.

Return type:

Tensor

paddle_quantum.gate.matrix.sdg_gate(dtype=None)

Generate the matrix

S=[100i]
Parameters:

dtype (str | None) – the dtype of this matrix. Defaults to None.

Returns:

the matrix of Sdg gate.

Return type:

Tensor

paddle_quantum.gate.matrix.t_gate(dtype=None)

Generate the matrix

T=[100eiπ4]
Parameters:

dtype (str | None) – the dtype of this matrix. Defaults to None.

Returns:

the matrix of T gate.

Return type:

Tensor

paddle_quantum.gate.matrix.tdg_gate(dtype=None)

Generate the matrix

T=[100eiπ4]
Parameters:

dtype (str | None) – the dtype of this matrix. Defaults to None.

Returns:

the matrix of Sdg gate.

Return type:

Tensor

paddle_quantum.gate.matrix.x_gate(dtype=None)

Generate the matrix

X=[0110]
Parameters:

dtype (str | None) – the dtype of this matrix. Defaults to None.

Returns:

the matrix of X gate.

Return type:

Tensor

paddle_quantum.gate.matrix.y_gate(dtype=None)

Generate the matrix

Y=[0ii0]
Parameters:

dtype (str | None) – the dtype of this matrix. Defaults to None.

Returns:

the matrix of Y gate.

Return type:

Tensor

paddle_quantum.gate.matrix.z_gate(dtype=None)

Generate the matrix

Z=[1001]
Parameters:

dtype (str | None) – the dtype of this matrix. Defaults to None.

Returns:

the matrix of Z gate.

Return type:

Tensor

paddle_quantum.gate.matrix.p_gate(theta)

Generate the matrix

P(θ)=[100eiθ]
Parameters:

theta (Tensor) – the parameter of this matrix.

Returns:

the matrix of P gate.

Return type:

Tensor

paddle_quantum.gate.matrix.rx_gate(theta)

Generate the matrix

RX(θ)=[cosθ2isinθ2isinθ2cosθ2]
Parameters:

theta (Tensor) – the parameter of this matrix.

Returns:

the matrix of R_X gate.

Return type:

Tensor

paddle_quantum.gate.matrix.ry_gate(theta)

Generate the matrix

RY(θ)=[cosθ2sinθ2sinθ2cosθ2]
Parameters:

theta (Tensor) – the parameter of this matrix.

Returns:

the matrix of R_Y gate.

Return type:

Tensor

paddle_quantum.gate.matrix.rz_gate(theta)

Generate the matrix

RZ(θ)=[eiθ200eiθ2]
Parameters:

theta (Tensor) – the parameter of this matrix.

Returns:

the matrix of R_Z gate.

Return type:

Tensor

paddle_quantum.gate.matrix.u3_gate(theta)

Generate the matrix

U3(θ,ϕ,λ)=[cosθ2eiλsinθ2eiϕsinθ2ei(ϕ+λ)cosθ2]
Parameters:

theta (Tensor) – the parameter of this matrix.

Returns:

the matrix of U_3 gate.

Return type:

Tensor

paddle_quantum.gate.matrix.cnot_gate(dtype=None)

Generate the matrix

CNOT=|00|I+|11|X=[1000010000010010]
Parameters:

dtype (str | None) – the dtype of this matrix. Defaults to None.

Returns:

the matrix of CNOT gate.

Return type:

Tensor

paddle_quantum.gate.matrix.cy_gate(dtype=None)

Generate the matrix

CY=|00|I+|11|Y=[10000100000i00i0]
Parameters:

dtype (str | None) – the dtype of this matrix. Defaults to None.

Returns:

the matrix of CY gate.

Return type:

Tensor

paddle_quantum.gate.matrix.cz_gate(dtype=None)

Generate the matrix

CZ=|00|I+|11|Z=[1000010000100001]
Parameters:

dtype (str | None) – the dtype of this matrix. Defaults to None.

Returns:

the matrix of CZ gate.

Return type:

Tensor

paddle_quantum.gate.matrix.swap_gate(dtype=None)

Generate the matrix

SWAP=[1000001001000001]
Parameters:

dtype (str | None) – the dtype of this matrix. Defaults to None.

Returns:

the matrix of SWAP gate.

Return type:

Tensor

paddle_quantum.gate.matrix.cp_gate(theta)

Generate the matrix

CP(θ)=[100001000010000eiθ]
Parameters:

theta (Tensor) – the parameter of this matrix.

Returns:

the matrix of CP gate.

Return type:

Tensor

paddle_quantum.gate.matrix.crx_gate(theta)

Generate the matrix

CRX=|00|I+|11|RX=[1000010000cosθ2isinθ200isinθ2cosθ2]
Parameters:

theta (Tensor) – the parameter of this matrix.

Returns:

the matrix of CR_X gate.

Return type:

Tensor

paddle_quantum.gate.matrix.cry_gate(theta)

Generate the matrix

CRY=|00|I+|11|RY=[1000010000cosθ2sinθ200sinθ2cosθ2]
Parameters:

theta (Tensor) – the parameter of this matrix.

Returns:

the matrix of CR_Y gate.

Return type:

Tensor

paddle_quantum.gate.matrix.crz_gate(theta)

Generate the matrix

CRZ=|00|I+|11|RZ=[1000010000eiθ20000eiθ2]
Parameters:

theta (Tensor) – the parameter of this matrix.

Returns:

the matrix of CR_Z gate.

Return type:

Tensor

paddle_quantum.gate.matrix.cu_gate(theta)

Generate the matrix

CU=[1000010000cosθ2eiλsinθ200eiϕsinθ2ei(ϕ+λ)cosθ2]
Parameters:

theta (Tensor) – the parameter of this matrix.

Returns:

the matrix of CU gate.

Return type:

Tensor

paddle_quantum.gate.matrix.rxx_gate(theta)

Generate the matrix

RXX(θ)=[cosθ200isinθ20cosθ2isinθ200isinθ2cosθ20isinθ200cosθ2]
Parameters:

theta (Tensor) – the parameter of this matrix.

Returns:

the matrix of RXX gate.

Return type:

Tensor

paddle_quantum.gate.matrix.ryy_gate(theta)

Generate the matrix

RYY(θ)=[cosθ200isinθ20cosθ2isinθ200isinθ2cosθ20isinθ200cosθ2]
Parameters:

theta (Tensor) – the parameter of this matrix.

Returns:

the matrix of RYY gate.

Return type:

Tensor

paddle_quantum.gate.matrix.rzz_gate(theta)

Generate the matrix

RZZ(θ)=[eiθ20000eiθ20000eiθ20000eiθ2]
Parameters:

theta (Tensor) – the parameter of this matrix.

Returns:

the matrix of RZZ gate.

Return type:

Tensor

paddle_quantum.gate.matrix.ms_gate(dtype=None)

Generate the matrix

MS=RXX(π2)=12[100i01i00i10i001]
Parameters:

dtype (str | None) – the dtype of this matrix. Defaults to None.

Returns:

the matrix of MS gate.

Return type:

Tensor

paddle_quantum.gate.matrix.cswap_gate(dtype=None)

Generate the matrix

CSWAP=[1000000001000000001000000001000000001000000000100000010000000001]
Parameters:

dtype (str | None) – the dtype of this matrix. Defaults to None.

Returns:

the matrix of CSWAP gate.

Return type:

Tensor

paddle_quantum.gate.matrix.toffoli_gate(dtype=None)

Generate the matrix

CSWAP=[1000000001000000001000000001000000001000000001000000000100000010]
Parameters:

dtype (str | None) – the dtype of this matrix. Defaults to None.

Returns:

the matrix of Toffoli gate.

Return type:

Tensor

paddle_quantum.gate.matrix.universal2_gate(theta)

Generate the matrix

Parameters:

theta (Tensor) – the parameter of this matrix.

Returns:

the matrix of universal two qubits gate.

Return type:

Tensor

paddle_quantum.gate.matrix.universal3_gate(theta)

Generate the matrix

Parameters:

theta (Tensor) – the parameter of this matrix.

Returns:

the matrix of universal three qubits gate.

Return type:

Tensor