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

Public Member Functions

None __init__ (self)
 init(*args, **kwargs) Overloaded function.
 
None __init__ (self, Hamiltonian other)
 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.Hamiltonian) -> str
 
str str_with_I (self, bool AB_is_A1_B0=...)
 str_with_I(self: hamiltonian.Hamiltonian, AB_is_A1_B0: bool = True) -> str
 
str str_withou_I (self)
 str_withou_I(self: hamiltonian.Hamiltonian) -> str
 
Hamiltonian tensor (self, Hamiltonian other)
 tensor(*args, **kwargs) Overloaded function.
 
Hamiltonian tensor (self, int n)
 tensor(*args, **kwargs) Overloaded function.
 
Hamiltonian update_by_tensor (self, Hamiltonian other)
 update_by_tensor(*args, **kwargs) Overloaded function.
 
Hamiltonian update_by_tensor (self, int n)
 update_by_tensor(*args, **kwargs) Overloaded function.
 
Hamiltonian __add__ (self, Hamiltonian other)
 add(self: hamiltonian.Hamiltonian, other: hamiltonian.Hamiltonian) -> hamiltonian.Hamiltonian
 
bool __eq__ (self, Hamiltonian other)
 eq(self: hamiltonian.Hamiltonian, other: hamiltonian.Hamiltonian) -> bool
 
Hamiltonian __iadd__ (self, Hamiltonian other)
 iadd(self: hamiltonian.Hamiltonian, other: hamiltonian.Hamiltonian) -> hamiltonian.Hamiltonian
 
Hamiltonian __imul__ (self, Hamiltonian other)
 imul(self: hamiltonian.Hamiltonian, other: hamiltonian.Hamiltonian) -> hamiltonian.Hamiltonian
 
Hamiltonian __isub__ (self, Hamiltonian other)
 isub(self: hamiltonian.Hamiltonian, other: hamiltonian.Hamiltonian) -> hamiltonian.Hamiltonian
 
Hamiltonian __matmul__ (self, Hamiltonian other)
 matmul(self: hamiltonian.Hamiltonian, other: hamiltonian.Hamiltonian) -> hamiltonian.Hamiltonian
 
Hamiltonian __mul__ (self, Hamiltonian other)
 mul(*args, **kwargs) Overloaded function.
 
Hamiltonian __mul__ (self, complex scalar)
 mul(*args, **kwargs) Overloaded function.
 
Hamiltonian __rmul__ (self, complex scalar)
 rmul(self: hamiltonian.Hamiltonian, scalar: complex) -> hamiltonian.Hamiltonian
 
Hamiltonian __sub__ (self, Hamiltonian other)
 sub(self: hamiltonian.Hamiltonian, other: hamiltonian.Hamiltonian) -> hamiltonian.Hamiltonian
 

Constructor & Destructor Documentation

◆ __init__() [1/8]

None pyqpanda3.hamiltonian.Hamiltonian.__init__ ( self)

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

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

Constructs a Hamiltonian object.

Initializes a new instance of the Hamiltonian class. This constructor may set up default values or perform any necessary initialization steps required for the object to be in a valid state.

  1. init(self: hamiltonian.Hamiltonian, other: hamiltonian.Hamiltonian) -> None

Copy constructor for Hamiltonian.

Creates a new Hamiltonian object as a copy of an existing one. This constructor deep-copies the state of the other Hamiltonian object, ensuring that the new object is an independent instance with the same state.

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

Constructs a Hamiltonian from a PauliOperator.

Initializes a new Hamiltonian object using the given PauliOperator as a basis. This constructor may perform any necessary transformations or calculations to convert the PauliOperator into a valid Hamiltonian representation.

Parameters
otherThe PauliOperator object to use for constructing the Hamiltonian.
  1. init(self: hamiltonian.Hamiltonian, pauli: str) -> None

Constructs a Hamiltonian from a string representation of Pauli operators.

Initializes a new Hamiltonian object using a string that represents one or more Pauli operators. This constructor parses the input string and constructs the corresponding Hamiltonian based on the specified operators. input must be \'X\' or \'Y\' or \'Z\' or \'I\',this will construct a pauli(X/Y/Z/I) to qbit0

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

Constructs a Hamiltonian from a map of operators and their coefficients.

Initializes a new Hamiltonian object using a map that associates strings representing quantum operators with their corresponding complex coefficients. This constructor constructs the Hamiltonian by summing the contributions of each operator weighted by its coefficient.

input like: {\"X0 Z1\\":1.1,\\"Y2 I1\\":2.1+0.j}

Parameters
opsA map where the keys are strings representing quantum operators and the values are complex numbers representing the coefficients of those operators.
  1. init(self: hamiltonian.Hamiltonian, paulis: list[str], coefs: list[complex]) -> None

Constructs a Hamiltonian from a vector of operators and their coefficients.

Initializes a new Hamiltonian object using two vectors: one containing strings that represent quantum operators, and another containing the corresponding complex coefficients for those operators. This constructor assumes that the vectors ops and coef_s have the same length and constructs the Hamiltonian by summing the contributions of each operator weighted by its coefficient. input like: [\"X0 Z1\\",\\"Y2 I1\\"],[1.1+0.j,2.1+0.j]

Parameters
opsA vector of strings representing quantum operators.
coef_sA vector of complex numbers representing the coefficients of the operators.
  1. init(self: hamiltonian.Hamiltonian, paulis: list[str], coefs: list[complex], AB_is_A1_B0: bool = True) -> None

Constructs a Hamiltonian from a vector of operators, their coefficients, and a flag.

Initializes a new Hamiltonian object using two vectors: one containing strings that represent quantum operators, and another containing the corresponding complex coefficients for those operators. Additionally, this constructor takes a boolean flag AB_is_A1_B0 that specifies a particular configuration or interpretation of the operators. This constructor assumes that the vectors ops and coef_s have the same length and constructs the Hamiltonian by summing the contributions of each operator weighted by its coefficient. The AB_is_A1_B0 flag may affect how the operators are interpreted or combined in the final Hamiltonian. input like: [\"XZI\\",\\"IZX\\"],[1.1+0.j,2.1+0.j],true

