Linopt
Linear optics circuit calculator
Public Types | Public Member Functions | List of all members
linopt::Basis Class Reference

The class representing a collection of Fock states. More...

#include <states.h>

Inheritance diagram for linopt::Basis:
Inheritance graph
[legend]
Collaboration diagram for linopt::Basis:
Collaboration graph
[legend]

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.
 
Basisoperator+= (const Basis &b)
 Effectively equivalent to *this = (*this) + b.
 
Basis operator* (const Basis &b) const
 Calculates a tensor product of two bases. More...
 
Basisoperator*= (const Basis &b)
 Effectively equivalent to *this = (*this) * b.
 
BasisgenerateBasis (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...
 

Detailed Description

The class representing a collection of Fock states.

The interface of this class is very similar to std::set<fock>.

Member Function Documentation

◆ applyFunction()

template<typename ExecPolicy >
State Basis::applyFunction ( const FockAmpFunction f) const

Constructs a state from the basis using function f.

Parameters
[in]f– function to apply.
Returns
Constructed state.

Applies a function f to all Fock states of *this to compute a corresponding amplitude of a resulting state.

◆ generateBasis()

Basis & 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.

Parameters
[in]nphot– number of photons in each Fock state.
[in]modes– number of modes in each Fock state.
Deprecated:
Parameters
[in]head– intended for internal usage. Normally empty Fock state should be passed.
Note
This funtion only appends elements to *this and never removes them. Therefore, if you want to freshly generate a basis, you should call basis::clear first.

◆ operator*()

Basis Basis::operator* ( const Basis b) const

Calculates a tensor product of two bases.

Returns a basis consisting of all possible elementwise tensor products of elements of *this and b.

◆ postselect()

Basis Basis::postselect ( const Fock ancilla) const

Returns a postselected basis after observing ancilla.

Parameters
[in]ancilla– ancilla's Fock state for postselection.
Returns
A basis after 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 \}. \]


The documentation for this class was generated from the following files: