pennylane icon indicating copy to clipboard operation
pennylane copied to clipboard

Closes #5895 Add matrix support for fermionic objects

Open RenkeHuang opened this issue 1 year ago • 1 comments

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_mat instance methods in the FermiWord and FermiSentence classes delegate the main logic to the _to_mat function.
  • _to_mat function uses Jordan-Wigner transform to convert an instance of FermiWord or FermiSentence to a PauliWord or PauliSentence instance, then use the existing to_mat method in the two classes to compute the matrix representation.
  • _to_mat function takes n_orbitals as 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_mat in FermiWord and FermiSentence class only supports dense matrices. The exponential growth of matrix dimensions (a.k.a Fock space) with respect to n_orbitals (or the largest orbital index in the input fermionic operator) may limit its applicability.

Related GitHub Issues: #5895

RenkeHuang avatar Jun 29 '24 09:06 RenkeHuang

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.

codecov[bot] avatar Jun 29 '24 09:06 codecov[bot]