QPanda3
0.1.0
Supported by OriginQ
|
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 | |
None pyqpanda3.hamiltonian.Hamiltonian.__init__ | ( | self | ) |
init(*args, **kwargs) Overloaded function.
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.
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.
other | The Hamiltonian object to copy from. |
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.
other | The PauliOperator object to use for constructing the Hamiltonian. |
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
a_pauli | The string containing the Pauli operator representation. |
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}
ops | A map where the keys are strings representing quantum operators and the values are complex numbers representing the coefficients of those operators. |
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]
ops | A vector of strings representing quantum operators. |
coef_s | A vector of complex numbers representing the coefficients of the operators. |
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
ops | A vector of strings representing quantum operators. |
coef_s | A vector of complex numbers representing the coefficients of the operators. |
AB_is_A1_B0 | A boolean flag that specifies a particular configuration or interpretation of the operators. |
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)]
ops | A vector of tuples, where each tuple contains a string (operator), a vector of size_t (indices), and a complex number (coefficient). |
None pyqpanda3.hamiltonian.Hamiltonian.__init__ | ( | self, | |
Hamiltonian | other ) |
init(*args, **kwargs) Overloaded function.
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.
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.
other | The Hamiltonian object to copy from. |
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.
other | The PauliOperator object to use for constructing the Hamiltonian. |
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
a_pauli | The string containing the Pauli operator representation. |
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}
ops | A map where the keys are strings representing quantum operators and the values are complex numbers representing the coefficients of those operators. |
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]
ops | A vector of strings representing quantum operators. |
coef_s | A vector of complex numbers representing the coefficients of the operators. |
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
ops | A vector of strings representing quantum operators. |
coef_s | A vector of complex numbers representing the coefficients of the operators. |
AB_is_A1_B0 | A boolean flag that specifies a particular configuration or interpretation of the operators. |
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)]
ops | A vector of tuples, where each tuple contains a string (operator), a vector of size_t (indices), and a complex number (coefficient). |
None pyqpanda3.hamiltonian.Hamiltonian.__init__ | ( | self, | |
PauliOperator | pauli_operator ) |
init(*args, **kwargs) Overloaded function.
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.
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.
other | The Hamiltonian object to copy from. |
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.
other | The PauliOperator object to use for constructing the Hamiltonian. |
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
a_pauli | The string containing the Pauli operator representation. |
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}
ops | A map where the keys are strings representing quantum operators and the values are complex numbers representing the coefficients of those operators. |
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]
ops | A vector of strings representing quantum operators. |
coef_s | A vector of complex numbers representing the coefficients of the operators. |
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
ops | A vector of strings representing quantum operators. |
coef_s | A vector of complex numbers representing the coefficients of the operators. |
AB_is_A1_B0 | A boolean flag that specifies a particular configuration or interpretation of the operators. |
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)]
ops | A vector of tuples, where each tuple contains a string (operator), a vector of size_t (indices), and a complex number (coefficient). |
None pyqpanda3.hamiltonian.Hamiltonian.__init__ | ( | self, | |
str | pauli ) |
init(*args, **kwargs) Overloaded function.
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.
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.
other | The Hamiltonian object to copy from. |
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.
other | The PauliOperator object to use for constructing the Hamiltonian. |
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
a_pauli | The string containing the Pauli operator representation. |
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}
ops | A map where the keys are strings representing quantum operators and the values are complex numbers representing the coefficients of those operators. |
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]
ops | A vector of strings representing quantum operators. |
coef_s | A vector of complex numbers representing the coefficients of the operators. |
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
ops | A vector of strings representing quantum operators. |
coef_s | A vector of complex numbers representing the coefficients of the operators. |
AB_is_A1_B0 | A boolean flag that specifies a particular configuration or interpretation of the operators. |
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)]
ops | A vector of tuples, where each tuple contains a string (operator), a vector of size_t (indices), and a complex number (coefficient). |
None pyqpanda3.hamiltonian.Hamiltonian.__init__ | ( | self, | |
dict[str, complex] | pauli_with_coef_s ) |
init(*args, **kwargs) Overloaded function.
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.
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.
other | The Hamiltonian object to copy from. |
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.
other | The PauliOperator object to use for constructing the Hamiltonian. |
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
a_pauli | The string containing the Pauli operator representation. |
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}
ops | A map where the keys are strings representing quantum operators and the values are complex numbers representing the coefficients of those operators. |
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]
ops | A vector of strings representing quantum operators. |
coef_s | A vector of complex numbers representing the coefficients of the operators. |
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
ops | A vector of strings representing quantum operators. |
coef_s | A vector of complex numbers representing the coefficients of the operators. |
AB_is_A1_B0 | A boolean flag that specifies a particular configuration or interpretation of the operators. |
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)]
ops | A vector of tuples, where each tuple contains a string (operator), a vector of size_t (indices), and a complex number (coefficient). |
None pyqpanda3.hamiltonian.Hamiltonian.__init__ | ( | self, | |
list[str] | paulis, | ||
list[complex] | coefs ) |
init(*args, **kwargs) Overloaded function.
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.
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.
other | The Hamiltonian object to copy from. |
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.
other | The PauliOperator object to use for constructing the Hamiltonian. |
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
a_pauli | The string containing the Pauli operator representation. |
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}
ops | A map where the keys are strings representing quantum operators and the values are complex numbers representing the coefficients of those operators. |
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]
ops | A vector of strings representing quantum operators. |
coef_s | A vector of complex numbers representing the coefficients of the operators. |
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
ops | A vector of strings representing quantum operators. |
coef_s | A vector of complex numbers representing the coefficients of the operators. |
AB_is_A1_B0 | A boolean flag that specifies a particular configuration or interpretation of the operators. |
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)]
ops | A vector of tuples, where each tuple contains a string (operator), a vector of size_t (indices), and a complex number (coefficient). |
None pyqpanda3.hamiltonian.Hamiltonian.__init__ | ( | self, | |
list[str] | paulis, | ||
list[complex] | coefs, | ||
bool | AB_is_A1_B0 = ... ) |
init(*args, **kwargs) Overloaded function.
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.
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.
other | The Hamiltonian object to copy from. |
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.
other | The PauliOperator object to use for constructing the Hamiltonian. |
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
a_pauli | The string containing the Pauli operator representation. |
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}
ops | A map where the keys are strings representing quantum operators and the values are complex numbers representing the coefficients of those operators. |
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]
ops | A vector of strings representing quantum operators. |
coef_s | A vector of complex numbers representing the coefficients of the operators. |
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
ops | A vector of strings representing quantum operators. |
coef_s | A vector of complex numbers representing the coefficients of the operators. |
AB_is_A1_B0 | A boolean flag that specifies a particular configuration or interpretation of the operators. |
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)]
ops | A vector of tuples, where each tuple contains a string (operator), a vector of size_t (indices), and a complex number (coefficient). |
None pyqpanda3.hamiltonian.Hamiltonian.__init__ | ( | self, | |
list[tuple[str, list[int], complex]] | paulis_qbits_coef__s ) |
init(*args, **kwargs) Overloaded function.
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.
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.
other | The Hamiltonian object to copy from. |
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.
other | The PauliOperator object to use for constructing the Hamiltonian. |
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
a_pauli | The string containing the Pauli operator representation. |
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}
ops | A map where the keys are strings representing quantum operators and the values are complex numbers representing the coefficients of those operators. |
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]
ops | A vector of strings representing quantum operators. |
coef_s | A vector of complex numbers representing the coefficients of the operators. |
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
ops | A vector of strings representing quantum operators. |
coef_s | A vector of complex numbers representing the coefficients of the operators. |
AB_is_A1_B0 | A boolean flag that specifies a particular configuration or interpretation of the operators. |
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)]
ops | A vector of tuples, where each tuple contains a string (operator), a vector of size_t (indices), and a complex number (coefficient). |
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.
other | The Hamiltonian object to add to the current object. |
Hamiltonian
object that is the sum of the current object and H
. 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.
Hamiltonian
object with another Hamiltonian
object other
to determine if they are equal.other | The Hamiltonian object to compare with the current object. |
Hamiltonian
objects are equal, false otherwise. 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.
other | The Hamiltonian object to add to the current object. |
Hamiltonian
object after the addition. 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.
Hamiltonian
object by another Hamiltonian
object other
and assigns the result back to the current object.other | The Hamiltonian object to multiply with the current object. |
Hamiltonian
object after the multiplication. 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.
Hamiltonian
object other
from the current Hamiltonian
object and assigns the result back to the current object.other | The Hamiltonian object to subtract from the current object. |
Hamiltonian
object after the subtraction. 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.
other | The Hamiltonian object to multiply with the current object. |
Hamiltonian
object that is the product of the current object and other
. Hamiltonian pyqpanda3.hamiltonian.Hamiltonian.__mul__ | ( | self, | |
complex | scalar ) |
mul(*args, **kwargs) Overloaded function.
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.
other | The Hamiltonian object to multiply with the current object. |
Hamiltonian
object that is the product of the current object and other
.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.
scalar | The complex scalar to multiply the Hamiltonian by. |
Hamiltonian
object that is the product of the current object and scalar
. Hamiltonian pyqpanda3.hamiltonian.Hamiltonian.__mul__ | ( | self, | |
Hamiltonian | other ) |
mul(*args, **kwargs) Overloaded function.
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.
other | The Hamiltonian object to multiply with the current object. |
Hamiltonian
object that is the product of the current object and other
.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.
scalar | The complex scalar to multiply the Hamiltonian by. |
Hamiltonian
object that is the product of the current object and scalar
. 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.
scalar | The complex scalar to multiply the Hamiltonian by. |
Hamiltonian
object that is the product of the current object and scalar
. 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.
other | The Hamiltonian object to subtract from the current object. |
Hamiltonian
object after the subtraction. 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\'.
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.AB_is_A1_B0 | A boolean value indicating the order of the substrings in the result. |
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.
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.AB_is_A1_B0 | A boolean value that specifies the character order in relation to qubit indices. |
Hamiltonian
object with Pauli matrices represented by 'X', 'Y', 'Z', and '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\'.
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.AB_is_A1_B0 | A boolean value indicating the order of the substrings in the result. |
Hamiltonian pyqpanda3.hamiltonian.Hamiltonian.tensor | ( | self, | |
Hamiltonian | other ) |
tensor(*args, **kwargs) Overloaded function.
Overload for the tensor product operator between two Hamiltonians.
This method computes the tensor product of two Hamiltonian
objects. In the resulting tensor product:
self
) remain unchanged.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.other | The Hamiltonian object to compute the tensor product with the current object. |
Hamiltonian
object that is the tensor product of the current object and other
.Overload for the exponentiation operator to perform tensor product.
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.n | The power to which the Hamiltonian object is raised, corresponding to the number of tensor product operations performed. |
Hamiltonian
object that is the result of performing the tensor product with the initial object n-1
times. Hamiltonian pyqpanda3.hamiltonian.Hamiltonian.tensor | ( | self, | |
int | n ) |
tensor(*args, **kwargs) Overloaded function.
Overload for the tensor product operator between two Hamiltonians.
This method computes the tensor product of two Hamiltonian
objects. In the resulting tensor product:
self
) remain unchanged.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.other | The Hamiltonian object to compute the tensor product with the current object. |
Hamiltonian
object that is the tensor product of the current object and other
.Overload for the exponentiation operator to perform tensor product.
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.n | The power to which the Hamiltonian object is raised, corresponding to the number of tensor product operations performed. |
Hamiltonian
object that is the result of performing the tensor product with the initial object n-1
times. Hamiltonian pyqpanda3.hamiltonian.Hamiltonian.update_by_tensor | ( | self, | |
Hamiltonian | other ) |
update_by_tensor(*args, **kwargs) Overloaded function.
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.
other | The Hamiltonian object to compute the tensor product with. |
Hamiltonian
object after the tensor product operation. Overload for the tensor product assignment operator to compute the n-th power of the tensor product.
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.n | The power of the tensor product to compute. |
Hamiltonian
object after the tensor product power operation. Hamiltonian pyqpanda3.hamiltonian.Hamiltonian.update_by_tensor | ( | self, | |
int | n ) |
update_by_tensor(*args, **kwargs) Overloaded function.
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.
other | The Hamiltonian object to compute the tensor product with. |
Hamiltonian
object after the tensor product operation. Overload for the tensor product assignment operator to compute the n-th power of the tensor product.
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.n | The power of the tensor product to compute. |
Hamiltonian
object after the tensor product power operation.