qml.FermiC¶
-
class
FermiC
(orbital)[source]¶ Bases:
pennylane.fermi.fermionic.FermiWord
The fermionic creation operator \(a^{\dagger}\)
For instance, the operator
qml.FermiC(2)
denotes \(a^{\dagger}_2\). This operator applied to \(\ket{0000}\) gives \(\ket{0010}\).- Parameters
orbital (int) – the non-negative integer indicating the orbital the operator acts on.
Note
While the
FermiC
class represents a mathematical operator, it is not a PennyLane qubitOperator
.See also
Example
To construct the operator \(a^{\dagger}_0\):
>>> FermiC(0) a⁺(0)
This can be combined with the annihilation operator
FermiA
. For example, \(a^{\dagger}_0 a_1 a^{\dagger}_2 a_3\) can be constructed as:>>> qml.FermiC(0) * qml.FermiA(1) * qml.FermiC(2) * qml.FermiA(3) a⁺(0) a(1) a⁺(2) a(3)
Attributes
Methods
clear
()copy
()fromkeys
([value])Create a new dictionary with keys from iterable and values set to value.
get
(key[, default])Return the value for key if key is in the dictionary, else default.
items
()keys
()pop
(k[,d])If key is not found, default is returned if given, otherwise KeyError is raised
popitem
()Remove and return a (key, value) pair as a 2-tuple.
setdefault
(key[, default])Insert key with a value of default if key is not in the dictionary.
to_mat
([n_orbitals])Return the matrix representation.
Return a compact string representation of a FermiWord.
update
(item)Restrict updating FermiWord after instantiation.
values
()-
clear
() → None. Remove all items from D.¶
-
copy
() → a shallow copy of D¶
-
fromkeys
(value=None, /)¶ Create a new dictionary with keys from iterable and values set to value.
-
get
(key, default=None, /)¶ Return the value for key if key is in the dictionary, else default.
-
items
() → a set-like object providing a view on D’s items¶
-
keys
() → a set-like object providing a view on D’s keys¶
-
pop
(k[, d]) → v, remove specified key and return the corresponding value.¶ If key is not found, default is returned if given, otherwise KeyError is raised
-
popitem
()¶ Remove and return a (key, value) pair as a 2-tuple.
Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.
-
setdefault
(key, default=None, /)¶ Insert key with a value of default if key is not in the dictionary.
Return the value for key if key is in the dictionary, else default.
-
to_mat
(n_orbitals=None)¶ Return the matrix representation.
- Parameters
n_orbitals (int or None) – Number of orbitals. If not provided, it will be inferred from the largest orbital index in the Fermi operator.
- Returns
Matrix representation of the
FermiWord
.- Return type
NumpyArray
Example
>>> w = FermiWord({(0, 0): '+', (1, 1): '-'}) >>> w.to_mat() array([0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j], [0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j], [0.+0.j, 1.+0.j, 0.+0.j, 0.+0.j], [0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j])
-
to_string
()¶ 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)
-
update
(item)¶ Restrict updating FermiWord after instantiation.
-
values
() → an object providing a view on D’s values¶