Parameters
opsA vector of strings representing quantum operators.
coef_sA vector of complex numbers representing the coefficients of the operators.
AB_is_A1_B0A boolean flag that specifies a particular configuration or interpretation of the operators.
  1. init(self: hamiltonian.Hamiltonian, paulis_qbits_coef__s: list[tuple[str, list[int], complex]]) -> None

Constructs a Hamiltonian from a vector of tuples containing operators, indices, and coefficients.

Initializes a new Hamiltonian object using a vector of tuples. Each tuple contains a string representing a quantum operator, a vector of size_t representing the indices of the operator (e.g., for tensor products or multi-site operators), and a complex number representing the coefficient of the operator. This constructor constructs the Hamiltonian by summing the contributions of each operator-index-coefficient tuple. input like: [(\"XZ\\",[0,4],1.1+0.j),(\\"YX\\",[1,2],2.1+0.j)]

Parameters
opsA vector of tuples, where each tuple contains a string (operator), a vector of size_t (indices), and a complex number (coefficient).

◆ __init__() [2/8]

None pyqpanda3.hamiltonian.Hamiltonian.__init__ ( self,
Hamiltonian other )

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

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

Constructs a Hamiltonian object.

Initializes a new instance of the Hamiltonian class. This constructor may set up default values or perform any necessary initialization steps required for the object to be in a valid state.

  1. init(self: hamiltonian.Hamiltonian, other: hamiltonian.Hamiltonian) -> None

Copy constructor for Hamiltonian.

Creates a new Hamiltonian object as a copy of an existing one. This constructor deep-copies the state of the other Hamiltonian object, ensuring that the new object is an independent instance with the same state.

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

Constructs a Hamiltonian from a PauliOperator.

Initializes a new Hamiltonian object using the given PauliOperator as a basis. This constructor may perform any necessary transformations or calculations to convert the PauliOperator into a valid Hamiltonian representation.

Parameters
otherThe PauliOperator object to use for constructing the Hamiltonian.
  1. init(self: hamiltonian.Hamiltonian, pauli: str) -> None

Constructs a Hamiltonian from a string representation of Pauli operators.

Initializes a new Hamiltonian object using a string that represents one or more Pauli operators. This constructor parses the input string and constructs the corresponding Hamiltonian based on the specified operators. input must be \'X\' or \'Y\' or \'Z\' or \'I\',this will construct a pauli(X/Y/Z/I) to qbit0

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

Constructs a Hamiltonian from a map of operators and their coefficients.

Initializes a new Hamiltonian object using a map that associates strings representing quantum operators with their corresponding complex coefficients. This constructor constructs the Hamiltonian by summing the contributions of each operator weighted by its coefficient.

input like: {\"X0 Z1\\":1.1,\\"Y2 I1\\":2.1+0.j}

Parameters
opsA map where the keys are strings representing quantum operators and the values are complex numbers representing the coefficients of those operators.
  1. init(self: hamiltonian.Hamiltonian, paulis: list[str], coefs: list[complex]) -> None

Constructs a Hamiltonian from a vector of operators and their coefficients.

Initializes a new Hamiltonian object using two vectors: one containing strings that represent quantum operators, and another containing the corresponding complex coefficients for those operators. This constructor assumes that the vectors ops and coef_s have the same length and constructs the Hamiltonian by summing the contributions of each operator weighted by its coefficient. input like: [\"X0 Z1\\",\\"Y2 I1\\"],[1.1+0.j,2.1+0.j]

Parameters
opsA vector of strings representing quantum operators.
coef_sA vector of complex numbers representing the coefficients of the operators.
  1. init(self: hamiltonian.Hamiltonian, paulis: list[str], coefs: list[complex], AB_is_A1_B0: bool = True) -> None

Constructs a Hamiltonian from a vector of operators, their coefficients, and a flag.

Initializes a new Hamiltonian object using two vectors: one containing strings that represent quantum operators, and another containing the corresponding complex coefficients for those operators. Additionally, this constructor takes a boolean flag AB_is_A1_B0 that specifies a particular configuration or interpretation of the operators. This constructor assumes that the vectors ops and coef_s have the same length and constructs the Hamiltonian by summing the contributions of each operator weighted by its coefficient. The AB_is_A1_B0 flag may affect how the operators are interpreted or combined in the final Hamiltonian. input like: [\"XZI\\",\\"IZX\\"],[1.1+0.j,2.1+0.j],true

Parameters
opsA vector of strings representing quantum operators.
coef_sA vector of complex numbers representing the coefficients of the operators.
AB_is_A1_B0A boolean flag that specifies a particular configuration or interpretation of the operators.
  1. init(self: hamiltonian.Hamiltonian, paulis_qbits_coef__s: list[tuple[str, list[int], complex]]) -> None

Constructs a Hamiltonian from a vector of tuples containing operators, indices, and coefficients.

Initializes a new Hamiltonian object using a vector of tuples. Each tuple contains a string representing a quantum operator, a vector of size_t representing the indices of the operator (e.g., for tensor products or multi-site operators), and a complex number representing the coefficient of the operator. This constructor constructs the Hamiltonian by summing the contributions of each operator-index-coefficient tuple. input like: [(\"XZ\\",[0,4],1.1+0.j),(\\"YX\\",[1,2],2.1+0.j)]

Parameters
opsA vector of tuples, where each tuple contains a string (operator), a vector of size_t (indices), and a complex number (coefficient).

◆ __init__() [3/8]

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

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

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

Constructs a Hamiltonian object.

Initializes a new instance of the Hamiltonian class. This constructor may set up default values or perform any necessary initialization steps required for the object to be in a valid state.

  1. init(self: hamiltonian.Hamiltonian, other: hamiltonian.Hamiltonian) -> None

Copy constructor for Hamiltonian.

Creates a new Hamiltonian object as a copy of an existing one. This constructor deep-copies the state of the other Hamiltonian object, ensuring that the new object is an independent instance with the same state.

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

Constructs a Hamiltonian from a PauliOperator.

Initializes a new Hamiltonian object using the given PauliOperator as a basis. This constructor may perform any necessary transformations or calculations to convert the PauliOperator into a valid Hamiltonian representation.

