QPanda3  0.1.0
Supported by OriginQ
Loading...
Searching...
No Matches
pyqpanda3.hamiltonian.PauliOperator Class Reference

Public Member Functions

None __init__ (self)
 init(*args, **kwargs) Overloaded function.
 
None __init__ (self, PauliOperator pauli_operator)
 init(*args, **kwargs) Overloaded function.
 
None __init__ (self, str pauli)
 init(*args, **kwargs) Overloaded function.
 
None __init__ (self, dict[str, complex] pauli_with_coef_s)
 init(*args, **kwargs) Overloaded function.
 
None __init__ (self, list[str] paulis, list[complex] coefs)
 init(*args, **kwargs) Overloaded function.
 
None __init__ (self, list[str] paulis, list[complex] coefs, bool AB_is_A1_B0)
 init(*args, **kwargs) Overloaded function.
 
None __init__ (self, list[tuple[str, list[int], complex]] paulis_qbits_coef__s)
 init(*args, **kwargs) Overloaded function.
 
str str_no_I (self)
 str_no_I(self: hamiltonian.PauliOperator) -> str
 
str str_with_I (self, bool AB_is_A1_B0=...)
 str_with_I(self: hamiltonian.PauliOperator, AB_is_A1_B0: bool = True) -> str
 
str str_withou_I (self)
 str_withou_I(self: hamiltonian.PauliOperator) -> str
 
PauliOperator tensor (self, PauliOperator other)
 tensor(*args, **kwargs) Overloaded function.
 
PauliOperator tensor (self, int n)
 tensor(*args, **kwargs) Overloaded function.
 
PauliOperator __add__ (self, PauliOperator other)
 add(self: hamiltonian.PauliOperator, other: hamiltonian.PauliOperator) -> hamiltonian.PauliOperator
 
bool __eq__ (self, PauliOperator other)
 eq(self: hamiltonian.PauliOperator, other: hamiltonian.PauliOperator) -> bool
 
PauliOperator __iadd__ (self, PauliOperator other)
 iadd(self: hamiltonian.PauliOperator, other: hamiltonian.PauliOperator) -> hamiltonian.PauliOperator
 
PauliOperator __imul__ (self, PauliOperator other)
 imul(self: hamiltonian.PauliOperator, other: hamiltonian.PauliOperator) -> hamiltonian.PauliOperator
 
PauliOperator __isub__ (self, PauliOperator other)
 isub(self: hamiltonian.PauliOperator, other: hamiltonian.PauliOperator) -> hamiltonian.PauliOperator
 
PauliOperator __matmul__ (self, PauliOperator other)
 matmul(self: hamiltonian.PauliOperator, other: hamiltonian.PauliOperator) -> hamiltonian.PauliOperator
 
PauliOperator __mul__ (self, PauliOperator other)
 mul(*args, **kwargs) Overloaded function.
 
PauliOperator __mul__ (self, complex scalar)
 mul(*args, **kwargs) Overloaded function.
 
PauliOperator __rmul__ (self, complex scalar)
 rmul(self: hamiltonian.PauliOperator, scalar: complex) -> hamiltonian.PauliOperator
 
PauliOperator __sub__ (self, PauliOperator other)
 sub(self: hamiltonian.PauliOperator, other: hamiltonian.PauliOperator) -> hamiltonian.PauliOperator
 

Constructor & Destructor Documentation

◆ __init__() [1/7]

None pyqpanda3.hamiltonian.PauliOperator.__init__ ( self)

init(*args, **kwargs) Overloaded function.

  1. init(self: hamiltonian.PauliOperator) -> None

Constructs a default PauliOperator object.

This constructor initializes a new PauliOperator object with default values. The default behavior may include setting the operator to an identity or null state, depending on the implementation details.

  1. init(self: hamiltonian.PauliOperator, pauli_operator: hamiltonian.PauliOperator) -> None

Copy constructor for PauliOperator.

This constructor creates a new PauliOperator object that is a copy of an existing PauliOperator object. It initializes the new object with the same state and values as the provided other object.

Parameters
otherThe PauliOperator object to copy from.
  1. init(self: hamiltonian.PauliOperator, pauli: str) -> None

Constructs a PauliOperator from a string representation.

This constructor initializes a new PauliOperator object based on a given string a_pauli that represents a Pauli operator. The specific format and interpretation of the string are defined by the implementation.

Parameters
a_pauliThe string representation of the Pauli operator.
  1. init(self: hamiltonian.PauliOperator, pauli_with_coef_s: dict[str, complex]) -> None

Constructs a PauliOperator from a string representation.

This constructor initializes a new PauliOperator object based on a given string a_pauli that represents a Pauli operator. The specific format and interpretation of the string are defined by the implementation. input like: {\"X0 Z1\\":1.1,\\"Y2 I1\\":2.1+0.j}

Parameters
a_pauliThe string representation of the Pauli operator.
  1. init(self: hamiltonian.PauliOperator, paulis: list[str], coefs: list[complex]) -> None

Constructs a PauliOperator from vectors of operations and coefficients.

This constructor initializes a new PauliOperator object based on two given vectors: ops containing string representations of Pauli operator symbols, and coef_s containing the corresponding std::complex<double> coefficients. The length of both vectors should be the same, and each pair of elements (one from ops and one from coef_s) represents a term in the Pauli operator. input like: [\"X0 Z1\\",\\"Y2 I1\\"],[1.1+0.j,2.1+0.j]

Parameters
opsThe vector of Pauli operator symbols.
coef_sThe vector of corresponding coefficients.
a_pauliThe string representation of the Pauli operator.
  1. init(self: hamiltonian.PauliOperator, paulis: list[str], coefs: list[complex], AB_is_A1_B0: bool) -> None

