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 qubit Operator.

See also

FermiA

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)

wires

Return wires in a FermiWord.

wires

Return wires in a FermiWord.

adjoint()

Return the adjoint of FermiC.

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()

Returns the dictionary items in sorted order.

keys()

pop(k[,d])

If the key is not found, return the default if given; otherwise, raise a KeyError.

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.

shift_operator(initial_position, final_position)

Shifts an operator in the FermiWord from initial_position to final_position by applying the fermionic anti-commutation relations.

to_mat([n_orbitals, format, buffer_size])

Return the matrix representation.

to_string()

Return a compact string representation of a FermiWord.

update(item)

Restrict updating FermiWord after instantiation.

values()

adjoint()[source]

Return the adjoint of FermiC.

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()

Returns the dictionary items in sorted order.

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 the key is not found, return the default if given; otherwise, raise a KeyError.

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.

shift_operator(initial_position, final_position)

Shifts an operator in the FermiWord from initial_position to final_position by applying the fermionic anti-commutation relations.

There are three anti-commutator relations:

\[\left\{ a_i, a_j \right\} = 0, \quad \left\{ a^{\dagger}_i, a^{\dagger}_j \right\} = 0, \quad \left\{ a_i, a^{\dagger}_j \right\} = \delta_{ij},\]

where

\[\left\{a_i, a_j \right\} = a_i a_j + a_j a_i,\]

and

\[\begin{split}\delta_{ij} = \begin{cases} 1 & i = j \\ 0 & i \neq j \end{cases}.\end{split}\]
Parameters
  • initial_position (int) – The position of the operator to be shifted.

  • final_position (int) – The desired position of the operator.

Returns

The FermiSentence obtained after applying the anti-commutator relations.

Return type

FermiSentence

Raises
  • TypeError – if initial_position or final_position is not an integer

  • ValueError – if initial_position or final_position are outside the range [0, len(fermiword) - 1] where len(fermiword) is the number of operators in the FermiWord.

Example

>>> w = qml.fermi.FermiWord({(0, 0): '+', (1, 1): '-'})
>>> w.shift_operator(0, 1)
-1 * a(1) a⁺(0)
to_mat(n_orbitals=None, format='dense', buffer_size=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.

  • format (str) – The format of the matrix. It is “dense” by default. Use “csr” for sparse.

  • buffer_size (int or None) – The maximum allowed memory in bytes to store intermediate results in the calculation of sparse matrices. It defaults to 2 ** 30 bytes that make 1GB of memory. In general, larger buffers allow faster computations.

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

Contents

Using PennyLane

Release news

Development

API

Internals