Parameters
otherThe PauliOperator object to use for constructing the Hamiltonian.
  1. init(self: hamiltonian.Hamiltonian, pauli: str) -> None

Constructs a Hamiltonian from a string representation of Pauli operators.

Initializes a new Hamiltonian object using a string that represents one or more Pauli operators. This constructor parses the input string and constructs the corresponding Hamiltonian based on the specified operators. input must be \'X\' or \'Y\' or \'Z\' or \'I\',this will construct a pauli(X/Y/Z/I) to qbit0

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

Constructs a Hamiltonian from a map of operators and their coefficients.

Initializes a new Hamiltonian object using a map that associates strings representing quantum operators with their corresponding complex coefficients. This constructor constructs the Hamiltonian by summing the contributions of each operator weighted by its coefficient.

input like: {\"X0 Z1\\":1.1,\\"Y2 I1\\":2.1+0.j}

Parameters
opsA map where the keys are strings representing quantum operators and the values are complex numbers representing the coefficients of those operators.
  1. init(self: hamiltonian.Hamiltonian, paulis: list[str], coefs: list[complex]) -> None

Constructs a Hamiltonian from a vector of operators and their coefficients.

Initializes a new Hamiltonian object using two vectors: one containing strings that represent quantum operators, and another containing the corresponding complex coefficients for those operators. This constructor assumes that the vectors ops and coef_s have the same length and constructs the Hamiltonian by summing the contributions of each operator weighted by its coefficient. input like: [\"X0 Z1\\",\\"Y2 I1\\"],[1.1+0.j,2.1+0.j]

Parameters
opsA vector of strings representing quantum operators.
coef_sA vector of complex numbers representing the coefficients of the operators.
  1. init(self: hamiltonian.Hamiltonian, paulis: list[str], coefs: list[complex], AB_is_A1_B0: bool = True) -> None

Constructs a Hamiltonian from a vector of operators, their coefficients, and a flag.

Initializes a new Hamiltonian object using two vectors: one containing strings that represent quantum operators, and another containing the corresponding complex coefficients for those operators. Additionally, this constructor takes a boolean flag AB_is_A1_B0 that specifies a particular configuration or interpretation of the operators. This constructor assumes that the vectors ops and coef_s have the same length and constructs the Hamiltonian by summing the contributions of each operator weighted by its coefficient. The AB_is_A1_B0 flag may affect how the operators are interpreted or combined in the final Hamiltonian. input like: [\"XZI\\",\\"IZX\\"],[1.1+0.j,2.1+0.j],true

Parameters
opsA vector of strings representing quantum operators.
coef_sA vector of complex numbers representing the coefficients of the operators.
AB_is_A1_B0A boolean flag that specifies a particular configuration or interpretation of the operators.
  1. init(self: hamiltonian.Hamiltonian, paulis_qbits_coef__s: list[tuple[str, list[int], complex]]) -> None

Constructs a Hamiltonian from a vector of tuples containing operators, indices, and coefficients.

Initializes a new Hamiltonian object using a vector of tuples. Each tuple contains a string representing a quantum operator, a vector of size_t representing the indices of the operator (e.g., for tensor products or multi-site operators), and a complex number representing the coefficient of the operator. This constructor constructs the Hamiltonian by summing the contributions of each operator-index-coefficient tuple. input like: [(\"XZ\\",[0,4],1.1+0.j),(\\"YX\\",[1,2],2.1+0.j)]

Parameters
opsA vector of tuples, where each tuple contains a string (operator), a vector of size_t (indices), and a complex number (coefficient).

◆ __init__() [4/8]

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

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

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

Constructs a Hamiltonian object.

Initializes a new instance of the Hamiltonian class. This constructor may set up default values or perform any necessary initialization steps required for the object to be in a valid state.

  1. init(self: hamiltonian.Hamiltonian, other: hamiltonian.Hamiltonian) -> None

Copy constructor for Hamiltonian.

Creates a new Hamiltonian object as a copy of an existing one. This constructor deep-copies the state of the other Hamiltonian object, ensuring that the new object is an independent instance with the same state.

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

Constructs a Hamiltonian from a PauliOperator.

Initializes a new Hamiltonian object using the given PauliOperator as a basis. This constructor may perform any necessary transformations or calculations to convert the PauliOperator into a valid Hamiltonian representation.

Parameters
otherThe PauliOperator object to use for constructing the Hamiltonian.
  1. init(self: hamiltonian.Hamiltonian, pauli: str) -> None

Constructs a Hamiltonian from a string representation of Pauli operators.

Initializes a new Hamiltonian object using a string that represents one or more Pauli operators. This constructor parses the input string and constructs the corresponding Hamiltonian based on the specified operators. input must be \'X\' or \'Y\' or \'Z\' or \'I\',this will construct a pauli(X/Y/Z/I) to qbit0

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

Constructs a Hamiltonian from a map of operators and their coefficients.

Initializes a new Hamiltonian object using a map that associates strings representing quantum operators with their corresponding complex coefficients. This constructor constructs the Hamiltonian by summing the contributions of each operator weighted by its coefficient.

input like: {\"X0 Z1\\":1.1,\\"Y2 I1\\":2.1+0.j}

Parameters
opsA map where the keys are strings representing quantum operators and the values are complex numbers representing the coefficients of those operators.
  1. init(self: hamiltonian.Hamiltonian, paulis: list[str], coefs: list[complex]) -> None

Constructs a Hamiltonian from a vector of operators and their coefficients.

Initializes a new Hamiltonian object using two vectors: one containing strings that represent quantum operators, and another containing the corresponding complex coefficients for those operators. This constructor assumes that the vectors ops and coef_s have the same length and constructs the Hamiltonian by summing the contributions of each operator weighted by its coefficient. input like: [\"X0 Z1\\",\\"Y2 I1\\"],[1.1+0.j,2.1+0.j]

Parameters
opsA vector of strings representing quantum operators.
coef_sA vector of complex numbers representing the coefficients of the operators.
  1. init(self: hamiltonian.Hamiltonian, paulis: list[str], coefs: list[complex], AB_is_A1_B0: bool = True) -> None

Constructs a Hamiltonian from a vector of operators, their coefficients, and a flag.