Constructs a PauliOperator from vectors of operations, coefficients, and an additional boolean flag.

This constructor initializes a new PauliOperator object based on two given vectors: ops containing string representations of Pauli operator symbols, and coef_s containing the corresponding std::complex<double> coefficients. Additionally, it takes a boolean flag A which may affect the initialization process or the behavior of the constructed PauliOperator object. The length of both vectors ops and coef_s should be the same, and each pair of elements (one from ops and one from coef_s) represents a term in the Pauli operator. input like: [\"XZI\\",\\"IZX\\"],[1.1+0.j,2.1+0.j],true

Parameters
opsThe vector of Pauli operator symbols.
coef_sThe vector of corresponding coefficients.
AThe boolean flag that may affect the initialization or behavior.
  1. init(self: hamiltonian.PauliOperator, paulis_qbits_coef__s: list[tuple[str, list[int], complex]]) -> None

Constructs a PauliOperator from a vector of tuples.

This constructor initializes a new PauliOperator object based on a given vector of tuples ops. Each tuple contains three elements: a string representing a Pauli operator symbol, a vector of size_t indices, and a std::complex<double> coefficient. The vector of tuples represents a collection of terms in the Pauli operator, where each term is specified by its operator symbol, indices (if applicable), and coefficient. input like: [(\"XZ\\",[0,4],1.1+0.j),(\\"YX\\",[1,2],2.1+0.j)]

Parameters
opsThe vector of tuples containing Pauli operator symbols, indices, and coefficients.

◆ __init__() [2/7]

None pyqpanda3.hamiltonian.PauliOperator.__init__ ( self,
PauliOperator pauli_operator )

init(*args, **kwargs) Overloaded function.

  1. init(self: hamiltonian.PauliOperator) -> None

Constructs a default PauliOperator object.

This constructor initializes a new PauliOperator object with default values. The default behavior may include setting the operator to an identity or null state, depending on the implementation details.

  1. init(self: hamiltonian.PauliOperator, pauli_operator: hamiltonian.PauliOperator) -> None

Copy constructor for PauliOperator.

This constructor creates a new PauliOperator object that is a copy of an existing PauliOperator object. It initializes the new object with the same state and values as the provided other object.

Parameters
otherThe PauliOperator object to copy from.
  1. init(self: hamiltonian.PauliOperator, pauli: str) -> None

Constructs a PauliOperator from a string representation.

This constructor initializes a new PauliOperator object based on a given string a_pauli that represents a Pauli operator. The specific format and interpretation of the string are defined by the implementation.

Parameters
a_pauliThe string representation of the Pauli operator.
  1. init(self: hamiltonian.PauliOperator, pauli_with_coef_s: dict[str, complex]) -> None

Constructs a PauliOperator from a string representation.

This constructor initializes a new PauliOperator object based on a given string a_pauli that represents a Pauli operator. The specific format and interpretation of the string are defined by the implementation. input like: {\"X0 Z1\\":1.1,\\"Y2 I1\\":2.1+0.j}

Parameters
a_pauliThe string representation of the Pauli operator.
  1. init(self: hamiltonian.PauliOperator, paulis: list[str], coefs: list[complex]) -> None

Constructs a PauliOperator from vectors of operations and coefficients.

This constructor initializes a new PauliOperator object based on two given vectors: ops containing string representations of Pauli operator symbols, and coef_s containing the corresponding std::complex<double> coefficients. The length of both vectors should be the same, and each pair of elements (one from ops and one from coef_s) represents a term in the Pauli operator. input like: [\"X0 Z1\\",\\"Y2 I1\\"],[1.1+0.j,2.1+0.j]

Parameters
opsThe vector of Pauli operator symbols.
coef_sThe vector of corresponding coefficients.
a_pauliThe string representation of the Pauli operator.
  1. init(self: hamiltonian.PauliOperator, paulis: list[str], coefs: list[complex], AB_is_A1_B0: bool) -> None

Constructs a PauliOperator from vectors of operations, coefficients, and an additional boolean flag.

This constructor initializes a new PauliOperator object based on two given vectors: ops containing string representations of Pauli operator symbols, and coef_s containing the corresponding std::complex<double> coefficients. Additionally, it takes a boolean flag A which may affect the initialization process or the behavior of the constructed PauliOperator object. The length of both vectors ops and coef_s should be the same, and each pair of elements (one from ops and one from coef_s) represents a term in the Pauli operator. input like: [\"XZI\\",\\"IZX\\"],[1.1+0.j,2.1+0.j],true

Parameters
opsThe vector of Pauli operator symbols.
coef_sThe vector of corresponding coefficients.
AThe boolean flag that may affect the initialization or behavior.
  1. init(self: hamiltonian.PauliOperator, paulis_qbits_coef__s: list[tuple[str, list[int], complex]]) -> None

Constructs a PauliOperator from a vector of tuples.

This constructor initializes a new PauliOperator object based on a given vector of tuples ops. Each tuple contains three elements: a string representing a Pauli operator symbol, a vector of size_t indices, and a std::complex<double> coefficient. The vector of tuples represents a collection of terms in the Pauli operator, where each term is specified by its operator symbol, indices (if applicable), and coefficient. input like: [(\"XZ\\",[0,4],1.1+0.j),(\\"YX\\",[1,2],2.1+0.j)]

Parameters
opsThe vector of tuples containing Pauli operator symbols, indices, and coefficients.

◆ __init__() [3/7]

None pyqpanda3.hamiltonian.PauliOperator.__init__ ( self,
str pauli )

