qml.fermi.FermiWord¶
-
class
FermiWord
(operator)[source]¶ Bases:
dict
Immutable dictionary used to represent a Fermi word, a product of fermionic creation and annihilation operators, that can be constructed from a standard dictionary.
The keys of the dictionary are tuples of two integers. The first integer represents the position of the creation/annihilation operator in the Fermi word and the second integer represents the orbital it acts on. The values of the dictionary are one of
'+'
or'-'
symbols that denote creation and annihilation operators, respectively. The operator \(a^{\dagger}_0 a_1\) can then be constructed as>>> w = FermiWord({(0, 0) : '+', (1, 1) : '-'}) >>> w a⁺(0) a(1)
Attributes
Methods
Return a compact string representation of a FermiWord.
update
(item)Restrict updating FermiWord after instantiation.
-
to_string
()[source]¶ Return a compact string representation of a FermiWord. Each operator in the word is represented by the number of the wire it operates on, and a + or - to indicate either a creation or annihilation operator.
>>> w = FermiWord({(0, 0) : '+', (1, 1) : '-'}) >>> w.to_string() a⁺(0) a(1)
-