Initializes a new Hamiltonian object using two vectors: one containing strings that represent quantum operators, and another containing the corresponding complex coefficients for those operators. Additionally, this constructor takes a boolean flag AB_is_A1_B0 that specifies a particular configuration or interpretation of the operators. This constructor assumes that the vectors ops and coef_s have the same length and constructs the Hamiltonian by summing the contributions of each operator weighted by its coefficient. The AB_is_A1_B0 flag may affect how the operators are interpreted or combined in the final Hamiltonian. input like: [\"XZI\\",\\"IZX\\"],[1.1+0.j,2.1+0.j],true

Parameters
opsA vector of strings representing quantum operators.
coef_sA vector of complex numbers representing the coefficients of the operators.
AB_is_A1_B0A boolean flag that specifies a particular configuration or interpretation of the operators.
  1. init(self: hamiltonian.Hamiltonian, paulis_qbits_coef__s: list[tuple[str, list[int], complex]]) -> None

Constructs a Hamiltonian from a vector of tuples containing operators, indices, and coefficients.

Initializes a new Hamiltonian object using a vector of tuples. Each tuple contains a string representing a quantum operator, a vector of size_t representing the indices of the operator (e.g., for tensor products or multi-site operators), and a complex number representing the coefficient of the operator. This constructor constructs the Hamiltonian by summing the contributions of each operator-index-coefficient tuple. input like: [(\"XZ\\",[0,4],1.1+0.j),(\\"YX\\",[1,2],2.1+0.j)]

Parameters
opsA vector of tuples, where each tuple contains a string (operator), a vector of size_t (indices), and a complex number (coefficient).

◆ __init__() [5/8]

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

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

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

Constructs a Hamiltonian object.

Initializes a new instance of the Hamiltonian class. This constructor may set up default values or perform any necessary initialization steps required for the object to be in a valid state.

  1. init(self: hamiltonian.Hamiltonian, other: hamiltonian.Hamiltonian) -> None

Copy constructor for Hamiltonian.

Creates a new Hamiltonian object as a copy of an existing one. This constructor deep-copies the state of the other Hamiltonian object, ensuring that the new object is an independent instance with the same state.

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

Constructs a Hamiltonian from a PauliOperator.

Initializes a new Hamiltonian object using the given PauliOperator as a basis. This constructor may perform any necessary transformations or calculations to convert the PauliOperator into a valid Hamiltonian representation.

Parameters
otherThe PauliOperator object to use for constructing the Hamiltonian.
  1. init(self: hamiltonian.Hamiltonian, pauli: str) -> None

Constructs a Hamiltonian from a string representation of Pauli operators.

Initializes a new Hamiltonian object using a string that represents one or more Pauli operators. This constructor parses the input string and constructs the corresponding Hamiltonian based on the specified operators. input must be \'X\' or \'Y\' or \'Z\' or \'I\',this will construct a pauli(X/Y/Z/I) to qbit0

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

Constructs a Hamiltonian from a map of operators and their coefficients.

Initializes a new Hamiltonian object using a map that associates strings representing quantum operators with their corresponding complex coefficients. This constructor constructs the Hamiltonian by summing the contributions of each operator weighted by its coefficient.

input like: {\"X0 Z1\\":1.1,\\"Y2 I1\\":2.1+0.j}

Parameters
opsA map where the keys are strings representing quantum operators and the values are complex numbers representing the coefficients of those operators.
  1. init(self: hamiltonian.Hamiltonian, paulis: list[str], coefs: list[complex]) -> None

Constructs a Hamiltonian from a vector of operators and their coefficients.

Initializes a new Hamiltonian object using two vectors: one containing strings that represent quantum operators, and another containing the corresponding complex coefficients for those operators. This constructor assumes that the vectors ops and coef_s have the same length and constructs the Hamiltonian by summing the contributions of each operator weighted by its coefficient. input like: [\"X0 Z1\\",\\"Y2 I1\\"],[1.1+0.j,2.1+0.j]

Parameters
opsA vector of strings representing quantum operators.
coef_sA vector of complex numbers representing the coefficients of the operators.
  1. init(self: hamiltonian.Hamiltonian, paulis: list[str], coefs: list[complex], AB_is_A1_B0: bool = True) -> None

Constructs a Hamiltonian from a vector of operators, their coefficients, and a flag.

Initializes a new Hamiltonian object using two vectors: one containing strings that represent quantum operators, and another containing the corresponding complex coefficients for those operators. Additionally, this constructor takes a boolean flag AB_is_A1_B0 that specifies a particular configuration or interpretation of the operators. This constructor assumes that the vectors ops and coef_s have the same length and constructs the Hamiltonian by summing the contributions of each operator weighted by its coefficient. The AB_is_A1_B0 flag may affect how the operators are interpreted or combined in the final Hamiltonian. input like: [\"XZI\\",\\"IZX\\"],[1.1+0.j,2.1+0.j],true

Parameters
opsA vector of strings representing quantum operators.
coef_sA vector of complex numbers representing the coefficients of the operators.
AB_is_A1_B0A boolean flag that specifies a particular configuration or interpretation of the operators.
  1. init(self: hamiltonian.Hamiltonian, paulis_qbits_coef__s: list[tuple[str, list[int], complex]]) -> None

Constructs a Hamiltonian from a vector of tuples containing operators, indices, and coefficients.

Initializes a new Hamiltonian object using a vector of tuples. Each tuple contains a string representing a quantum operator, a vector of size_t representing the indices of the operator (e.g., for tensor products or multi-site operators), and a complex number representing the coefficient of the operator. This constructor constructs the Hamiltonian by summing the contributions of each operator-index-coefficient tuple. input like: [(\"XZ\\",[0,4],1.1+0.j),(\\"YX\\",[1,2],2.1+0.j)]

Parameters
opsA vector of tuples, where each tuple contains a string (operator), a vector of size_t (indices), and a complex number (coefficient).

◆ __init__() [6/8]

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

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

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

Constructs a Hamiltonian object.

Initializes a new instance of the Hamiltonian class. This constructor may set up default values or perform any necessary initialization steps required for the object to be in a valid state.

  1. init(self: hamiltonian.Hamiltonian, other: hamiltonian.Hamiltonian) -> None