init(*args, **kwargs) Overloaded function.

  1. init(self: hamiltonian.PauliOperator) -> None

Constructs a default PauliOperator object.

This constructor initializes a new PauliOperator object with default values. The default behavior may include setting the operator to an identity or null state, depending on the implementation details.

  1. init(self: hamiltonian.PauliOperator, pauli_operator: hamiltonian.PauliOperator) -> None

Copy constructor for PauliOperator.

This constructor creates a new PauliOperator object that is a copy of an existing PauliOperator object. It initializes the new object with the same state and values as the provided other object.

Parameters
otherThe PauliOperator object to copy from.
  1. init(self: hamiltonian.PauliOperator, pauli: str) -> None

Constructs a PauliOperator from a string representation.

This constructor initializes a new PauliOperator object based on a given string a_pauli that represents a Pauli operator. The specific format and interpretation of the string are defined by the implementation.

Parameters
a_pauliThe string representation of the Pauli operator.
  1. init(self: hamiltonian.PauliOperator, pauli_with_coef_s: dict[str, complex]) -> None

Constructs a PauliOperator from a string representation.

This constructor initializes a new PauliOperator object based on a given string a_pauli that represents a Pauli operator. The specific format and interpretation of the string are defined by the implementation. input like: {\"X0 Z1\\":1.1,\\"Y2 I1\\":2.1+0.j}

Parameters
a_pauliThe string representation of the Pauli operator.
  1. init(self: hamiltonian.PauliOperator, paulis: list[str], coefs: list[complex]) -> None

Constructs a PauliOperator from vectors of operations and coefficients.

This constructor initializes a new PauliOperator object based on two given vectors: ops containing string representations of Pauli operator symbols, and coef_s containing the corresponding std::complex<double> coefficients. The length of both vectors should be the same, and each pair of elements (one from ops and one from coef_s) represents a term in the Pauli operator. input like: [\"X0 Z1\\",\\"Y2 I1\\"],[1.1+0.j,2.1+0.j]

Parameters
opsThe vector of Pauli operator symbols.
coef_sThe vector of corresponding coefficients.
a_pauliThe string representation of the Pauli operator.
  1. init(self: hamiltonian.PauliOperator, paulis: list[str], coefs: list[complex], AB_is_A1_B0: bool) -> None

Constructs a PauliOperator from vectors of operations, coefficients, and an additional boolean flag.

This constructor initializes a new PauliOperator object based on two given vectors: ops containing string representations of Pauli operator symbols, and coef_s containing the corresponding std::complex<double> coefficients. Additionally, it takes a boolean flag A which may affect the initialization process or the behavior of the constructed PauliOperator object. The length of both vectors ops and coef_s should be the same, and each pair of elements (one from ops and one from coef_s) represents a term in the Pauli operator. input like: [\"XZI\\",\\"IZX\\"],[1.1+0.j,2.1+0.j],true

Parameters
opsThe vector of Pauli operator symbols.
coef_sThe vector of corresponding coefficients.
AThe boolean flag that may affect the initialization or behavior.
  1. init(self: hamiltonian.PauliOperator, paulis_qbits_coef__s: list[tuple[str, list[int], complex]]) -> None

Constructs a PauliOperator from a vector of tuples.

This constructor initializes a new PauliOperator object based on a given vector of tuples ops. Each tuple contains three elements: a string representing a Pauli operator symbol, a vector of size_t indices, and a std::complex<double> coefficient. The vector of tuples represents a collection of terms in the Pauli operator, where each term is specified by its operator symbol, indices (if applicable), and coefficient. input like: [(\"XZ\\",[0,4],1.1+0.j),(\\"YX\\",[1,2],2.1+0.j)]

Parameters
opsThe vector of tuples containing Pauli operator symbols, indices, and coefficients.

◆ __init__() [4/7]

None pyqpanda3.hamiltonian.PauliOperator.__init__ ( self,
dict[str, complex] pauli_with_coef_s )

init(*args, **kwargs) Overloaded function.

  1. init(self: hamiltonian.PauliOperator) -> None

Constructs a default PauliOperator object.

This constructor initializes a new PauliOperator object with default values. The default behavior may include setting the operator to an identity or null state, depending on the implementation details.

  1. init(self: hamiltonian.PauliOperator, pauli_operator: hamiltonian.PauliOperator) -> None

Copy constructor for PauliOperator.

This constructor creates a new PauliOperator object that is a copy of an existing PauliOperator object. It initializes the new object with the same state and values as the provided other object.

Parameters
otherThe PauliOperator object to copy from.
  1. init(self: hamiltonian.PauliOperator, pauli: str) -> None

Constructs a PauliOperator from a string representation.

This constructor initializes a new PauliOperator object based on a given string a_pauli that represents a Pauli operator. The specific format and interpretation of the string are defined by the implementation.

Parameters
a_pauliThe string representation of the Pauli operator.
  1. init(self: hamiltonian.PauliOperator, pauli_with_coef_s: dict[str, complex]) -> None

Constructs a PauliOperator from a string representation.

This constructor initializes a new PauliOperator object based on a given string a_pauli that represents a Pauli operator. The specific format and interpretation of the string are defined by the implementation. input like: {\"X0 Z1\\":1.1,\\"Y2 I1\\":2.1+0.j}

Parameters
a_pauliThe string representation of the Pauli operator.
  1. init(self: hamiltonian.PauliOperator, paulis: list[str], coefs: list[complex]) -> None

Constructs a PauliOperator from vectors of operations and coefficients.

