Linopt
Linear optics circuit calculator
|
The class representing a collection of Fock states. More...
#include <states.h>
Public Types | |
using | Set = std::set< Fock > |
Convenience typedef to std::set. | |
using | Value = Fock |
using | value_type = Value |
using | Reference = Value & |
using | reference = Reference |
using | Iterator = Base::iterator |
using | ConstIterator = Base::const_iterator |
using | ReverseIterator = Base::reverse_iterator |
using | ConstReverseIterator = Base::const_reverse_iterator |
Public Member Functions | |
int | size () const |
Returns the number of Fock states in the basis. | |
Basis (const Set &s) | |
Basis (std::initializer_list< Fock > il) | |
Basis (int nphot, int modes) | |
Constructs a basis of all possible Fock states with modes modes and containing nphot photons. | |
Basis | operator+ (const Basis &b) const |
Returns a basis which is a union of Fock states from both *this and b . | |
Basis & | operator+= (const Basis &b) |
Effectively equivalent to *this = (*this) + b . | |
Basis | operator* (const Basis &b) const |
Calculates a tensor product of two bases. More... | |
Basis & | operator*= (const Basis &b) |
Effectively equivalent to *this = (*this) * b . | |
Basis & | generateBasis (const int nphot, const int modes, const Fock &head=Fock()) |
Generates a basis of all possible Fock states with modes modes and containing nphot photons. More... | |
Basis | postselect (const Fock &ancilla) const |
Returns a postselected basis after observing ancilla. More... | |
template<typename ExecPolicy = execution::Seq> | |
State | applyFunction (const FockAmpFunction &f) const |
Constructs a state from the basis using function f . More... | |
The class representing a collection of Fock states.
The interface of this class is very similar to std::set<fock>
.
State Basis::applyFunction | ( | const FockAmpFunction & | f | ) | const |
Constructs a state from the basis using function f
.
[in] | f | – function to apply. |
Applies a function f
to all Fock states of *this
to compute a corresponding amplitude of a resulting state.
Generates a basis of all possible Fock states with modes
modes and containing nphot
photons.
[in] | nphot | – number of photons in each Fock state. |
[in] | modes | – number of modes in each Fock state. |
[in] | head | – intended for internal usage. Normally empty Fock state should be passed. |
*this
and never removes them. Therefore, if you want to freshly generate a basis, you should call basis::clear
first. Calculates a tensor product of two bases.
Returns a basis consisting of all possible elementwise tensor products of elements of *this
and b
.
Returns a postselected basis after observing ancilla.
[in] | ancilla | – ancilla's Fock state for postselection. |
Postselection of a basis \( B \) with the ancilla state \( | \mathrm{anc} \rangle = | a_0, a_2, \dots, a_A \rangle \) picks only Fock states from \( B \) with the heading (first \( A \) occupation numbers) which equals to \( | \mathrm{anc} \rangle \). The headings do not get to the new constructed basis. Note that currently there is no possibility to specify a position of ancilla modes.
For example, postselection of a basis
\[ \{ | 0000001 \rangle, | 1234567 \rangle, | 1239999 \rangle \} \]
with the ancilla \( | 123 \rangle \) results in the basis
\[ \{ | 4567 \rangle, | 9999 \rangle \}. \]