PauliX#

class torchquantum.operator.PauliX(has_params: bool = False, trainable: bool = False, init_params=None, n_wires=None, wires=None, inverse=False)[source]#

Bases: Observable

Class for Pauli X Gate.

__init__(has_params: bool = False, trainable: bool = False, init_params=None, n_wires=None, wires=None, inverse=False)#

Init function of the Observable class

Parameters:
  • has_params (bool, optional) – Whether the operations has parameters. Defaults to False.

  • trainable (bool, optional) – Whether the parameters are trainable (if contains parameters). Defaults to False.

  • init_params (torch.Tensor, optional) – Initial parameters. Defaults to None.

  • n_wires (int, optional) – Number of qubits. Defaults to None.

  • wires (Union[int, List[int]], optional) – Which qubit the operation is applied to. Defaults to None.

Methods

diagonalizing_gates()[source]#

The diagonalizing gates when perform measurements.

Returns: None.

static func(q_device, wires, params=None, n_wires=None, static=False, parent_graph=None, inverse=False, comp_method='bmm')#

Perform the Pauli X gate.

Parameters:
  • q_device (tq.QuantumDevice) – The QuantumDevice.

  • wires (Union[List[int], int]) – Which qubit(s) to apply the gate.

  • params (torch.Tensor, optional) – Parameters (if any) of the gate. Default to None.

  • n_wires (int, optional) – Number of qubits the gate is applied to. Default to None.

  • static (bool, optional) – Whether use static mode computation. Default to False.

  • parent_graph (tq.QuantumGraph, optional) – Parent QuantumGraph of current operation. Default to None.

  • inverse (bool, optional) – Whether inverse the gate. Default to False.

  • comp_method (bool, optional) – Use ‘bmm’ or ‘einsum’ method to perform

  • 'bmm'. (matrix vector multiplication. Default to) –

Returns:

None.

Attributes

eigvals = tensor([ 1.+0.j, -1.+0.j])#
matrix = tensor([[0.+0.j, 1.+0.j],         [1.+0.j, 0.+0.j]])#
num_params = 0#
num_wires = 1#
op_name = 'paulix'#
training: bool#