This constructor initializes a new PauliOperator object based on two given vectors: ops containing string representations of Pauli operator symbols, and coef_s containing the corresponding std::complex<double> coefficients. The length of both vectors should be the same, and each pair of elements (one from ops and one from coef_s) represents a term in the Pauli operator. input like: [\"X0 Z1\\",\\"Y2 I1\\"],[1.1+0.j,2.1+0.j]

Parameters
opsThe vector of Pauli operator symbols.
coef_sThe vector of corresponding coefficients.
a_pauliThe string representation of the Pauli operator.
  1. init(self: hamiltonian.PauliOperator, paulis: list[str], coefs: list[complex], AB_is_A1_B0: bool) -> None

Constructs a PauliOperator from vectors of operations, coefficients, and an additional boolean flag.

This constructor initializes a new PauliOperator object based on two given vectors: ops containing string representations of Pauli operator symbols, and coef_s containing the corresponding std::complex<double> coefficients. Additionally, it takes a boolean flag A which may affect the initialization process or the behavior of the constructed PauliOperator object. The length of both vectors ops and coef_s should be the same, and each pair of elements (one from ops and one from coef_s) represents a term in the Pauli operator. input like: [\"XZI\\",\\"IZX\\"],[1.1+0.j,2.1+0.j],true

Parameters
opsThe vector of Pauli operator symbols.
coef_sThe vector of corresponding coefficients.
AThe boolean flag that may affect the initialization or behavior.
  1. init(self: hamiltonian.PauliOperator, paulis_qbits_coef__s: list[tuple[str, list[int], complex]]) -> None

Constructs a PauliOperator from a vector of tuples.

This constructor initializes a new PauliOperator object based on a given vector of tuples ops. Each tuple contains three elements: a string representing a Pauli operator symbol, a vector of size_t indices, and a std::complex<double> coefficient. The vector of tuples represents a collection of terms in the Pauli operator, where each term is specified by its operator symbol, indices (if applicable), and coefficient. input like: [(\"XZ\\",[0,4],1.1+0.j),(\\"YX\\",[1,2],2.1+0.j)]

Parameters
opsThe vector of tuples containing Pauli operator symbols, indices, and coefficients.

◆ __init__() [5/7]

None pyqpanda3.hamiltonian.PauliOperator.__init__ ( self,
list[str] paulis,
list[complex] coefs )

init(*args, **kwargs) Overloaded function.

  1. init(self: hamiltonian.PauliOperator) -> None

Constructs a default PauliOperator object.

This constructor initializes a new PauliOperator object with default values. The default behavior may include setting the operator to an identity or null state, depending on the implementation details.

  1. init(self: hamiltonian.PauliOperator, pauli_operator: hamiltonian.PauliOperator) -> None

Copy constructor for PauliOperator.

This constructor creates a new PauliOperator object that is a copy of an existing PauliOperator object. It initializes the new object with the same state and values as the provided other object.

Parameters
otherThe PauliOperator object to copy from.
  1. init(self: hamiltonian.PauliOperator, pauli: str) -> None

Constructs a PauliOperator from a string representation.

This constructor initializes a new PauliOperator object based on a given string a_pauli that represents a Pauli operator. The specific format and interpretation of the string are defined by the implementation.

Parameters
a_pauliThe string representation of the Pauli operator.
  1. init(self: hamiltonian.PauliOperator, pauli_with_coef_s: dict[str, complex]) -> None

Constructs a PauliOperator from a string representation.

This constructor initializes a new PauliOperator object based on a given string a_pauli that represents a Pauli operator. The specific format and interpretation of the string are defined by the implementation. input like: {\"X0 Z1\\":1.1,\\"Y2 I1\\":2.1+0.j}

Parameters
a_pauliThe string representation of the Pauli operator.
  1. init(self: hamiltonian.PauliOperator, paulis: list[str], coefs: list[complex]) -> None

Constructs a PauliOperator from vectors of operations and coefficients.

This constructor initializes a new PauliOperator object based on two given vectors: ops containing string representations of Pauli operator symbols, and coef_s containing the corresponding std::complex<double> coefficients. The length of both vectors should be the same, and each pair of elements (one from ops and one from coef_s) represents a term in the Pauli operator. input like: [\"X0 Z1\\",\\"Y2 I1\\"],[1.1+0.j,2.1+0.j]

Parameters
opsThe vector of Pauli operator symbols.
coef_sThe vector of corresponding coefficients.
a_pauliThe string representation of the Pauli operator.
  1. init(self: hamiltonian.PauliOperator, paulis: list[str], coefs: list[complex], AB_is_A1_B0: bool) -> None

Constructs a PauliOperator from vectors of operations, coefficients, and an additional boolean flag.

This constructor initializes a new PauliOperator object based on two given vectors: ops containing string representations of Pauli operator symbols, and coef_s containing the corresponding std::complex<double> coefficients. Additionally, it takes a boolean flag A which may affect the initialization process or the behavior of the constructed PauliOperator object. The length of both vectors ops and coef_s should be the same, and each pair of elements (one from ops and one from coef_s) represents a term in the Pauli operator. input like: [\"XZI\\",\\"IZX\\"],[1.1+0.j,2.1+0.j],true

Parameters
opsThe vector of Pauli operator symbols.
coef_sThe vector of corresponding coefficients.
AThe boolean flag that may affect the initialization or behavior.
  1. init(self: hamiltonian.PauliOperator, paulis_qbits_coef__s: list[tuple[str, list[int], complex]]) -> None

Constructs a PauliOperator from a vector of tuples.

