fulqrum.core.FermionicOperator¶
- class FermionicOperator¶
Operator class for Fermionic operators
- Parameters:
width (int) – Number of modes
operators (list) – List of tuples for terms in Hamiltonian
Example:
import fulqrum as fq fq.FermionicOperator(5, [("++--", [0, 0, 1, 4], -0.018), ("+-", [3, 2], 0.4)])
<FermionicOperator[('+:0 +:0 -:1 -:4', (-0.018+0j)), ('-:2 +:3', (-0.4+0j))], width=5>Methods
append(self, FermionicOperator other)coefficients(self)Return the coefficients for each term in the operator
deflate_repeated_indices(self)Collapse repeated indices into singles and remove zero terms
Jordan-Wigner transformation over extended alphabet from Fermionic -> Qubit operator
from_dict(self, dict dic)FermionicOperator from dictionary
from_json(self, filename)Load operator from a JSON or XZ file.
from_label(self, size_t width, str label=, ...)Create FermionicOperator from a string label
to_dict(self)Dictionary representation of FermionicOperator
to_json(self, filename[, overwrite])Save operator to a JSON or XZ file.
weights(self)Weight of each term in the operator
Attributes
Return the coeff for a single term or empty operator
Return the number of terms in the operator
Return the operators for a single term or empty operator
Width of operator
- append(self, FermionicOperator other) void¶
- coeff¶
Return the coeff for a single term or empty operator
- Returns:
complex
- coefficients(self)¶
Return the coefficients for each term in the operator
- Returns:
complex-valued array of coefficients
- Return type:
ndarray
- deflate_repeated_indices(self)¶
Collapse repeated indices into singles and remove zero terms
- Returns:
Deflated operator
- Return type:
- extended_jw_transformation(self)¶
Jordan-Wigner transformation over extended alphabet from Fermionic -> Qubit operator
- classmethod from_dict(self, dict dic)¶
FermionicOperator from dictionary
- Parameters:
dic (dict) – Dictionary representation of operator
- Returns:
FermionicOperator
- classmethod from_json(self, filename)¶
Load operator from a JSON or XZ file.
- Parameters:
filename (str) – File to load from
- Returns:
FermionicOperator
- classmethod from_label(self, size_t width, str label='', double complex coeff=1.0)¶
Create FermionicOperator from a string label
- Parameters:
width (int) – Width of operator
label (str) – Label of operator
coeff (complex) – Complex coefficient, default=1.0
- Returns:
FermionicOperator
- num_terms¶
Return the number of terms in the operator
- Returns:
Number of terms in operator
- Return type:
int
- operators¶
Return the operators for a single term or empty operator
- Returns:
List of operator index tuples, if any, else None
- Return type:
list or None
Notes
This returns a list of tuples to allow for multiple indices in Fermionic operators
- to_dict(self)¶
Dictionary representation of FermionicOperator
- Returns:
Dictionary representation of FermionicOperator
- Return type:
dict
- to_json(self, filename, overwrite=False)¶
Save operator to a JSON or XZ file. File extension can be ‘json’ or ‘xz’, the latter or which does LZMA compression which is recommended for large operators.
- Parameters:
filename (str) – File to store to
overwrite (bool) – Overwrite file if it exits, default=False
- weights(self)¶
Weight of each term in the operator
- Returns:
Array of operator weights
- Return type:
ndarray
- width¶
Width of operator
- Returns:
int