Closes #5895 Add matrix support for fermionic objects
Context:
The fermi module includes functions and classes for creating and manipulating fermionic operators: FermiWord and FermiSentence class. It would be beneficial to add support for obtaining the matrix representation of these operators, similar to the to_mat instance method in the PauliWord and PauliSentence classes.
Description of the Change:
-
to_matinstance methods in theFermiWordandFermiSentenceclasses delegate the main logic to the_to_matfunction. -
_to_matfunction uses Jordan-Wigner transform to convert an instance ofFermiWordorFermiSentenceto aPauliWordorPauliSentenceinstance, then use the existingto_matmethod in the two classes to compute the matrix representation. -
_to_matfunction takesn_orbitalsas an optional input, which determines the matrix size $2^{n_\mathrm{orbitals}} \times 2^{n_\mathrm{orbitals}}$
Benefits:
The new method to_mat in FermiWord and FermiSentence class allows computing the matrix representation of a given Fermi operator.
Possible Drawbacks:
- Currently,
to_matinFermiWordandFermiSentenceclass only supports dense matrices. The exponential growth of matrix dimensions (a.k.a Fock space) with respect ton_orbitals(or the largest orbital index in the input fermionic operator) may limit its applicability.
Related GitHub Issues: #5895
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 99.65%. Comparing base (
497721a) to head (0dacfd4). Report is 285 commits behind head on master.
Additional details and impacted files
@@ Coverage Diff @@
## master #5920 +/- ##
==========================================
- Coverage 99.66% 99.65% -0.01%
==========================================
Files 427 427
Lines 41046 40765 -281
==========================================
- Hits 40907 40625 -282
- Misses 139 140 +1
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.