This constructor initializes a new PauliOperator object based on a given vector of tuples ops. Each tuple contains three elements: a string representing a Pauli operator symbol, a vector of size_t indices, and a std::complex<double> coefficient. The vector of tuples represents a collection of terms in the Pauli operator, where each term is specified by its operator symbol, indices (if applicable), and coefficient. input like: [(\"XZ\\",[0,4],1.1+0.j),(\\"YX\\",[1,2],2.1+0.j)]

Parameters
opsThe vector of tuples containing Pauli operator symbols, indices, and coefficients.

◆ __init__() [6/7]

None pyqpanda3.hamiltonian.PauliOperator.__init__ ( self,
list[str] paulis,
list[complex] coefs,
bool AB_is_A1_B0 )

init(*args, **kwargs) Overloaded function.

  1. init(self: hamiltonian.PauliOperator) -> None

Constructs a default PauliOperator object.

This constructor initializes a new PauliOperator object with default values. The default behavior may include setting the operator to an identity or null state, depending on the implementation details.

  1. init(self: hamiltonian.PauliOperator, pauli_operator: hamiltonian.PauliOperator) -> None

Copy constructor for PauliOperator.

This constructor creates a new PauliOperator object that is a copy of an existing PauliOperator object. It initializes the new object with the same state and values as the provided other object.

Parameters
otherThe PauliOperator object to copy from.
  1. init(self: hamiltonian.PauliOperator, pauli: str) -> None

Constructs a PauliOperator from a string representation.

This constructor initializes a new PauliOperator object based on a given string a_pauli that represents a Pauli operator. The specific format and interpretation of the string are defined by the implementation.

Parameters
a_pauliThe string representation of the Pauli operator.
  1. init(self: hamiltonian.PauliOperator, pauli_with_coef_s: dict[str, complex]) -> None

Constructs a PauliOperator from a string representation.

This constructor initializes a new PauliOperator object based on a given string a_pauli that represents a Pauli operator. The specific format and interpretation of the string are defined by the implementation. input like: {\"X0 Z1\\":1.1,\\"Y2 I1\\":2.1+0.j}

Parameters
a_pauliThe string representation of the Pauli operator.
  1. init(self: hamiltonian.PauliOperator, paulis: list[str], coefs: list[complex]) -> None

Constructs a PauliOperator from vectors of operations and coefficients.

This constructor initializes a new PauliOperator object based on two given vectors: ops containing string representations of Pauli operator symbols, and coef_s containing the corresponding std::complex<double> coefficients. The length of both vectors should be the same, and each pair of elements (one from ops and one from coef_s) represents a term in the Pauli operator. input like: [\"X0 Z1\\",\\"Y2 I1\\"],[1.1+0.j,2.1+0.j]

Parameters
opsThe vector of Pauli operator symbols.
coef_sThe vector of corresponding coefficients.
a_pauliThe string representation of the Pauli operator.
  1. init(self: hamiltonian.PauliOperator, paulis: list[str], coefs: list[complex], AB_is_A1_B0: bool) -> None

Constructs a PauliOperator from vectors of operations, coefficients, and an additional boolean flag.

This constructor initializes a new PauliOperator object based on two given vectors: ops containing string representations of Pauli operator symbols, and coef_s containing the corresponding std::complex<double> coefficients. Additionally, it takes a boolean flag A which may affect the initialization process or the behavior of the constructed PauliOperator object. The length of both vectors ops and coef_s should be the same, and each pair of elements (one from ops and one from coef_s) represents a term in the Pauli operator. input like: [\"XZI\\",\\"IZX\\"],[1.1+0.j,2.1+0.j],true

Parameters
opsThe vector of Pauli operator symbols.
coef_sThe vector of corresponding coefficients.
AThe boolean flag that may affect the initialization or behavior.
  1. init(self: hamiltonian.PauliOperator, paulis_qbits_coef__s: list[tuple[str, list[int], complex]]) -> None

Constructs a PauliOperator from a vector of tuples.

This constructor initializes a new PauliOperator object based on a given vector of tuples ops. Each tuple contains three elements: a string representing a Pauli operator symbol, a vector of size_t indices, and a std::complex<double> coefficient. The vector of tuples represents a collection of terms in the Pauli operator, where each term is specified by its operator symbol, indices (if applicable), and coefficient. input like: [(\"XZ\\",[0,4],1.1+0.j),(\\"YX\\",[1,2],2.1+0.j)]

Parameters
opsThe vector of tuples containing Pauli operator symbols, indices, and coefficients.

◆ __init__() [7/7]

None pyqpanda3.hamiltonian.PauliOperator.__init__ ( self,
list[tuple[str, list[int], complex]] paulis_qbits_coef__s )

init(*args, **kwargs) Overloaded function.

  1. init(self: hamiltonian.PauliOperator) -> None

Constructs a default PauliOperator object.

This constructor initializes a new PauliOperator object with default values. The default behavior may include setting the operator to an identity or null state, depending on the implementation details.

  1. init(self: hamiltonian.PauliOperator, pauli_operator: hamiltonian.PauliOperator) -> None

Copy constructor for PauliOperator.

This constructor creates a new PauliOperator object that is a copy of an existing PauliOperator object. It initializes the new object with the same state and values as the provided other object.

Parameters
otherThe PauliOperator object to copy from.
  1. init(self: hamiltonian.PauliOperator, pauli: str) -> None

Constructs a PauliOperator from a string representation.

This constructor initializes a new PauliOperator object based on a given string a_pauli that represents a Pauli operator. The specific format and interpretation of the string are defined by the implementation.

Parameters
a_pauliThe string representation of the Pauli operator.
  1. init(self: hamiltonian.PauliOperator, pauli_with_coef_s: dict[str, complex]) -> None