Copy constructor for Hamiltonian.

Creates a new Hamiltonian object as a copy of an existing one. This constructor deep-copies the state of the other Hamiltonian object, ensuring that the new object is an independent instance with the same state.

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

Constructs a Hamiltonian from a PauliOperator.

Initializes a new Hamiltonian object using the given PauliOperator as a basis. This constructor may perform any necessary transformations or calculations to convert the PauliOperator into a valid Hamiltonian representation.

Parameters
otherThe PauliOperator object to use for constructing the Hamiltonian.
  1. init(self: hamiltonian.Hamiltonian, pauli: str) -> None

Constructs a Hamiltonian from a string representation of Pauli operators.

Initializes a new Hamiltonian object using a string that represents one or more Pauli operators. This constructor parses the input string and constructs the corresponding Hamiltonian based on the specified operators. input must be \'X\' or \'Y\' or \'Z\' or \'I\',this will construct a pauli(X/Y/Z/I) to qbit0

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

Constructs a Hamiltonian from a map of operators and their coefficients.

Initializes a new Hamiltonian object using a map that associates strings representing quantum operators with their corresponding complex coefficients. This constructor constructs the Hamiltonian by summing the contributions of each operator weighted by its coefficient.

input like: {\"X0 Z1\\":1.1,\\"Y2 I1\\":2.1+0.j}

Parameters
opsA map where the keys are strings representing quantum operators and the values are complex numbers representing the coefficients of those operators.
  1. init(self: hamiltonian.Hamiltonian, paulis: list[str], coefs: list[complex]) -> None

Constructs a Hamiltonian from a vector of operators and their coefficients.

Initializes a new Hamiltonian object using two vectors: one containing strings that represent quantum operators, and another containing the corresponding complex coefficients for those operators. This constructor assumes that the vectors ops and coef_s have the same length and constructs the Hamiltonian by summing the contributions of each operator weighted by its coefficient. input like: [\"X0 Z1\\",\\"Y2 I1\\"],[1.1+0.j,2.1+0.j]

Parameters
opsA vector of strings representing quantum operators.
coef_sA vector of complex numbers representing the coefficients of the operators.
  1. init(self: hamiltonian.Hamiltonian, paulis: list[str], coefs: list[complex], AB_is_A1_B0: bool = True) -> None

Constructs a Hamiltonian from a vector of operators, their coefficients, and a flag.

Initializes a new Hamiltonian object using two vectors: one containing strings that represent quantum operators, and another containing the corresponding complex coefficients for those operators. Additionally, this constructor takes a boolean flag AB_is_A1_B0 that specifies a particular configuration or interpretation of the operators. This constructor assumes that the vectors ops and coef_s have the same length and constructs the Hamiltonian by summing the contributions of each operator weighted by its coefficient. The AB_is_A1_B0 flag may affect how the operators are interpreted or combined in the final Hamiltonian. input like: [\"XZI\\",\\"IZX\\"],[1.1+0.j,2.1+0.j],true

Parameters
opsA vector of strings representing quantum operators.
coef_sA vector of complex numbers representing the coefficients of the operators.
AB_is_A1_B0A boolean flag that specifies a particular configuration or interpretation of the operators.
  1. init(self: hamiltonian.Hamiltonian, paulis_qbits_coef__s: list[tuple[str, list[int], complex]]) -> None

Constructs a Hamiltonian from a vector of tuples containing operators, indices, and coefficients.

Initializes a new Hamiltonian object using a vector of tuples. Each tuple contains a string representing a quantum operator, a vector of size_t representing the indices of the operator (e.g., for tensor products or multi-site operators), and a complex number representing the coefficient of the operator. This constructor constructs the Hamiltonian by summing the contributions of each operator-index-coefficient tuple. input like: [(\"XZ\\",[0,4],1.1+0.j),(\\"YX\\",[1,2],2.1+0.j)]

Parameters
opsA vector of tuples, where each tuple contains a string (operator), a vector of size_t (indices), and a complex number (coefficient).

◆ __init__() [7/8]

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

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

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

Constructs a Hamiltonian object.

Initializes a new instance of the Hamiltonian class. This constructor may set up default values or perform any necessary initialization steps required for the object to be in a valid state.

  1. init(self: hamiltonian.Hamiltonian, other: hamiltonian.Hamiltonian) -> None

Copy constructor for Hamiltonian.

Creates a new Hamiltonian object as a copy of an existing one. This constructor deep-copies the state of the other Hamiltonian object, ensuring that the new object is an independent instance with the same state.

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

Constructs a Hamiltonian from a PauliOperator.

Initializes a new Hamiltonian object using the given PauliOperator as a basis. This constructor may perform any necessary transformations or calculations to convert the PauliOperator into a valid Hamiltonian representation.

Parameters
otherThe PauliOperator object to use for constructing the Hamiltonian.
  1. init(self: hamiltonian.Hamiltonian, pauli: str) -> None

Constructs a Hamiltonian from a string representation of Pauli operators.

Initializes a new Hamiltonian object using a string that represents one or more Pauli operators. This constructor parses the input string and constructs the corresponding Hamiltonian based on the specified operators. input must be \'X\' or \'Y\' or \'Z\' or \'I\',this will construct a pauli(X/Y/Z/I) to qbit0

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

Constructs a Hamiltonian from a map of operators and their coefficients.

Initializes a new Hamiltonian object using a map that associates strings representing quantum operators with their corresponding complex coefficients. This constructor constructs the Hamiltonian by summing the contributions of each operator weighted by its coefficient.

input like: {\"X0 Z1\\":1.1,\\"Y2 I1\\":2.1+0.j}

Parameters
opsA map where the keys are strings representing quantum operators and the values are complex numbers representing the coefficients of those operators.
  1. init(self: hamiltonian.Hamiltonian, paulis: list[str], coefs: list[complex]) -> None

Constructs a Hamiltonian from a vector of operators and their coefficients.