Constructs a PauliOperator from a string representation.

This constructor initializes a new PauliOperator object based on a given string a_pauli that represents a Pauli operator. The specific format and interpretation of the string are defined by the implementation. input like: {\"X0 Z1\\":1.1,\\"Y2 I1\\":2.1+0.j}

Parameters
a_pauliThe string representation of the Pauli operator.
  1. init(self: hamiltonian.PauliOperator, paulis: list[str], coefs: list[complex]) -> None

Constructs a PauliOperator from vectors of operations and coefficients.

This constructor initializes a new PauliOperator object based on two given vectors: ops containing string representations of Pauli operator symbols, and coef_s containing the corresponding std::complex<double> coefficients. The length of both vectors should be the same, and each pair of elements (one from ops and one from coef_s) represents a term in the Pauli operator. input like: [\"X0 Z1\\",\\"Y2 I1\\"],[1.1+0.j,2.1+0.j]

Parameters
opsThe vector of Pauli operator symbols.
coef_sThe vector of corresponding coefficients.
a_pauliThe string representation of the Pauli operator.
  1. init(self: hamiltonian.PauliOperator, paulis: list[str], coefs: list[complex], AB_is_A1_B0: bool) -> None

Constructs a PauliOperator from vectors of operations, coefficients, and an additional boolean flag.

This constructor initializes a new PauliOperator object based on two given vectors: ops containing string representations of Pauli operator symbols, and coef_s containing the corresponding std::complex<double> coefficients. Additionally, it takes a boolean flag A which may affect the initialization process or the behavior of the constructed PauliOperator object. The length of both vectors ops and coef_s should be the same, and each pair of elements (one from ops and one from coef_s) represents a term in the Pauli operator. input like: [\"XZI\\",\\"IZX\\"],[1.1+0.j,2.1+0.j],true

Parameters
opsThe vector of Pauli operator symbols.
coef_sThe vector of corresponding coefficients.
AThe boolean flag that may affect the initialization or behavior.
  1. init(self: hamiltonian.PauliOperator, paulis_qbits_coef__s: list[tuple[str, list[int], complex]]) -> None

Constructs a PauliOperator from a vector of tuples.

This constructor initializes a new PauliOperator object based on a given vector of tuples ops. Each tuple contains three elements: a string representing a Pauli operator symbol, a vector of size_t indices, and a std::complex<double> coefficient. The vector of tuples represents a collection of terms in the Pauli operator, where each term is specified by its operator symbol, indices (if applicable), and coefficient. input like: [(\"XZ\\",[0,4],1.1+0.j),(\\"YX\\",[1,2],2.1+0.j)]

Parameters
opsThe vector of tuples containing Pauli operator symbols, indices, and coefficients.

Member Function Documentation

◆ __add__()

PauliOperator pyqpanda3.hamiltonian.PauliOperator.__add__ ( self,
PauliOperator other )

add(self: hamiltonian.PauliOperator, other: hamiltonian.PauliOperator) -> hamiltonian.PauliOperator

Overload of the + operator for adding two PauliOperators.

This method allows for the addition of two PauliOperators, resulting in a new PauliOperator that represents the sum of the two input PauliOperators.

Parameters
pauli_opThe PauliOperator to add to the current PauliOperator.
Returns
A new PauliOperator that is the sum of the two input PauliOperators.

◆ __eq__()

bool pyqpanda3.hamiltonian.PauliOperator.__eq__ ( self,
PauliOperator other )

eq(self: hamiltonian.PauliOperator, other: hamiltonian.PauliOperator) -> bool

Checks if the current PauliOperator is equal to another PauliOperator.

This method compares the current PauliOperator with another PauliOperator to determine if they are equal. Two PauliOperators are considered equal if they have the same terms and coefficients.

Parameters
otherThe PauliOperator to compare with the current PauliOperator.
Returns
True if the current PauliOperator is equal to the input PauliOperator, false otherwise.

◆ __iadd__()

PauliOperator pyqpanda3.hamiltonian.PauliOperator.__iadd__ ( self,
PauliOperator other )

iadd(self: hamiltonian.PauliOperator, other: hamiltonian.PauliOperator) -> hamiltonian.PauliOperator

Overload of the += operator for adding two PauliOperators.

This method allows for the addition of two PauliOperators. The current PauliOperator is updated to be the sum of the current PauliOperator and the input PauliOperator.

Parameters
otherThe PauliOperator to add to the current PauliOperator.
Returns
A reference to the updated current PauliOperator.

◆ __imul__()

PauliOperator pyqpanda3.hamiltonian.PauliOperator.__imul__ ( self,
PauliOperator other )

imul(self: hamiltonian.PauliOperator, other: hamiltonian.PauliOperator) -> hamiltonian.PauliOperator

Overload of the = operator for multiplying two PauliOperators.

This method allows for the multiplication of two PauliOperators. The current PauliOperator is updated to be the product of the current PauliOperator and the input PauliOperator. Note: The multiplication of PauliOperators typically follows the rules of tensor products and may result in a new PauliOperator with combined terms and coefficients.

Parameters
otherThe PauliOperator to multiply with the current PauliOperator.
Returns
A reference to the updated current PauliOperator.

◆ __isub__()

PauliOperator pyqpanda3.hamiltonian.PauliOperator.__isub__ ( self,
PauliOperator other )

isub(self: hamiltonian.PauliOperator, other: hamiltonian.PauliOperator) -> hamiltonian.PauliOperator

Overload of the -= operator for subtracting two PauliOperators.

This method allows for the subtraction of two PauliOperators. The current PauliOperator is updated to be the difference of the current PauliOperator and the input PauliOperator.

Parameters
otherThe PauliOperator to subtract from the current PauliOperator.
Returns
A reference to the updated current PauliOperator.

◆ __matmul__()

PauliOperator pyqpanda3.hamiltonian.PauliOperator.__matmul__ ( self,
PauliOperator other )

matmul(self: hamiltonian.PauliOperator, other: hamiltonian.PauliOperator) -> hamiltonian.PauliOperator

Overload of the `` operator for multiplying two PauliOperators.

This method allows for the multiplication of two PauliOperators, resulting in a new PauliOperator that represents the product of the two input PauliOperators. (1)If two terms are identical except for their coefficients, then a new term is generated with a coefficient that is the difference between the original coefficients (left operand minus right operand), and the part of the new term other than the coefficient is the same as the original two terms. (2)If two terms are different (excluding coefficients), then two new terms are generated. One of the new terms corresponds to the left operand and is exactly the same as the left operand. The other new term corresponds to the right operand and is the result of multiplying the coefficient of the right operand by -1.

Parameters
otherThe PauliOperator to multiply with the current PauliOperator.
Returns
A new PauliOperator that is the product of the two input PauliOperators.

◆ __mul__() [1/2]

PauliOperator pyqpanda3.hamiltonian.PauliOperator.__mul__ ( self,
complex scalar )

mul(*args, **kwargs) Overloaded function.

  1. mul(self: hamiltonian.PauliOperator, other: hamiltonian.PauliOperator) -> hamiltonian.PauliOperator

Overload of the `` operator for multiplying two PauliOperators.

This method allows for the multiplication of two PauliOperators, resulting in a new PauliOperator that represents the product of the two input PauliOperators. (1)If two terms are identical except for their coefficients, then a new term is generated with a coefficient that is the difference between the original coefficients (left operand minus right operand), and the part of the new term other than the coefficient is the same as the original two terms. (2)If two terms are different (excluding coefficients), then two new terms are generated. One of the new terms corresponds to the left operand and is exactly the same as the left operand. The other new term corresponds to the right operand and is the result of multiplying the coefficient of the right operand by -1.

Parameters
otherThe PauliOperator to multiply with the current PauliOperator.
Returns
A new PauliOperator that is the product of the two input PauliOperators.
  1. mul(self: hamiltonian.PauliOperator, scalar: complex) -> hamiltonian.PauliOperator

Overload of the `` operator for multiplying a PauliOperator by a scalar.

This method allows for the multiplication of a PauliOperator by a scalar value, resulting in a new PauliOperator that represents the scaled version of the original PauliOperator.

Parameters
scalarThe scalar value to multiply the PauliOperator by.
Returns
A new PauliOperator that is the scaled version of the original PauliOperator.

◆ __mul__() [2/2]

PauliOperator pyqpanda3.hamiltonian.PauliOperator.__mul__ ( self,
PauliOperator other )

mul(*args, **kwargs) Overloaded function.

  1. mul(self: hamiltonian.PauliOperator, other: hamiltonian.PauliOperator) -> hamiltonian.PauliOperator

Overload of the `` operator for multiplying two PauliOperators.

This method allows for the multiplication of two PauliOperators, resulting in a new PauliOperator that represents the product of the two input PauliOperators. (1)If two terms are identical except for their coefficients, then a new term is generated with a coefficient that is the difference between the original coefficients (left operand minus right operand), and the part of the new term other than the coefficient is the same as the original two terms. (2)If two terms are different (excluding coefficients), then two new terms are generated. One of the new terms corresponds to the left operand and is exactly the same as the left operand. The other new term corresponds to the right operand and is the result of multiplying the coefficient of the right operand by -1.

Parameters
otherThe PauliOperator to multiply with the current PauliOperator.
Returns
A new PauliOperator that is the product of the two input PauliOperators.
  1. mul(self: hamiltonian.PauliOperator, scalar: complex) -> hamiltonian.PauliOperator

Overload of the `` operator for multiplying a PauliOperator by a scalar.

This method allows for the multiplication of a PauliOperator by a scalar value, resulting in a new PauliOperator that represents the scaled version of the original PauliOperator.

Parameters
scalarThe scalar value to multiply the PauliOperator by.
Returns
A new PauliOperator that is the scaled version of the original PauliOperator.

◆ __rmul__()

PauliOperator pyqpanda3.hamiltonian.PauliOperator.__rmul__ ( self,
complex scalar )

rmul(self: hamiltonian.PauliOperator, scalar: complex) -> hamiltonian.PauliOperator

Overload of the `` operator for multiplying a PauliOperator by a scalar.

This method allows for the multiplication of a PauliOperator by a scalar value, resulting in a new PauliOperator that represents the scaled version of the original PauliOperator.

Parameters
scalarThe scalar value to multiply the PauliOperator by.
Returns
A new PauliOperator that is the scaled version of the original PauliOperator.

◆ __sub__()

PauliOperator pyqpanda3.hamiltonian.PauliOperator.__sub__ ( self,
PauliOperator other )

sub(self: hamiltonian.PauliOperator, other: hamiltonian.PauliOperator) -> hamiltonian.PauliOperator

Overload of the - operator for subtracting two PauliOperators.

This method allows for the subtraction of one PauliOperator from another, resulting in a new PauliOperator that represents the difference between the two input PauliOperators. (1)If two terms are identical except for their coefficients, a new term is generated with a coefficient that is the sum of the original coefficients, and the part of the new term other than the coefficient is the same as the original two terms. (2)If two terms are different (excluding coefficients), then two new terms are generated, which are identical to the original two terms respectively.