Initializes a new Hamiltonian object using two vectors: one containing strings that represent quantum operators, and another containing the corresponding complex coefficients for those operators. This constructor assumes that the vectors ops and coef_s have the same length and constructs the Hamiltonian by summing the contributions of each operator weighted by its coefficient. input like: [\"X0 Z1\\",\\"Y2 I1\\"],[1.1+0.j,2.1+0.j]

Parameters
opsA vector of strings representing quantum operators.
coef_sA vector of complex numbers representing the coefficients of the operators.
  1. init(self: hamiltonian.Hamiltonian, paulis: list[str], coefs: list[complex], AB_is_A1_B0: bool = True) -> None

Constructs a Hamiltonian from a vector of operators, their coefficients, and a flag.

Initializes a new Hamiltonian object using two vectors: one containing strings that represent quantum operators, and another containing the corresponding complex coefficients for those operators. Additionally, this constructor takes a boolean flag AB_is_A1_B0 that specifies a particular configuration or interpretation of the operators. This constructor assumes that the vectors ops and coef_s have the same length and constructs the Hamiltonian by summing the contributions of each operator weighted by its coefficient. The AB_is_A1_B0 flag may affect how the operators are interpreted or combined in the final Hamiltonian. input like: [\"XZI\\",\\"IZX\\"],[1.1+0.j,2.1+0.j],true

Parameters
opsA vector of strings representing quantum operators.
coef_sA vector of complex numbers representing the coefficients of the operators.
AB_is_A1_B0A boolean flag that specifies a particular configuration or interpretation of the operators.
  1. init(self: hamiltonian.Hamiltonian, paulis_qbits_coef__s: list[tuple[str, list[int], complex]]) -> None

Constructs a Hamiltonian from a vector of tuples containing operators, indices, and coefficients.

Initializes a new Hamiltonian object using a vector of tuples. Each tuple contains a string representing a quantum operator, a vector of size_t representing the indices of the operator (e.g., for tensor products or multi-site operators), and a complex number representing the coefficient of the operator. This constructor constructs the Hamiltonian by summing the contributions of each operator-index-coefficient tuple. input like: [(\"XZ\\",[0,4],1.1+0.j),(\\"YX\\",[1,2],2.1+0.j)]

Parameters
opsA vector of tuples, where each tuple contains a string (operator), a vector of size_t (indices), and a complex number (coefficient).

◆ __init__() [8/8]

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

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

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

Constructs a Hamiltonian object.

Initializes a new instance of the Hamiltonian class. This constructor may set up default values or perform any necessary initialization steps required for the object to be in a valid state.

  1. init(self: hamiltonian.Hamiltonian, other: hamiltonian.Hamiltonian) -> None

Copy constructor for Hamiltonian.

Creates a new Hamiltonian object as a copy of an existing one. This constructor deep-copies the state of the other Hamiltonian object, ensuring that the new object is an independent instance with the same state.

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

Constructs a Hamiltonian from a PauliOperator.

Initializes a new Hamiltonian object using the given PauliOperator as a basis. This constructor may perform any necessary transformations or calculations to convert the PauliOperator into a valid Hamiltonian representation.

Parameters
otherThe PauliOperator object to use for constructing the Hamiltonian.
  1. init(self: hamiltonian.Hamiltonian, pauli: str) -> None

Constructs a Hamiltonian from a string representation of Pauli operators.

Initializes a new Hamiltonian object using a string that represents one or more Pauli operators. This constructor parses the input string and constructs the corresponding Hamiltonian based on the specified operators. input must be \'X\' or \'Y\' or \'Z\' or \'I\',this will construct a pauli(X/Y/Z/I) to qbit0

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

Constructs a Hamiltonian from a map of operators and their coefficients.

Initializes a new Hamiltonian object using a map that associates strings representing quantum operators with their corresponding complex coefficients. This constructor constructs the Hamiltonian by summing the contributions of each operator weighted by its coefficient.

input like: {\"X0 Z1\\":1.1,\\"Y2 I1\\":2.1+0.j}

Parameters
opsA map where the keys are strings representing quantum operators and the values are complex numbers representing the coefficients of those operators.
  1. init(self: hamiltonian.Hamiltonian, paulis: list[str], coefs: list[complex]) -> None

Constructs a Hamiltonian from a vector of operators and their coefficients.

Initializes a new Hamiltonian object using two vectors: one containing strings that represent quantum operators, and another containing the corresponding complex coefficients for those operators. This constructor assumes that the vectors ops and coef_s have the same length and constructs the Hamiltonian by summing the contributions of each operator weighted by its coefficient. input like: [\"X0 Z1\\",\\"Y2 I1\\"],[1.1+0.j,2.1+0.j]

Parameters
opsA vector of strings representing quantum operators.
coef_sA vector of complex numbers representing the coefficients of the operators.
  1. init(self: hamiltonian.Hamiltonian, paulis: list[str], coefs: list[complex], AB_is_A1_B0: bool = True) -> None

Constructs a Hamiltonian from a vector of operators, their coefficients, and a flag.

Initializes a new Hamiltonian object using two vectors: one containing strings that represent quantum operators, and another containing the corresponding complex coefficients for those operators. Additionally, this constructor takes a boolean flag AB_is_A1_B0 that specifies a particular configuration or interpretation of the operators. This constructor assumes that the vectors ops and coef_s have the same length and constructs the Hamiltonian by summing the contributions of each operator weighted by its coefficient. The AB_is_A1_B0 flag may affect how the operators are interpreted or combined in the final Hamiltonian. input like: [\"XZI\\",\\"IZX\\"],[1.1+0.j,2.1+0.j],true

Parameters
opsA vector of strings representing quantum operators.
coef_sA vector of complex numbers representing the coefficients of the operators.
AB_is_A1_B0A boolean flag that specifies a particular configuration or interpretation of the operators.
  1. init(self: hamiltonian.Hamiltonian, paulis_qbits_coef__s: list[tuple[str, list[int], complex]]) -> None

Constructs a Hamiltonian from a vector of tuples containing operators, indices, and coefficients.

Initializes a new Hamiltonian object using a vector of tuples. Each tuple contains a string representing a quantum operator, a vector of size_t representing the indices of the operator (e.g., for tensor products or multi-site operators), and a complex number representing the coefficient of the operator. This constructor constructs the Hamiltonian by summing the contributions of each operator-index-coefficient tuple. input like: [(\"XZ\\",[0,4],1.1+0.j),(\\"YX\\",[1,2],2.1+0.j)]

Parameters
opsA vector of tuples, where each tuple contains a string (operator), a vector of size_t (indices), and a complex number (coefficient).

Member Function Documentation

◆ __add__()

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

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

Overload for the addition operator.

This method allows for the addition of two Hamiltonian objects. It returns a new Hamiltonian object that is the sum of the current object and the one passed as a parameter. (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
otherThe Hamiltonian object to add to the current object.
Returns
A new Hamiltonian object that is the sum of the current object and H.

◆ __eq__()

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

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

Checks if the current Hamiltonian is equal to another Hamiltonian.

  • This method compares the current Hamiltonian object with another Hamiltonian object other to determine if they are equal.
  • Parameters
    otherThe Hamiltonian object to compare with the current object.
    Returns
    True if the current and other Hamiltonian objects are equal, false otherwise.

◆ __iadd__()

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

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

Overload for the addition assignment operator to add another Hamiltonian.

This method adds the given Hamiltonian object other to the current Hamiltonian object and assigns the result back to the current object.

Parameters
otherThe Hamiltonian object to add to the current object.
Returns
A reference to the current Hamiltonian object after the addition.

◆ __imul__()

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

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

Overload for the multiplication assignment operator to multiply by another Hamiltonian.

  • This method multiplies the current Hamiltonian object by another Hamiltonian object other and assigns the result back to the current object.
  • Parameters
    otherThe Hamiltonian object to multiply with the current object.
    Returns
    A reference to the current Hamiltonian object after the multiplication.

◆ __isub__()

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

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

Overload for the subtraction assignment operator to subtract another Hamiltonian.

  • This method subtracts the given Hamiltonian object other from the current Hamiltonian object and assigns the result back to the current object.
  • Parameters
    otherThe Hamiltonian object to subtract from the current object.
    Returns
    A reference to the current Hamiltonian object after the subtraction.

◆ __matmul__()

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

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

Overload for the multiplication operator between two Hamiltonians.

This method allows for the multiplication of two Hamiltonian objects. The multiplication follows the distributive property, with the smallest unit of operation being the multiplication of coefficients and individual Pauli matrices. Parenthetical expressions are handled appropriately. The result is a new Hamiltonian object that represents the product of the two input objects.

Parameters
otherThe Hamiltonian object to multiply with the current object.
Returns
A new Hamiltonian object that is the product of the current object and other.

◆ __mul__() [1/2]

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

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

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

Overload for the multiplication operator between two Hamiltonians.

This method allows for the multiplication of two Hamiltonian objects. The multiplication follows the distributive property, with the smallest unit of operation being the multiplication of coefficients and individual Pauli matrices. Parenthetical expressions are handled appropriately. The result is a new Hamiltonian object that represents the product of the two input objects.

Parameters
otherThe Hamiltonian object to multiply with the current object.
Returns
A new Hamiltonian object that is the product of the current object and other.
  1. mul(self: hamiltonian.Hamiltonian, scalar: complex) -> hamiltonian.Hamiltonian

Overload for the multiplication operator with a complex scalar.

This method allows for the multiplication of a Hamiltonian object by a complex scalar. It returns a new Hamiltonian object that is the product of the current object and the scalar.

Parameters
scalarThe complex scalar to multiply the Hamiltonian by.
Returns
A new Hamiltonian object that is the product of the current object and scalar.

◆ __mul__() [2/2]

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

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

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

Overload for the multiplication operator between two Hamiltonians.

This method allows for the multiplication of two Hamiltonian objects. The multiplication follows the distributive property, with the smallest unit of operation being the multiplication of coefficients and individual Pauli matrices. Parenthetical expressions are handled appropriately. The result is a new Hamiltonian object that represents the product of the two input objects.

Parameters
otherThe Hamiltonian object to multiply with the current object.
Returns
A new Hamiltonian object that is the product of the current object and other.
  1. mul(self: hamiltonian.Hamiltonian, scalar: complex) -> hamiltonian.Hamiltonian

Overload for the multiplication operator with a complex scalar.

This method allows for the multiplication of a Hamiltonian object by a complex scalar. It returns a new Hamiltonian object that is the product of the current object and the scalar.

Parameters
scalarThe complex scalar to multiply the Hamiltonian by.
Returns
A new Hamiltonian object that is the product of the current object and scalar.

◆ __rmul__()

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

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

Overload for the multiplication operator with a complex scalar.

This method allows for the multiplication of a Hamiltonian object by a complex scalar. It returns a new Hamiltonian object that is the product of the current object and the scalar.

Parameters
scalarThe complex scalar to multiply the Hamiltonian by.
Returns
A new Hamiltonian object that is the product of the current object and scalar.

◆ __sub__()

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

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

Overload for the subtraction assignment operator to subtract another Hamiltonian.

This method subtracts the given Hamiltonian object other from the current Hamiltonian object and assigns the result back to the current object. (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 Hamiltonian object to subtract from the current object.
Returns
A reference to the current Hamiltonian object after the subtraction.

◆ str_no_I()

str pyqpanda3.hamiltonian.Hamiltonian.str_no_I ( self)

str_no_I(self: hamiltonian.Hamiltonian) -> str

Converts the Pauli operators to a string representation without the identity operator \'I\'.

  • This method represents the Pauli operators (X, Y, Z) acting on qubits as a string composed of characters \'X\', \'Y\', \'Z\', and numbers. For example, "X1 Y4" represents the Pauli operator X acting on the qubit with index 1 and the Pauli operator Y acting on the qubit with index 4. The parameter AB_is_A1_B0 determines the order of the character substrings representing the Pauli operators acting on the qubits. If AB_is_A1_B0 is true, the substring corresponding to the qubit with the larger index appears first in the resulting string; otherwise, it appears later.
  • Parameters
    AB_is_A1_B0A boolean value indicating the order of the substrings in the result.
    Returns
    A string representation of the Pauli operators without the identity operator \'I\'.

◆ str_with_I()

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

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

Converts the Hamiltonian to a string representation with Pauli matrices.

  • This method converts the current Hamiltonian 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 Hamiltonian object with Pauli matrices represented by 'X', 'Y', 'Z', and 'I'.

◆ str_withou_I()

str pyqpanda3.hamiltonian.Hamiltonian.str_withou_I ( self)

str_withou_I(self: hamiltonian.Hamiltonian) -> str

Converts the Pauli operators to a string representation without the identity operator \'I\'.

  • This method represents the Pauli operators (X, Y, Z) acting on qubits as a string composed of characters \'X\', \'Y\', \'Z\', and numbers. For example, "X1 Y4" represents the Pauli operator X acting on the qubit with index 1 and the Pauli operator Y acting on the qubit with index 4. The parameter AB_is_A1_B0 determines the order of the character substrings representing the Pauli operators acting on the qubits. If AB_is_A1_B0 is true, the substring corresponding to the qubit with the larger index appears first in the resulting string; otherwise, it appears later.
  • Parameters
    AB_is_A1_B0A boolean value indicating the order of the substrings in the result.
    Returns
    A string representation of the Pauli operators without the identity operator \'I\'.

◆ tensor() [1/2]

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

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

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

Overload for the tensor product operator between two Hamiltonians.

This method computes the tensor product of two Hamiltonian objects. In the resulting tensor product:

  1. The qubit indices in the current object (self) remain unchanged.
  2. The qubit indices in the other object (other) are incremented by the number of qubits in the current object. The result is a new Hamiltonian object that represents the tensor product of the two input objects.
Parameters
otherThe Hamiltonian object to compute the tensor product with the current object.
Returns
A new Hamiltonian object that is the tensor product of the current object and other.
  1. tensor(self: hamiltonian.Hamiltonian, n: int) -> hamiltonian.Hamiltonian

Overload for the exponentiation operator to perform tensor product.

  • This method allows for raising the Hamiltonian object to a power n by performing a tensor product with itself n-1 times. The tensor product is performed such that the qubit indices in the self object remain unchanged, while the indices in the other objects involved in the tensor product (implicit in the definition of the tensor product for Hamiltonians) are shifted to avoid overlap.
  • Parameters
    nThe power to which the Hamiltonian object is raised, corresponding to the number of tensor product operations performed.
    Returns
    A new Hamiltonian object that is the result of performing the tensor product with the initial object n-1 times.

◆ tensor() [2/2]

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

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

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

Overload for the tensor product operator between two Hamiltonians.

This method computes the tensor product of two Hamiltonian objects. In the resulting tensor product:

  1. The qubit indices in the current object (self) remain unchanged.
  2. The qubit indices in the other object (other) are incremented by the number of qubits in the current object. The result is a new Hamiltonian object that represents the tensor product of the two input objects.
Parameters
otherThe Hamiltonian object to compute the tensor product with the current object.
Returns
A new Hamiltonian object that is the tensor product of the current object and other.
  1. tensor(self: hamiltonian.Hamiltonian, n: int) -> hamiltonian.Hamiltonian

Overload for the exponentiation operator to perform tensor product.

  • This method allows for raising the Hamiltonian object to a power n by performing a tensor product with itself n-1 times. The tensor product is performed such that the qubit indices in the self object remain unchanged, while the indices in the other objects involved in the tensor product (implicit in the definition of the tensor product for Hamiltonians) are shifted to avoid overlap.
  • Parameters
    nThe power to which the Hamiltonian object is raised, corresponding to the number of tensor product operations performed.
    Returns
    A new Hamiltonian object that is the result of performing the tensor product with the initial object n-1 times.

◆ update_by_tensor() [1/2]

Hamiltonian pyqpanda3.hamiltonian.Hamiltonian.update_by_tensor ( self,
Hamiltonian other )

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

  1. update_by_tensor(self: hamiltonian.Hamiltonian, other: hamiltonian.Hamiltonian) -> hamiltonian.Hamiltonian

Overload for the tensor product assignment operator. This method computes the tensor product (Kronecker product) of the current Hamiltonian object with another Hamiltonian object other and assigns the result back to the current object.

Parameters
otherThe Hamiltonian object to compute the tensor product with.
Returns
A reference to the current Hamiltonian object after the tensor product operation.
Note
This operation is typically used in quantum mechanics and linear algebra contexts.
  1. update_by_tensor(self: hamiltonian.Hamiltonian, n: int) -> hamiltonian.Hamiltonian

Overload for the tensor product assignment operator to compute the n-th power of the tensor product.

  • This method computes the n-th power of the tensor product of the current Hamiltonian object with itself and assigns the result back to the current object. Note that this operation is equivalent to repeatedly applying the tensor product n times.
  • Parameters
    nThe power of the tensor product to compute.
    Returns
    A reference to the current Hamiltonian object after the tensor product power operation.
    See also
    Hamiltonian operator^(size_t n) for the non-assignment version of this operation.

◆ update_by_tensor() [2/2]

Hamiltonian pyqpanda3.hamiltonian.Hamiltonian.update_by_tensor ( self,
int n )

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

  1. update_by_tensor(self: hamiltonian.Hamiltonian, other: hamiltonian.Hamiltonian) -> hamiltonian.Hamiltonian

Overload for the tensor product assignment operator. This method computes the tensor product (Kronecker product) of the current Hamiltonian object with another Hamiltonian object other and assigns the result back to the current object.

Parameters
otherThe Hamiltonian object to compute the tensor product with.
Returns
A reference to the current Hamiltonian object after the tensor product operation.
Note
This operation is typically used in quantum mechanics and linear algebra contexts.
  1. update_by_tensor(self: hamiltonian.Hamiltonian, n: int) -> hamiltonian.Hamiltonian

Overload for the tensor product assignment operator to compute the n-th power of the tensor product.

  • This method computes the n-th power of the tensor product of the current Hamiltonian object with itself and assigns the result back to the current object. Note that this operation is equivalent to repeatedly applying the tensor product n times.
  • Parameters
    nThe power of the tensor product to compute.
    Returns
    A reference to the current Hamiltonian object after the tensor product power operation.
    See also
    Hamiltonian operator^(size_t n) for the non-assignment version of this operation.

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