Parameters
pauli_opThe PauliOperator to subtract from the current PauliOperator.
Returns
A new PauliOperator that is the result of subtracting the input PauliOperator from the current one.

◆ str_no_I()

str pyqpanda3.hamiltonian.PauliOperator.str_no_I ( self)

str_no_I(self: hamiltonian.PauliOperator) -> str

Converts the PauliOperator to a string representation without the \'I\' (identity) term.

This method generates a string that represents the PauliOperator, excluding the \'I\' term. The string consists of characters \'X\', \'Y\', \'Z\', and digits, where "X#", "Y#", and "Z#" represent Pauli operators X, Y, and Z acting on qubits with index #, respectively. The AB_is_A1_B0 parameter specifies the order of the character substrings representing the Pauli operators on different qubits in the resulting string. If AB_is_A1_B0 is true, the substring corresponding to the qubit with the larger index appears first in the string. If false, the substring with the smaller index appears first.

Parameters
AB_is_A1_B0If true, the substring for the qubit with the larger index appears first in the string. If false, the substring for the qubit with the smaller index appears first.
Returns
A string that represents the PauliOperator without the \'I\' term, with the specified order of substrings.

◆ str_with_I()

str pyqpanda3.hamiltonian.PauliOperator.str_with_I ( self,
bool AB_is_A1_B0 = ... )

str_with_I(self: hamiltonian.PauliOperator, AB_is_A1_B0: bool = True) -> str

Converts the PauliOperator to a string representation with Pauli matrices.

This method converts the current PauliOperator object to a string representation where the Pauli matrices are represented by the characters 'X', 'Y', 'Z', and 'I'. The parameter AB_is_A1_B0 indicates the relationship between the order of the characters in the string and the qubit indices. If AB_is_A1_B0 is true, then the characters with smaller indices in the string correspond to larger qubit indices. Otherwise, the characters with smaller indices in the string correspond to smaller qubit indices.

Parameters
AB_is_A1_B0A boolean value that specifies the character order in relation to qubit indices.
Returns
A string representation of the PauliOperator object with Pauli matrices represented by 'X', 'Y', 'Z', and 'I'.

◆ str_withou_I()

str pyqpanda3.hamiltonian.PauliOperator.str_withou_I ( self)

str_withou_I(self: hamiltonian.PauliOperator) -> str

Converts the PauliOperator to a string representation without the \'I\' (identity) term.

This method generates a string that represents the PauliOperator, excluding the \'I\' term. The string consists of characters \'X\', \'Y\', \'Z\', and digits, where "X#", "Y#", and "Z#" represent Pauli operators X, Y, and Z acting on qubits with index #, respectively. The AB_is_A1_B0 parameter specifies the order of the character substrings representing the Pauli operators on different qubits in the resulting string. If AB_is_A1_B0 is true, the substring corresponding to the qubit with the larger index appears first in the string. If false, the substring with the smaller index appears first.

Parameters
AB_is_A1_B0If true, the substring for the qubit with the larger index appears first in the string. If false, the substring for the qubit with the smaller index appears first.
Returns
A string that represents the PauliOperator without the \'I\' term, with the specified order of substrings.

◆ tensor() [1/2]

PauliOperator pyqpanda3.hamiltonian.PauliOperator.tensor ( self,
int n )

tensor(*args, **kwargs) Overloaded function.

  1. tensor(self: hamiltonian.PauliOperator, other: hamiltonian.PauliOperator) -> hamiltonian.PauliOperator

Overload of the ^ operator for performing the tensor product of two PauliOperators.

This method computes the tensor product (Kronecker product) of the current PauliOperator with another PauliOperator, resulting in a new PauliOperator that represents the combined system of the two input PauliOperators.

Parameters
otherThe PauliOperator to compute the tensor product with.
Returns
A new PauliOperator that is the tensor product of the two input PauliOperators.
  1. tensor(self: hamiltonian.PauliOperator, n: int) -> hamiltonian.PauliOperator

Overload of the ^ operator for performing the tensor product operation n-1 times.

This method allows for the computation of the tensor product of the current PauliOperator with itself n-1 times, resulting in a new PauliOperator that represents this repeated tensor product.

Parameters
nThe number of times to perform the tensor product operation (i.e., n-1 tensor products).
Returns
A new PauliOperator that is the result of performing the tensor product operation n-1 times.

◆ tensor() [2/2]

PauliOperator pyqpanda3.hamiltonian.PauliOperator.tensor ( self,
PauliOperator other )

tensor(*args, **kwargs) Overloaded function.

  1. tensor(self: hamiltonian.PauliOperator, other: hamiltonian.PauliOperator) -> hamiltonian.PauliOperator

Overload of the ^ operator for performing the tensor product of two PauliOperators.

This method computes the tensor product (Kronecker product) of the current PauliOperator with another PauliOperator, resulting in a new PauliOperator that represents the combined system of the two input PauliOperators.

Parameters
otherThe PauliOperator to compute the tensor product with.
Returns
A new PauliOperator that is the tensor product of the two input PauliOperators.
  1. tensor(self: hamiltonian.PauliOperator, n: int) -> hamiltonian.PauliOperator

Overload of the ^ operator for performing the tensor product operation n-1 times.

This method allows for the computation of the tensor product of the current PauliOperator with itself n-1 times, resulting in a new PauliOperator that represents this repeated tensor product.

Parameters
nThe number of times to perform the tensor product operation (i.e., n-1 tensor products).
Returns
A new PauliOperator that is the result of performing the tensor product operation n-1 times.

The documentation for this class was generated from the following file: