Quantum++  v1.0-rc3
A modern C++11 quantum computing library
qpp Namespace Reference

Quantum++ main namespace. More...

Namespaces

 exception
 Quantum++ exception hierarchy namespace.
 
 experimental
 Experimental/test functions/classes, do not use or modify.
 
 internal
 Internal utility functions, do not use them directly or modify them.
 

Classes

class  Bit_circuit
 Classical reversible circuit simulator. More...
 
class  Codes
 const Singleton class that defines quantum error correcting codes More...
 
class  Dynamic_bitset
 Dynamic bitset class, allows the specification of the number of bits at runtime (unlike std::bitset<N>) More...
 
class  Gates
 const Singleton class that implements most commonly used gates More...
 
class  IDisplay
 Abstract class (interface) that mandates the definition of virtual std::ostream& display(std::ostream& os) const. More...
 
class  Init
 const Singleton class that performs additional initializations/cleanups More...
 
struct  is_complex
 Checks whether the type is a complex type. More...
 
struct  is_complex< std::complex< T > >
 Checks whether the type is a complex number type, specialization for complex types. More...
 
struct  is_iterable
 Checks whether T is compatible with an STL-like iterable container. More...
 
struct  is_iterable< T, to_void< decltype(std::declval< T >().begin()), decltype(std::declval< T >().end()), typename T::value_type > >
 Checks whether T is compatible with an STL-like iterable container, specialization for STL-like iterable containers. More...
 
struct  is_matrix_expression
 Checks whether the type is an Eigen matrix expression. More...
 
struct  make_void
 Helper for qpp::to_void<> alias template. More...
 
class  RandomDevices
 Singleton class that manages the source of randomness in the library. More...
 
class  States
 const Singleton class that implements most commonly used states More...
 
class  Timer
 Chronometer. More...
 

Typedefs

template<typename... Ts>
using to_void = typename make_void< Ts... >::type
 Alias template that implements the proposal for void_t. More...
 
using idx = std::size_t
 Non-negative integer index. More...
 
using bigint = long long int
 Big integer. More...
 
using cplx = std::complex< double >
 Complex number in double precision. More...
 
using ket = Eigen::VectorXcd
 Complex (double precision) dynamic Eigen column vector. More...
 
using bra = Eigen::RowVectorXcd
 Complex (double precision) dynamic Eigen row vector. More...
 
using cmat = Eigen::MatrixXcd
 Complex (double precision) dynamic Eigen matrix. More...
 
using dmat = Eigen::MatrixXd
 Real (double precision) dynamic Eigen matrix. More...
 
template<typename Scalar >
using dyn_mat = Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic >
 Dynamic Eigen matrix over the field specified by Scalar. More...
 
template<typename Scalar >
using dyn_col_vect = Eigen::Matrix< Scalar, Eigen::Dynamic, 1 >
 Dynamic Eigen column vector over the field specified by Scalar. More...
 
template<typename Scalar >
using dyn_row_vect = Eigen::Matrix< Scalar, 1, Eigen::Dynamic >
 Dynamic Eigen row vector over the field specified by Scalar. More...
 

Functions

constexpr cplx operator"" _i (unsigned long long int x) noexcept
 User-defined literal for complex $i=\sqrt{-1}$ (integer overload) More...
 
constexpr cplx operator"" _i (long double x) noexcept
 User-defined literal for complex $i=\sqrt{-1}$ (real overload) More...
 
cplx omega (idx D)
 D-th root of unity. More...
 
template<typename Derived >
dyn_col_vect< double > schmidtcoeffs (const Eigen::MatrixBase< Derived > &A, const std::vector< idx > &dims)
 Schmidt coefficients of the bi-partite pure state A. More...
 
template<typename Derived >
dyn_col_vect< double > schmidtcoeffs (const Eigen::MatrixBase< Derived > &A, idx d=2)
 Schmidt coefficients of the bi-partite pure state A. More...
 
template<typename Derived >
cmat schmidtA (const Eigen::MatrixBase< Derived > &A, const std::vector< idx > &dims)
 Schmidt basis on Alice side. More...
 
template<typename Derived >
cmat schmidtA (const Eigen::MatrixBase< Derived > &A, idx d=2)
 Schmidt basis on Alice side. More...
 
template<typename Derived >
cmat schmidtB (const Eigen::MatrixBase< Derived > &A, const std::vector< idx > &dims)
 Schmidt basis on Bob side. More...
 
template<typename Derived >
cmat schmidtB (const Eigen::MatrixBase< Derived > &A, idx d=2)
 Schmidt basis on Bob side. More...
 
template<typename Derived >
std::vector< double > schmidtprobs (const Eigen::MatrixBase< Derived > &A, const std::vector< idx > &dims)
 Schmidt probabilities of the bi-partite pure state A. More...
 
template<typename Derived >
std::vector< double > schmidtprobs (const Eigen::MatrixBase< Derived > &A, idx d=2)
 Schmidt probabilities of the bi-partite pure state A. More...
 
template<typename Derived >
double entanglement (const Eigen::MatrixBase< Derived > &A, const std::vector< idx > &dims)
 Entanglement of the bi-partite pure state A. More...
 
template<typename Derived >
double entanglement (const Eigen::MatrixBase< Derived > &A, idx d=2)
 Entanglement of the bi-partite pure state A. More...
 
template<typename Derived >
double gconcurrence (const Eigen::MatrixBase< Derived > &A)
 G-concurrence of the bi-partite pure state A. More...
 
template<typename Derived >
double negativity (const Eigen::MatrixBase< Derived > &A, const std::vector< idx > &dims)
 Negativity of the bi-partite mixed state A. More...
 
template<typename Derived >
double negativity (const Eigen::MatrixBase< Derived > &A, idx d=2)
 Negativity of the bi-partite mixed state A. More...
 
template<typename Derived >
double lognegativity (const Eigen::MatrixBase< Derived > &A, const std::vector< idx > &dims)
 Logarithmic negativity of the bi-partite mixed state A. More...
 
template<typename Derived >
double lognegativity (const Eigen::MatrixBase< Derived > &A, idx d=2)
 Logarithmic negativity of the bi-partite mixed state A. More...
 
template<typename Derived >
double concurrence (const Eigen::MatrixBase< Derived > &A)
 Wootters concurrence of the bi-partite qubit mixed state A. More...
 
template<typename Derived >
double entropy (const Eigen::MatrixBase< Derived > &A)
 von-Neumann entropy of the density matrix A More...
 
double entropy (const std::vector< double > &prob)
 Shannon entropy of the probability distribution prob. More...
 
template<typename Derived >
double renyi (const Eigen::MatrixBase< Derived > &A, double alpha)
 Renyi- $\alpha$ entropy of the density matrix A, for $\alpha\geq 0$. More...
 
double renyi (const std::vector< double > &prob, double alpha)
 Renyi- $\alpha$ entropy of the probability distribution prob, for $\alpha\geq 0$. More...
 
template<typename Derived >
double tsallis (const Eigen::MatrixBase< Derived > &A, double q)
 Tsallis- $q$ entropy of the density matrix A, for $q\geq 0$. More...
 
double tsallis (const std::vector< double > &prob, double q)
 Tsallis- $q$ entropy of the probability distribution prob, for $q\geq 0$. More...
 
template<typename Derived >
double qmutualinfo (const Eigen::MatrixBase< Derived > &A, const std::vector< idx > &subsysA, const std::vector< idx > &subsysB, const std::vector< idx > &dims)
 Quantum mutual information between 2 subsystems of a composite system. More...
 
template<typename Derived >
double qmutualinfo (const Eigen::MatrixBase< Derived > &A, const std::vector< idx > &subsysA, const std::vector< idx > &subsysB, idx d=2)
 Quantum mutual information between 2 subsystems of a composite system. More...
 
template<typename Derived >
internal::IOManipEigen disp (const Eigen::MatrixBase< Derived > &A, double chop=qpp::chop)
 Eigen expression ostream manipulator. More...
 
internal::IOManipEigen disp (cplx z, double chop=qpp::chop)
 Complex number ostream manipulator. More...
 
template<typename InputIterator >
internal::IOManipRange< InputIterator > disp (InputIterator first, InputIterator last, const std::string &separator, const std::string &start="[", const std::string &end="]")
 Range ostream manipulator. More...
 
template<typename Container >
internal::IOManipRange< typename Container::const_iterator > disp (const Container &c, const std::string &separator, const std::string &start="[", const std::string &end="]", typename std::enable_if< is_iterable< Container >::value >::type *=nullptr)
 Standard container ostream manipulator. The container must support std::begin(), std::end() and forward iteration. More...
 
template<typename PointerType >
internal::IOManipPointer< PointerType > disp (const PointerType *p, idx N, const std::string &separator, const std::string &start="[", const std::string &end="]")
 C-style pointer ostream manipulator. More...
 
template<typename Derived >
void save (const Eigen::MatrixBase< Derived > &A, const std::string &fname)
 Saves Eigen expression to a binary file (internal format) in double precision. More...
 
template<typename Derived >
dyn_mat< typename Derived::Scalar > load (const std::string &fname)
 Loads Eigen matrix from a binary file (internal format) in double precision. More...
 
template<typename Derived >
dyn_col_vect< typename Derived::Scalar > ip (const Eigen::MatrixBase< Derived > &phi, const Eigen::MatrixBase< Derived > &psi, const std::vector< idx > &subsys, const std::vector< idx > &dims)
 Generalized inner product. More...
 
template<typename Derived >
dyn_col_vect< typename Derived::Scalar > ip (const Eigen::MatrixBase< Derived > &phi, const Eigen::MatrixBase< Derived > &psi, const std::vector< idx > &subsys, idx d=2)
 Generalized inner product. More...
 
template<typename Derived >
std::tuple< idx, std::vector< double >, std::vector< cmat > > measure (const Eigen::MatrixBase< Derived > &A, const std::vector< cmat > &Ks)
 Measures the state A using the set of Kraus operators Ks. More...
 
template<typename Derived >
std::tuple< idx, std::vector< double >, std::vector< cmat > > measure (const Eigen::MatrixBase< Derived > &A, const std::initializer_list< cmat > &Ks)
 Measures the state A using the set of Kraus operators Ks. More...
 
template<typename Derived >
std::tuple< idx, std::vector< double >, std::vector< cmat > > measure (const Eigen::MatrixBase< Derived > &A, const cmat &U)
 Measures the state A in the orthonormal basis specified by the unitary matrix U. More...
 
template<typename Derived >
std::tuple< idx, std::vector< double >, std::vector< cmat > > measure (const Eigen::MatrixBase< Derived > &A, const std::vector< cmat > &Ks, const std::vector< idx > &subsys, const std::vector< idx > &dims)
 Measures the part subsys of the multi-partite state vector or density matrix A using the set of Kraus operators Ks. More...
 
template<typename Derived >
std::tuple< idx, std::vector< double >, std::vector< cmat > > measure (const Eigen::MatrixBase< Derived > &A, const std::initializer_list< cmat > &Ks, const std::vector< idx > &subsys, const std::vector< idx > &dims)
 Measures the part subsys of the multi-partite state vector or density matrix A using the set of Kraus operators Ks. More...
 
template<typename Derived >
std::tuple< idx, std::vector< double >, std::vector< cmat > > measure (const Eigen::MatrixBase< Derived > &A, const std::vector< cmat > &Ks, const std::vector< idx > &subsys, idx d=2)
 Measures the part subsys of the multi-partite state vector or density matrix A using the set of Kraus operators Ks. More...
 
template<typename Derived >
std::tuple< idx, std::vector< double >, std::vector< cmat > > measure (const Eigen::MatrixBase< Derived > &A, const std::initializer_list< cmat > &Ks, const std::vector< idx > &subsys, idx d=2)
 Measures the part subsys of the multi-partite state vector or density matrix A using the set of Kraus operators Ks. More...
 
template<typename Derived >
std::tuple< idx, std::vector< double >, std::vector< cmat > > measure (const Eigen::MatrixBase< Derived > &A, const cmat &V, const std::vector< idx > &subsys, const std::vector< idx > &dims)
 Measures the part subsys of the multi-partite state vector or density matrix A in the orthonormal basis or rank-1 POVM specified by the matrix V. More...
 
template<typename Derived >
std::tuple< idx, std::vector< double >, std::vector< cmat > > measure (const Eigen::MatrixBase< Derived > &A, const cmat &V, const std::vector< idx > &subsys, idx d=2)
 Measures the part subsys of the multi-partite state vector or density matrix A in the orthonormal basis or rank-1 POVM specified by the matrix V. More...
 
template<typename Derived >
std::tuple< std::vector< idx >, double, cmatmeasure_seq (const Eigen::MatrixBase< Derived > &A, std::vector< idx > subsys, std::vector< idx > dims)
 Sequentially measures the part subsys of the multi-partite state vector or density matrix A in the computational basis. More...
 
template<typename Derived >
std::tuple< std::vector< idx >, double, cmatmeasure_seq (const Eigen::MatrixBase< Derived > &A, std::vector< idx > subsys, idx d=2)
 Sequentially measures the part subsys of the multi-partite state vector or density matrix A in the computational basis. More...
 
template<typename Derived >
std::enable_if< std::is_same< typename Derived::Scalar, cplx >::value, dyn_mat< cplx > >::type loadMATLAB (const std::string &mat_file, const std::string &var_name)
 Loads a complex Eigen dynamic matrix from a MATLAB .mat file,. More...
 
template<typename Derived >
std::enable_if<!std::is_same< typename Derived::Scalar, cplx >::value, dyn_mat< typename Derived::Scalar > >::type loadMATLAB (const std::string &mat_file, const std::string &var_name)
 Loads a non-complex Eigen dynamic matrix from a MATLAB .mat file,. More...
 
template<typename Derived >
std::enable_if< std::is_same< typename Derived::Scalar, cplx >::value >::type saveMATLAB (const Eigen::MatrixBase< Derived > &A, const std::string &mat_file, const std::string &var_name, const std::string &mode)
 Saves a complex Eigen dynamic matrix to a MATLAB .mat file,. More...
 
template<typename Derived >
std::enable_if< !std::is_same< typename Derived::Scalar, cplx >::value >::type saveMATLAB (const Eigen::MatrixBase< Derived > &A, const std::string &mat_file, const std::string &var_name, const std::string &mode)
 Saves a non-complex Eigen dynamic matrix to a MATLAB .mat file,. More...
 
std::vector< int > x2contfrac (double x, idx N, idx cut=1e5)
 Simple continued fraction expansion. More...
 
double contfrac2x (const std::vector< int > &cf, idx N=idx(-1))
 Real representation of a simple continued fraction. More...
 
bigint gcd (bigint a, bigint b)
 Greatest common divisor of two integers. More...
 
bigint gcd (const std::vector< bigint > &as)
 Greatest common divisor of a list of integers. More...
 
bigint lcm (bigint a, bigint b)
 Least common multiple of two integers. More...
 
bigint lcm (const std::vector< bigint > &as)
 Least common multiple of a list of integers. More...
 
std::vector< idxinvperm (const std::vector< idx > &perm)
 Inverse permutation. More...
 
std::vector< idxcompperm (const std::vector< idx > &perm, const std::vector< idx > &sigma)
 Compose permutations. More...
 
std::vector< bigintfactors (bigint a)
 Prime factor decomposition. More...
 
bigint modmul (bigint a, bigint b, bigint p)
 Modular multiplication without overflow. More...
 
bigint modpow (bigint a, bigint n, bigint p)
 Fast integer power modulo p based on the SQUARE-AND-MULTIPLY algorithm. More...
 
std::tuple< bigint, bigint, bigintegcd (bigint a, bigint b)
 Extended greatest common divisor of two integers. More...
 
bigint modinv (bigint a, bigint p)
 Modular inverse of a mod p. More...
 
bool isprime (bigint p, idx k=80)
 Primality test based on the Miller-Rabin's algorithm. More...
 
bigint randprime (bigint a, bigint b, idx N=1000)
 Generates a random big prime uniformly distributed in the interval [a, b]. More...
 
template<typename Derived1 , typename Derived2 >
dyn_mat< typename Derived1::Scalar > applyCTRL (const Eigen::MatrixBase< Derived1 > &state, const Eigen::MatrixBase< Derived2 > &A, const std::vector< idx > &ctrl, const std::vector< idx > &subsys, const std::vector< idx > &dims)
 Applies the controlled-gate A to the part subsys of the multi-partite state vector or density matrix state. More...
 
template<typename Derived1 , typename Derived2 >
dyn_mat< typename Derived1::Scalar > applyCTRL (const Eigen::MatrixBase< Derived1 > &state, const Eigen::MatrixBase< Derived2 > &A, const std::vector< idx > &ctrl, const std::vector< idx > &subsys, idx d=2)
 Applies the controlled-gate A to the part subsys of the multi-partite state vector or density matrix state. More...
 
template<typename Derived1 , typename Derived2 >
dyn_mat< typename Derived1::Scalar > apply (const Eigen::MatrixBase< Derived1 > &state, const Eigen::MatrixBase< Derived2 > &A, const std::vector< idx > &subsys, const std::vector< idx > &dims)
 Applies the gate A to the part subsys of the multi-partite state vector or density matrix state. More...
 
template<typename Derived1 , typename Derived2 >
dyn_mat< typename Derived1::Scalar > apply (const Eigen::MatrixBase< Derived1 > &state, const Eigen::MatrixBase< Derived2 > &A, const std::vector< idx > &subsys, idx d=2)
 Applies the gate A to the part subsys of the multi-partite state vector or density matrix state. More...
 
template<typename Derived >
cmat apply (const Eigen::MatrixBase< Derived > &A, const std::vector< cmat > &Ks)
 Applies the channel specified by the set of Kraus operators Ks to the density matrix A. More...
 
template<typename Derived >
cmat apply (const Eigen::MatrixBase< Derived > &A, const std::vector< cmat > &Ks, const std::vector< idx > &subsys, const std::vector< idx > &dims)
 Applies the channel specified by the set of Kraus operators Ks to the part subsys of the multi-partite density matrix A. More...
 
template<typename Derived >
cmat apply (const Eigen::MatrixBase< Derived > &A, const std::vector< cmat > &Ks, const std::vector< idx > &subsys, idx d=2)
 Applies the channel specified by the set of Kraus operators Ks to the part subsys of the multi-partite density matrix A. More...
 
cmat kraus2super (const std::vector< cmat > &Ks)
 Superoperator matrix. More...
 
cmat kraus2choi (const std::vector< cmat > &Ks)
 Choi matrix. More...
 
std::vector< cmatchoi2kraus (const cmat &A)
 Orthogonal Kraus operators from Choi matrix. More...
 
cmat choi2super (const cmat &A)
 Converts Choi matrix to superoperator matrix. More...
 
cmat super2choi (const cmat &A)
 Converts superoperator matrix to Choi matrix. More...
 
template<typename Derived >
dyn_mat< typename Derived::Scalar > ptrace1 (const Eigen::MatrixBase< Derived > &A, const std::vector< idx > &dims)
 Partial trace. More...
 
template<typename Derived >
dyn_mat< typename Derived::Scalar > ptrace1 (const Eigen::MatrixBase< Derived > &A, idx d=2)
 Partial trace. More...
 
template<typename Derived >
dyn_mat< typename Derived::Scalar > ptrace2 (const Eigen::MatrixBase< Derived > &A, const std::vector< idx > &dims)
 Partial trace. More...
 
template<typename Derived >
dyn_mat< typename Derived::Scalar > ptrace2 (const Eigen::MatrixBase< Derived > &A, idx d=2)
 Partial trace. More...
 
template<typename Derived >
dyn_mat< typename Derived::Scalar > ptrace (const Eigen::MatrixBase< Derived > &A, const std::vector< idx > &subsys, const std::vector< idx > &dims)
 Partial trace. More...
 
template<typename Derived >
dyn_mat< typename Derived::Scalar > ptrace (const Eigen::MatrixBase< Derived > &A, const std::vector< idx > &subsys, idx d=2)
 Partial trace. More...
 
template<typename Derived >
dyn_mat< typename Derived::Scalar > ptranspose (const Eigen::MatrixBase< Derived > &A, const std::vector< idx > &subsys, const std::vector< idx > &dims)
 Partial transpose. More...
 
template<typename Derived >
dyn_mat< typename Derived::Scalar > ptranspose (const Eigen::MatrixBase< Derived > &A, const std::vector< idx > &subsys, idx d=2)
 Partial transpose. More...
 
template<typename Derived >
dyn_mat< typename Derived::Scalar > syspermute (const Eigen::MatrixBase< Derived > &A, const std::vector< idx > &perm, const std::vector< idx > &dims)
 Subsystem permutation. More...
 
template<typename Derived >
dyn_mat< typename Derived::Scalar > syspermute (const Eigen::MatrixBase< Derived > &A, const std::vector< idx > &perm, idx d=2)
 Subsystem permutation. More...
 
double rand (double a, double b)
 Generates a random real number uniformly distributed in the interval [a, b) More...
 
bigint rand (bigint a, bigint b)
 Generates a random big integer uniformly distributed in the interval [a, b]. More...
 
idx randidx (idx a=std::numeric_limits< idx >::min(), idx b=std::numeric_limits< idx >::max())
 Generates a random index (idx) uniformly distributed in the interval [a, b]. More...
 
template<typename Derived >
Derived rand (idx rows, idx cols, double a=0, double b=1)
 Generates a random matrix with entries uniformly distributed in the interval [a, b) More...
 
template<>
dmat rand (idx rows, idx cols, double a, double b)
 Generates a random real matrix with entries uniformly distributed in the interval [a, b), specialization for double matrices (qpp::dmat) More...
 
template<>
cmat rand (idx rows, idx cols, double a, double b)
 Generates a random complex matrix with entries (both real and imaginary) uniformly distributed in the interval [a, b), specialization for complex matrices (qpp::cmat) More...
 
template<typename Derived >
Derived randn (idx rows, idx cols, double mean=0, double sigma=1)
 Generates a random matrix with entries normally distributed in N(mean, sigma) More...
 
template<>
dmat randn (idx rows, idx cols, double mean, double sigma)
 Generates a random real matrix with entries normally distributed in N(mean, sigma), specialization for double matrices (qpp::dmat) More...
 
template<>
cmat randn (idx rows, idx cols, double mean, double sigma)
 Generates a random complex matrix with entries (both real and imaginary) normally distributed in N(mean, sigma), specialization for complex matrices (qpp::cmat) More...
 
double randn (double mean=0, double sigma=1)
 Generates a random real number (double) normally distributed in N(mean, sigma) More...
 
cmat randU (idx D=2)
 Generates a random unitary matrix. More...
 
cmat randV (idx Din, idx Dout)
 Generates a random isometry matrix. More...
 
std::vector< cmatrandkraus (idx N, idx D=2)
 Generates a set of random Kraus operators. More...
 
cmat randH (idx D=2)
 Generates a random Hermitian matrix. More...
 
ket randket (idx D=2)
 Generates a random normalized ket (pure state vector) More...
 
cmat randrho (idx D=2)
 Generates a random density matrix. More...
 
std::vector< idxrandperm (idx N)
 Generates a random uniformly distributed permutation. More...
 
std::vector< double > randprob (idx N)
 Generates a random probability vector uniformly distributed over the probability simplex. More...
 
std::vector< double > uniform (idx N)
 Uniform probability distribution vector. More...
 
std::vector< double > marginalX (const dmat &probXY)
 Marginal distribution. More...
 
std::vector< double > marginalY (const dmat &probXY)
 Marginal distribution. More...
 
template<typename Container >
double avg (const std::vector< double > &prob, const Container &X, typename std::enable_if< is_iterable< Container >::value >::type *=nullptr)
 Average. More...
 
template<typename Container >
double cov (const dmat &probXY, const Container &X, const Container &Y, typename std::enable_if< is_iterable< Container >::value >::type *=nullptr)
 Covariance. More...
 
template<typename Container >
double var (const std::vector< double > &prob, const Container &X, typename std::enable_if< is_iterable< Container >::value >::type *=nullptr)
 Variance. More...
 
template<typename Container >
double sigma (const std::vector< double > &prob, const Container &X, typename std::enable_if< is_iterable< Container >::value >::type *=nullptr)
 Standard deviation. More...
 
template<typename Container >
double cor (const dmat &probXY, const Container &X, const Container &Y, typename std::enable_if< is_iterable< Container >::value >::type *=nullptr)
 Correlation. More...
 

Variables

constexpr double chop = 1e-10
 Used in qpp::disp() for setting to zero numbers that have their absolute value smaller than qpp::chop. More...
 
constexpr double eps = 1e-12
 Used to decide whether a number or expression in double precision is zero or not. More...
 
constexpr idx maxn = 64
 Maximum number of allowed qubits/qudits (subsystems) More...
 
constexpr double pi = 3.141592653589793238462643383279502884
 $ \pi $ More...
 
constexpr double ee = 2.718281828459045235360287471352662497
 Base of natural logarithm, $e$. More...
 
constexpr double infty = std::numeric_limits<double>::max()
 Used to denote infinity in double precision. More...
 

Detailed Description

Quantum++ main namespace.

Typedef Documentation

◆ bigint

using qpp::bigint = typedef long long int

Big integer.

◆ bra

using qpp::bra = typedef Eigen::RowVectorXcd

Complex (double precision) dynamic Eigen row vector.

◆ cmat

using qpp::cmat = typedef Eigen::MatrixXcd

Complex (double precision) dynamic Eigen matrix.

◆ cplx

using qpp::cplx = typedef std::complex<double>

Complex number in double precision.

◆ dmat

using qpp::dmat = typedef Eigen::MatrixXd

Real (double precision) dynamic Eigen matrix.

◆ dyn_col_vect

template<typename Scalar >
using qpp::dyn_col_vect = typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1>

Dynamic Eigen column vector over the field specified by Scalar.

Example:

// type of colvect is Eigen::Matrix<float, Eigen::Dynamic, 1>
dyn_col_vect<float> colvect(2);

◆ dyn_mat

template<typename Scalar >
using qpp::dyn_mat = typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic>

Dynamic Eigen matrix over the field specified by Scalar.

Example:

// type of mat is Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic>
dyn_mat<float> mat(2, 3);

◆ dyn_row_vect

template<typename Scalar >
using qpp::dyn_row_vect = typedef Eigen::Matrix<Scalar, 1, Eigen::Dynamic>

Dynamic Eigen row vector over the field specified by Scalar.

Example:

// type of rowvect is Eigen::Matrix<float, 1, Eigen::Dynamic>
dyn_row_vect<float> rowvect(3);

◆ idx

using qpp::idx = typedef std::size_t

Non-negative integer index.

◆ ket

using qpp::ket = typedef Eigen::VectorXcd

Complex (double precision) dynamic Eigen column vector.

◆ to_void

template<typename... Ts>
using qpp::to_void = typedef typename make_void<Ts...>::type

Alias template that implements the proposal for void_t.

See also
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3911

Function Documentation

◆ apply() [1/5]

template<typename Derived1 , typename Derived2 >
dyn_mat<typename Derived1::Scalar> qpp::apply ( const Eigen::MatrixBase< Derived1 > &  state,
const Eigen::MatrixBase< Derived2 > &  A,
const std::vector< idx > &  subsys,
const std::vector< idx > &  dims 
)

Applies the gate A to the part subsys of the multi-partite state vector or density matrix state.

Note
The dimension of the gate A must match the dimension of subsys
Parameters
stateEigen expression
AEigen expression
subsysSubsystem indexes where the gate A is applied
dimsDimensions of the multi-partite system
Returns
Gate A applied to the part subsys of state

◆ apply() [2/5]

template<typename Derived1 , typename Derived2 >
dyn_mat<typename Derived1::Scalar> qpp::apply ( const Eigen::MatrixBase< Derived1 > &  state,
const Eigen::MatrixBase< Derived2 > &  A,
const std::vector< idx > &  subsys,
idx  d = 2 
)

Applies the gate A to the part subsys of the multi-partite state vector or density matrix state.

Note
The dimension of the gate A must match the dimension of subsys
Parameters
stateEigen expression
AEigen expression
subsysSubsystem indexes where the gate A is applied
dSubsystem dimensions
Returns
Gate A applied to the part subsys of state

◆ apply() [3/5]

template<typename Derived >
cmat qpp::apply ( const Eigen::MatrixBase< Derived > &  A,
const std::vector< cmat > &  Ks 
)

Applies the channel specified by the set of Kraus operators Ks to the density matrix A.

Parameters
AEigen expression
KsSet of Kraus operators
Returns
Output density matrix after the action of the channel

◆ apply() [4/5]

template<typename Derived >
cmat qpp::apply ( const Eigen::MatrixBase< Derived > &  A,
const std::vector< cmat > &  Ks,
const std::vector< idx > &  subsys,
const std::vector< idx > &  dims 
)

Applies the channel specified by the set of Kraus operators Ks to the part subsys of the multi-partite density matrix A.

Parameters
AEigen expression
KsSet of Kraus operators
subsysSubsystem indexes where the Kraus operators Ks are applied
dimsDimensions of the multi-partite system
Returns
Output density matrix after the action of the channel

◆ apply() [5/5]

template<typename Derived >
cmat qpp::apply ( const Eigen::MatrixBase< Derived > &  A,
const std::vector< cmat > &  Ks,
const std::vector< idx > &  subsys,
idx  d = 2 
)

Applies the channel specified by the set of Kraus operators Ks to the part subsys of the multi-partite density matrix A.

Parameters
AEigen expression
KsSet of Kraus operators
subsysSubsystem indexes where the Kraus operators Ks are applied
dSubsystem dimensions
Returns
Output density matrix after the action of the channel

◆ applyCTRL() [1/2]

template<typename Derived1 , typename Derived2 >
dyn_mat<typename Derived1::Scalar> qpp::applyCTRL ( const Eigen::MatrixBase< Derived1 > &  state,
const Eigen::MatrixBase< Derived2 > &  A,
const std::vector< idx > &  ctrl,
const std::vector< idx > &  subsys,
const std::vector< idx > &  dims 
)

Applies the controlled-gate A to the part subsys of the multi-partite state vector or density matrix state.

See also
qpp::Gates::CTRL()
Note
The dimension of the gate A must match the dimension of subsys. Also, all control subsystems in ctrl must have the same dimension.
Parameters
stateEigen expression
AEigen expression
ctrlControl subsystem indexes
subsysSubsystem indexes where the gate A is applied
dimsDimensions of the multi-partite system
Returns
CTRL-A gate applied to the part subsys of state

◆ applyCTRL() [2/2]

template<typename Derived1 , typename Derived2 >
dyn_mat<typename Derived1::Scalar> qpp::applyCTRL ( const Eigen::MatrixBase< Derived1 > &  state,
const Eigen::MatrixBase< Derived2 > &  A,
const std::vector< idx > &  ctrl,
const std::vector< idx > &  subsys,
idx  d = 2 
)

Applies the controlled-gate A to the part subsys of the multi-partite state vector or density matrix state.

See also
qpp::Gates::CTRL()
Note
The dimension of the gate A must match the dimension of subsys
Parameters
stateEigen expression
AEigen expression
ctrlControl subsystem indexes
subsysSubsystem indexes where the gate A is applied
dSubsystem dimensions
Returns
CTRL-A gate applied to the part subsys of state

◆ avg()

template<typename Container >
double qpp::avg ( const std::vector< double > &  prob,
const Container &  X,
typename std::enable_if< is_iterable< Container >::value >::type *  = nullptr 
)

Average.

Parameters
probReal probability vector representing the probability distribution of X
XReal random variable values represented by an STL-like container
Returns
Average of X

◆ choi2kraus()

std::vector<cmat> qpp::choi2kraus ( const cmat A)
inline

Orthogonal Kraus operators from Choi matrix.

See also
qpp::kraus2choi()

Extracts a set of orthogonal (under Hilbert-Schmidt operator norm) Kraus operators from the Choi matrix A

Note
The Kraus operators satisfy $Tr(K_i^\dagger K_j)=\delta_{ij}$ for all $i\neq j$
Parameters
AChoi matrix
Returns
Set of orthogonal Kraus operators

◆ choi2super()

cmat qpp::choi2super ( const cmat A)
inline

Converts Choi matrix to superoperator matrix.

See also
qpp::super2choi()
Parameters
AChoi matrix
Returns
Superoperator matrix

◆ compperm()

std::vector<idx> qpp::compperm ( const std::vector< idx > &  perm,
const std::vector< idx > &  sigma 
)
inline

Compose permutations.

Parameters
permPermutation
sigmaPermutation
Returns
Composition of the permutations perm $\circ$ sigma = perm(sigma)

◆ concurrence()

template<typename Derived >
double qpp::concurrence ( const Eigen::MatrixBase< Derived > &  A)

Wootters concurrence of the bi-partite qubit mixed state A.

Parameters
AEigen expression
Returns
Wootters concurrence

◆ contfrac2x()

double qpp::contfrac2x ( const std::vector< int > &  cf,
idx  N = idx(-1) 
)
inline

Real representation of a simple continued fraction.

See also
qpp::x2contfrac()
Note
If N is greater than the size of cf (by default it is), then all terms in cf are considered.
Parameters
cfInteger vector containing the simple continued fraction expansion
NNumber of terms considered in the continued fraction expansion.
Returns
Real representation of the simple continued fraction

◆ cor()

template<typename Container >
double qpp::cor ( const dmat probXY,
const Container &  X,
const Container &  Y,
typename std::enable_if< is_iterable< Container >::value >::type *  = nullptr 
)

Correlation.

Parameters
probXYReal matrix representing the joint probability distribution of X and Y in lexicographical order (X labels the rows, Y labels the columns)
XReal random variable values represented by an STL-like container
YReal random variable values represented by an STL-like container
Returns
Correlation of X and Y

◆ cov()

template<typename Container >
double qpp::cov ( const dmat probXY,
const Container &  X,
const Container &  Y,
typename std::enable_if< is_iterable< Container >::value >::type *  = nullptr 
)

Covariance.

Parameters
probXYReal matrix representing the joint probability distribution of X and Y in lexicographical order (X labels the rows, Y labels the columns)
XReal random variable values represented by an STL-like container
YReal random variable values represented by an STL-like container
Returns
Covariance of X and Y

◆ disp() [1/5]

template<typename Derived >
internal::IOManipEigen qpp::disp ( const Eigen::MatrixBase< Derived > &  A,
double  chop = qpp::chop 
)

Eigen expression ostream manipulator.

Parameters
AEigen expression
chopSet to zero the elements smaller in absolute value than chop
Returns
Instance of qpp::internal::IOManipEigen

◆ disp() [2/5]

internal::IOManipEigen qpp::disp ( cplx  z,
double  chop = qpp::chop 
)
inline

Complex number ostream manipulator.

Parameters
zComplex number (or any other type implicitly cast-able to std::complex<double>)
chopSet to zero the elements smaller in absolute value than chop
Returns
Instance of qpp::internal::IOManipEigen

◆ disp() [3/5]

template<typename InputIterator >
internal::IOManipRange<InputIterator> qpp::disp ( InputIterator  first,
InputIterator  last,
const std::string &  separator,
const std::string &  start = "[",
const std::string &  end = "]" 
)

Range ostream manipulator.

Parameters
firstIterator to the first element of the range
lastIterator to the last element of the range
separatorSeparator
startLeft marking
endRight marking
Returns
Instance of qpp::internal::IOManipRange

◆ disp() [4/5]

template<typename Container >
internal::IOManipRange<typename Container::const_iterator> qpp::disp ( const Container &  c,
const std::string &  separator,
const std::string &  start = "[",
const std::string &  end = "]",
typename std::enable_if< is_iterable< Container >::value >::type *  = nullptr 
)

Standard container ostream manipulator. The container must support std::begin(), std::end() and forward iteration.

Parameters
cContainer
separatorSeparator
startLeft marking
endRight marking
Returns
Instance of qpp::internal::IOManipRange

◆ disp() [5/5]

template<typename PointerType >
internal::IOManipPointer<PointerType> qpp::disp ( const PointerType *  p,
idx  N,
const std::string &  separator,
const std::string &  start = "[",
const std::string &  end = "]" 
)

C-style pointer ostream manipulator.

Parameters
pPointer to the first element
NNumber of elements to be displayed
separatorSeparator
startLeft marking
endRight marking
Returns
Instance of qpp::internal::IOManipPointer

◆ egcd()

std::tuple<bigint, bigint, bigint> qpp::egcd ( bigint  a,
bigint  b 
)
inline

Extended greatest common divisor of two integers.

See also
qpp::gcd()
Parameters
aInteger
bInteger
Returns
Tuple of: 1. Integer $m$, 2. Integer $n$, and 3. Non-negative integer $gcd(a, b)$ such that $ma + nb = gcd(a, b)$

◆ entanglement() [1/2]

template<typename Derived >
double qpp::entanglement ( const Eigen::MatrixBase< Derived > &  A,
const std::vector< idx > &  dims 
)

Entanglement of the bi-partite pure state A.

Defined as the von-Neumann entropy of the reduced density matrix of one of the subsystems

See also
qpp::entropy()
Parameters
AEigen expression
dimsDimensions of the bi-partite system
Returns
Entanglement, with the logarithm in base 2

◆ entanglement() [2/2]

template<typename Derived >
double qpp::entanglement ( const Eigen::MatrixBase< Derived > &  A,
idx  d = 2 
)

Entanglement of the bi-partite pure state A.

Defined as the von-Neumann entropy of the reduced density matrix of one of the subsystems

See also
qpp::entropy()
Parameters
AEigen expression
dSubsystem dimensions
Returns
Entanglement, with the logarithm in base 2

◆ entropy() [1/2]

template<typename Derived >
double qpp::entropy ( const Eigen::MatrixBase< Derived > &  A)

von-Neumann entropy of the density matrix A

Parameters
AEigen expression
Returns
von-Neumann entropy, with the logarithm in base 2

◆ entropy() [2/2]

double qpp::entropy ( const std::vector< double > &  prob)
inline

Shannon entropy of the probability distribution prob.

Parameters
probReal probability vector
Returns
Shannon entropy, with the logarithm in base 2

◆ factors()

std::vector<bigint> qpp::factors ( bigint  a)
inline

Prime factor decomposition.

Note
Runs in $\mathcal{O}(\sqrt{n})$ time complexity
Parameters
aInteger different from 0, 1 or -1
Returns
Integer vector containing the factors

◆ gcd() [1/2]

bigint qpp::gcd ( bigint  a,
bigint  b 
)
inline

Greatest common divisor of two integers.

See also
qpp::lcm()
Parameters
aInteger
bInteger
Returns
Greatest common divisor of a and b

◆ gcd() [2/2]

bigint qpp::gcd ( const std::vector< bigint > &  as)
inline

Greatest common divisor of a list of integers.

See also
qpp::lcm()
Parameters
asList of integers
Returns
Greatest common divisor of all numbers in as

◆ gconcurrence()

template<typename Derived >
double qpp::gconcurrence ( const Eigen::MatrixBase< Derived > &  A)

G-concurrence of the bi-partite pure state A.

Note
Both local dimensions must be equal

Uses qpp::logdet() to avoid overflows

See also
qpp::logdet()
Parameters
AEigen expression
Returns
G-concurrence

◆ invperm()

std::vector<idx> qpp::invperm ( const std::vector< idx > &  perm)
inline

Inverse permutation.

Parameters
permPermutation
Returns
Inverse of the permutation perm

◆ ip() [1/2]

template<typename Derived >
dyn_col_vect<typename Derived::Scalar> qpp::ip ( const Eigen::MatrixBase< Derived > &  phi,
const Eigen::MatrixBase< Derived > &  psi,
const std::vector< idx > &  subsys,
const std::vector< idx > &  dims 
)

Generalized inner product.

Parameters
phiColumn vector Eigen expression
psiColumn vector Eigen expression
subsysSubsystem indexes over which phi is defined
dimsDimensions of the multi-partite system
Returns
Inner product $\langle \phi_{subsys}|\psi\rangle$, as a scalar or column vector over the remaining Hilbert space

◆ ip() [2/2]

template<typename Derived >
dyn_col_vect<typename Derived::Scalar> qpp::ip ( const Eigen::MatrixBase< Derived > &  phi,
const Eigen::MatrixBase< Derived > &  psi,
const std::vector< idx > &  subsys,
idx  d = 2 
)

Generalized inner product.

Parameters
phiColumn vector Eigen expression
psiColumn vector Eigen expression
subsysSubsystem indexes over which phi is defined
dSubsystem dimensions
Returns
Inner product $\langle \phi_{subsys}|\psi\rangle$, as a scalar or column vector over the remaining Hilbert space

◆ isprime()

bool qpp::isprime ( bigint  p,
idx  k = 80 
)
inline

Primality test based on the Miller-Rabin's algorithm.

Parameters
pInteger different from 0, 1 or -1
kNumber of iterations. The probability of a false positive is $2^{-k}$.
Returns
True if the number is (most-likely) prime, false otherwise

◆ kraus2choi()

cmat qpp::kraus2choi ( const std::vector< cmat > &  Ks)
inline

Choi matrix.

See also
qpp::choi2kraus()

Constructs the Choi matrix of the channel specified by the set of Kraus operators Ks in the standard operator basis $\{|i\rangle\langle j|\}$ ordered in lexicographical order, i.e. $|0\rangle\langle 0|$, $|0\rangle\langle 1|$ etc.

Note
The superoperator matrix $S$ and the Choi matrix $ C$ are related by $ S_{ab,mn} = C_{ma,nb}$
Parameters
KsSet of Kraus operators
Returns
Choi matrix

◆ kraus2super()

cmat qpp::kraus2super ( const std::vector< cmat > &  Ks)
inline

Superoperator matrix.

Constructs the superoperator matrix of the channel specified by the set of Kraus operators Ks in the standard operator basis $\{|i\rangle\langle j|\}$ ordered in lexicographical order, i.e. $|0\rangle\langle 0|$, $|0\rangle\langle 1|$ etc.

Parameters
KsSet of Kraus operators
Returns
Superoperator matrix

◆ lcm() [1/2]

bigint qpp::lcm ( bigint  a,
bigint  b 
)
inline

Least common multiple of two integers.

See also
qpp::gcd()
Parameters
aInteger
bInteger
Returns
Least common multiple of a and b

◆ lcm() [2/2]

bigint qpp::lcm ( const std::vector< bigint > &  as)
inline

Least common multiple of a list of integers.

See also
qpp::gcd()
Parameters
asList of integers
Returns
Least common multiple of all numbers in as

◆ load()

template<typename Derived >
dyn_mat<typename Derived::Scalar> qpp::load ( const std::string &  fname)

Loads Eigen matrix from a binary file (internal format) in double precision.

See also
qpp::save()

The template parameter cannot be automatically deduced and must be explicitly provided, depending on the scalar field of the matrix that is being loaded.

Example:

// loads a previously saved Eigen dynamic complex matrix from "input.bin"
cmat mat = load<cmat>("input.bin");
Parameters
fnameOutput file name

◆ loadMATLAB() [1/2]

template<typename Derived >
std::enable_if<std::is_same<typename Derived::Scalar, cplx>::value, dyn_mat<cplx> >::type qpp::loadMATLAB ( const std::string &  mat_file,
const std::string &  var_name 
)

Loads a complex Eigen dynamic matrix from a MATLAB .mat file,.

See also
qpp::saveMATLAB()

The template parameter cannot be automatically deduced and must be explicitly provided

Example:

// loads a previously saved Eigen ket
// from the MATLAB file "input.mat"
ket psi = loadMATLAB<ket>("input.mat");
Template Parameters
DerivedComplex Eigen type
Parameters
mat_fileMATALB .mat file
var_nameVariable name in the .mat file representing the matrix to be loaded
Returns
Eigen dynamic matrix

◆ loadMATLAB() [2/2]

template<typename Derived >
std::enable_if<!std::is_same<typename Derived::Scalar, cplx>::value, dyn_mat<typename Derived::Scalar> >::type qpp::loadMATLAB ( const std::string &  mat_file,
const std::string &  var_name 
)

Loads a non-complex Eigen dynamic matrix from a MATLAB .mat file,.

See also
qpp::saveMATLAB()

The template parameter cannot be automatically deduced and must be explicitly provided

Example:

// loads a previously saved Eigen dynamic double matrix
// from the MATLAB file "input.mat"
dmat mat = loadMATLAB<dmat>("input.mat");
Template Parameters
DerivedNon-complex Eigen type
Parameters
mat_fileMATALB .mat file
var_nameVariable name in the .mat file representing the matrix to be loaded
Returns
Eigen dynamic matrix

◆ lognegativity() [1/2]

template<typename Derived >
double qpp::lognegativity ( const Eigen::MatrixBase< Derived > &  A,
const std::vector< idx > &  dims 
)

Logarithmic negativity of the bi-partite mixed state A.

Parameters
AEigen expression
dimsDimensions of the bi-partite system
Returns
Logarithmic negativity, with the logarithm in base 2

◆ lognegativity() [2/2]

template<typename Derived >
double qpp::lognegativity ( const Eigen::MatrixBase< Derived > &  A,
idx  d = 2 
)

Logarithmic negativity of the bi-partite mixed state A.

Parameters
AEigen expression
dSubsystem dimensions
Returns
Logarithmic negativity, with the logarithm in base 2

◆ marginalX()

std::vector<double> qpp::marginalX ( const dmat probXY)
inline

Marginal distribution.

Parameters
probXYReal matrix representing the joint probability distribution of X and Y in lexicographical order (X labels the rows, Y labels the columns)
Returns
Real vector consisting of the marginal distribution of X

◆ marginalY()

std::vector<double> qpp::marginalY ( const dmat probXY)
inline

Marginal distribution.

Parameters
probXYReal matrix representing the joint probability distribution of X and Y in lexicographical order (X labels the rows, Y labels the columns)
Returns
Real vector consisting of the marginal distribution of Y

◆ measure() [1/9]

template<typename Derived >
std::tuple<idx, std::vector<double>, std::vector<cmat> > qpp::measure ( const Eigen::MatrixBase< Derived > &  A,
const std::vector< cmat > &  Ks 
)

Measures the state A using the set of Kraus operators Ks.

Parameters
AEigen expression
KsSet of Kraus operators
Returns
Tuple of: 1. Result of the measurement, 2. Vector of outcome probabilities, and 3. Vector of post-measurement normalized states

◆ measure() [2/9]

template<typename Derived >
std::tuple<idx, std::vector<double>, std::vector<cmat> > qpp::measure ( const Eigen::MatrixBase< Derived > &  A,
const std::initializer_list< cmat > &  Ks 
)

Measures the state A using the set of Kraus operators Ks.

Parameters
AEigen expression
KsSet of Kraus operators
Returns
Tuple of: 1. Result of the measurement, 2. Vector of outcome probabilities, and 3. Vector of post-measurement normalized states

◆ measure() [3/9]

template<typename Derived >
std::tuple<idx, std::vector<double>, std::vector<cmat> > qpp::measure ( const Eigen::MatrixBase< Derived > &  A,
const cmat U 
)

Measures the state A in the orthonormal basis specified by the unitary matrix U.

Parameters
AEigen expression
UUnitary matrix whose columns represent the measurement basis vectors
Returns
Tuple of: 1. Result of the measurement, 2. Vector of outcome probabilities, and 3. Vector of post-measurement normalized states

◆ measure() [4/9]

template<typename Derived >
std::tuple<idx, std::vector<double>, std::vector<cmat> > qpp::measure ( const Eigen::MatrixBase< Derived > &  A,
const std::vector< cmat > &  Ks,
const std::vector< idx > &  subsys,
const std::vector< idx > &  dims 
)

Measures the part subsys of the multi-partite state vector or density matrix A using the set of Kraus operators Ks.

See also
qpp::measure_seq()
Note
The dimension of all Ks must match the dimension of subsys. The measurement is destructive, i.e. the measured subsystems are traced away.
Parameters
AEigen expression
KsSet of Kraus operators
subsysSubsystem indexes that are measured
dimsDimensions of the multi-partite system
Returns
Tuple of: 1. Result of the measurement, 2. Vector of outcome probabilities, and 3. Vector of post-measurement normalized states

◆ measure() [5/9]

template<typename Derived >
std::tuple<idx, std::vector<double>, std::vector<cmat> > qpp::measure ( const Eigen::MatrixBase< Derived > &  A,
const std::initializer_list< cmat > &  Ks,
const std::vector< idx > &  subsys,
const std::vector< idx > &  dims 
)

Measures the part subsys of the multi-partite state vector or density matrix A using the set of Kraus operators Ks.

See also
qpp::measure_seq()
Note
The dimension of all Ks must match the dimension of subsys. The measurement is destructive, i.e. the measured subsystems are traced away.
Parameters
AEigen expression
KsSet of Kraus operators
subsysSubsystem indexes that are measured
dimsDimensions of the multi-partite system
Returns
Tuple of: 1. Result of the measurement, 2. Vector of outcome probabilities, and 3. Vector of post-measurement normalized states

◆ measure() [6/9]

template<typename Derived >
std::tuple<idx, std::vector<double>, std::vector<cmat> > qpp::measure ( const Eigen::MatrixBase< Derived > &  A,
const std::vector< cmat > &  Ks,
const std::vector< idx > &  subsys,
idx  d = 2 
)

Measures the part subsys of the multi-partite state vector or density matrix A using the set of Kraus operators Ks.

See also
qpp::measure_seq()
Note
The dimension of all Ks must match the dimension of subsys. The measurement is destructive, i.e. the measured subsystems are traced away.
Parameters
AEigen expression
KsSet of Kraus operators
subsysSubsystem indexes that are measured
dSubsystem dimensions
Returns
Tuple of: 1. Result of the measurement, 2. Vector of outcome probabilities, and 3. Vector of post-measurement normalized states

◆ measure() [7/9]

template<typename Derived >
std::tuple<idx, std::vector<double>, std::vector<cmat> > qpp::measure ( const Eigen::MatrixBase< Derived > &  A,
const std::initializer_list< cmat > &  Ks,
const std::vector< idx > &  subsys,
idx  d = 2 
)

Measures the part subsys of the multi-partite state vector or density matrix A using the set of Kraus operators Ks.

See also
qpp::measure_seq()
Note
The dimension of all Ks must match the dimension of subsys. The measurement is destructive, i.e. the measured subsystems are traced away.
Parameters
AEigen expression
KsSet of Kraus operators
subsysSubsystem indexes that are measured
dSubsystem dimensions
Returns
Tuple of: 1. Result of the measurement, 2. Vector of outcome probabilities, and 3. Vector of post-measurement normalized states

◆ measure() [8/9]

template<typename Derived >
std::tuple<idx, std::vector<double>, std::vector<cmat> > qpp::measure ( const Eigen::MatrixBase< Derived > &  A,
const cmat V,
const std::vector< idx > &  subsys,
const std::vector< idx > &  dims 
)

Measures the part subsys of the multi-partite state vector or density matrix A in the orthonormal basis or rank-1 POVM specified by the matrix V.

See also
qpp::measure_seq()
Note
The dimension of V must match the dimension of subsys. The measurement is destructive, i.e. the measured subsystems are traced away.
Parameters
AEigen expression
VMatrix whose columns represent the measurement basis vectors or the bra parts of the rank-1 POVM
subsysSubsystem indexes that are measured
dimsDimensions of the multi-partite system
Returns
Tuple of: 1. Result of the measurement, 2. Vector of outcome probabilities, and 3. Vector of post-measurement normalized states

◆ measure() [9/9]

template<typename Derived >
std::tuple<idx, std::vector<double>, std::vector<cmat> > qpp::measure ( const Eigen::MatrixBase< Derived > &  A,
const cmat V,
const std::vector< idx > &  subsys,
idx  d = 2 
)

Measures the part subsys of the multi-partite state vector or density matrix A in the orthonormal basis or rank-1 POVM specified by the matrix V.

See also
qpp::measure_seq()
Note
The dimension of V must match the dimension of subsys. The measurement is destructive, i.e. the measured subsystems are traced away.
Parameters
AEigen expression
VMatrix whose columns represent the measurement basis vectors or the bra parts of the rank-1 POVM
subsysSubsystem indexes that are measured
dSubsystem dimensions
Returns
Tuple of: 1. Result of the measurement, 2. Vector of outcome probabilities, and 3. Vector of post-measurement normalized states

◆ measure_seq() [1/2]

template<typename Derived >
std::tuple<std::vector<idx>, double, cmat> qpp::measure_seq ( const Eigen::MatrixBase< Derived > &  A,
std::vector< idx subsys,
std::vector< idx dims 
)

Sequentially measures the part subsys of the multi-partite state vector or density matrix A in the computational basis.

See also
qpp::measure()
Parameters
AEigen expression
subsysSubsystem indexes that are measured
dimsDimensions of the multi-partite system
Returns
Tuple of: 1. Vector of outcome results of the measurement (ordered in increasing order with respect to subsys, i.e. first measurement result corresponds to the subsystem with the smallest index), 2. Outcome probability, and 3. Post-measurement normalized state

◆ measure_seq() [2/2]

template<typename Derived >
std::tuple<std::vector<idx>, double, cmat> qpp::measure_seq ( const Eigen::MatrixBase< Derived > &  A,
std::vector< idx subsys,
idx  d = 2 
)

Sequentially measures the part subsys of the multi-partite state vector or density matrix A in the computational basis.

See also
qpp::measure()
Parameters
AEigen expression
subsysSubsystem indexes that are measured
dSubsystem dimensions
Returns
Tuple of: 1. Vector of outcome results of the measurement (ordered in increasing order with respect to subsys, i.e. first measurement result corresponds to the subsystem with the smallest index), 2. Outcome probability, and 3. Post-measurement normalized state

◆ modinv()

bigint qpp::modinv ( bigint  a,
bigint  p 
)
inline

Modular inverse of a mod p.

See also
qpp::egcd()
Note
a and p must be co-prime
Parameters
aNon-negative integer
pNon-negative integer
Returns
Modular inverse $a^{-1}$ $\textrm{ mod }$ $p$

◆ modmul()

bigint qpp::modmul ( bigint  a,
bigint  b,
bigint  p 
)
inline

Modular multiplication without overflow.

Computes $ab$ $\mathrm{ mod }$ $p$ without overflow

Parameters
aInteger
bInteger
pPositive integer
Returns
$ab$ $\mathrm{ mod }$ $p$ avoiding overflow

◆ modpow()

bigint qpp::modpow ( bigint  a,
bigint  n,
bigint  p 
)
inline

Fast integer power modulo p based on the SQUARE-AND-MULTIPLY algorithm.

Note
Uses qpp::modmul() that avoids overflows

Computes $a^n$ $\mathrm{ mod }$ $p$

Parameters
aNon-negative integer
nNon-negative integer
pStrictly positive integer
Returns
$a^n$ $\mathrm{ mod }$ $p$

◆ negativity() [1/2]

template<typename Derived >
double qpp::negativity ( const Eigen::MatrixBase< Derived > &  A,
const std::vector< idx > &  dims 
)

Negativity of the bi-partite mixed state A.

Parameters
AEigen expression
dimsDimensions of the bi-partite system
Returns
Negativity

◆ negativity() [2/2]

template<typename Derived >
double qpp::negativity ( const Eigen::MatrixBase< Derived > &  A,
idx  d = 2 
)

Negativity of the bi-partite mixed state A.

Parameters
AEigen expression
dSubsystem dimensions
Returns
Negativity

◆ omega()

cplx qpp::omega ( idx  D)
inline

D-th root of unity.

Parameters
DNon-negative integer
Returns
D-th root of unity $\exp(2\pi i/D)$

◆ operator"" _i() [1/2]

constexpr cplx qpp::operator"" _i ( unsigned long long int  x)
inlinenoexcept

User-defined literal for complex $i=\sqrt{-1}$ (integer overload)

Example:

cplx z = 4_i; // type of z is std::complex<double>

◆ operator"" _i() [2/2]

constexpr cplx qpp::operator"" _i ( long double  x)
inlinenoexcept

User-defined literal for complex $i=\sqrt{-1}$ (real overload)

Example:

cplx z = 4.5_i; // type of z is std::complex<double>

◆ ptrace() [1/2]

template<typename Derived >
dyn_mat<typename Derived::Scalar> qpp::ptrace ( const Eigen::MatrixBase< Derived > &  A,
const std::vector< idx > &  subsys,
const std::vector< idx > &  dims 
)

Partial trace.

See also
qpp::ptrace1(), qpp::ptrace2()

Partial trace of the multi-partite state vector or density matrix over a list of subsystems

Parameters
AEigen expression
subsysSubsystem indexes
dimsDimensions of the multi-partite system
Returns
Partial trace $Tr_{subsys}(\cdot)$ over the subsytems subsys in a multi-partite system, as a dynamic matrix over the same scalar field as A

◆ ptrace() [2/2]

template<typename Derived >
dyn_mat<typename Derived::Scalar> qpp::ptrace ( const Eigen::MatrixBase< Derived > &  A,
const std::vector< idx > &  subsys,
idx  d = 2 
)

Partial trace.

See also
qpp::ptrace1(), qpp::ptrace2()

Partial trace of the multi-partite state vector or density matrix over a list of subsystems

Parameters
AEigen expression
subsysSubsystem indexes
dSubsystem dimensions
Returns
Partial trace $Tr_{subsys}(\cdot)$ over the subsytems subsys in a multi-partite system, as a dynamic matrix over the same scalar field as A

◆ ptrace1() [1/2]

template<typename Derived >
dyn_mat<typename Derived::Scalar> qpp::ptrace1 ( const Eigen::MatrixBase< Derived > &  A,
const std::vector< idx > &  dims 
)

Partial trace.

See also
qpp::ptrace2()

Partial trace over the first subsystem of bi-partite state vector or density matrix

Parameters
AEigen expression
dimsDimensions of the bi-partite system
Returns
Partial trace $Tr_{A}(\cdot)$ over the first subsytem $A$ in a bi-partite system $A\otimes B$, as a dynamic matrix over the same scalar field as A

◆ ptrace1() [2/2]

template<typename Derived >
dyn_mat<typename Derived::Scalar> qpp::ptrace1 ( const Eigen::MatrixBase< Derived > &  A,
idx  d = 2 
)

Partial trace.

See also
qpp::ptrace2()

Partial trace over the first subsystem of bi-partite state vector or density matrix

Parameters
AEigen expression
dSubsystem dimensions
Returns
Partial trace $Tr_{A}(\cdot)$ over the first subsytem $A$ in a bi-partite system $A\otimes B$, as a dynamic matrix over the same scalar field as A

◆ ptrace2() [1/2]

template<typename Derived >
dyn_mat<typename Derived::Scalar> qpp::ptrace2 ( const Eigen::MatrixBase< Derived > &  A,
const std::vector< idx > &  dims 
)

Partial trace.

See also
qpp::ptrace1()

Partial trace over the second subsystem of bi-partite state vector or density matrix

Parameters
AEigen expression
dimsDimensions of the bi-partite system
Returns
Partial trace $Tr_{B}(\cdot)$ over the second subsytem $B$ in a bi-partite system $A\otimes B$, as a dynamic matrix over the same scalar field as A

◆ ptrace2() [2/2]

template<typename Derived >
dyn_mat<typename Derived::Scalar> qpp::ptrace2 ( const Eigen::MatrixBase< Derived > &  A,
idx  d = 2 
)

Partial trace.

See also
qpp::ptrace1()

Partial trace over the second subsystem of bi-partite state vector or density matrix

Parameters
AEigen expression
dSubsystem dimensions
Returns
Partial trace $Tr_{B}(\cdot)$ over the second subsytem $B$ in a bi-partite system $A\otimes B$, as a dynamic matrix over the same scalar field as A

◆ ptranspose() [1/2]

template<typename Derived >
dyn_mat<typename Derived::Scalar> qpp::ptranspose ( const Eigen::MatrixBase< Derived > &  A,
const std::vector< idx > &  subsys,
const std::vector< idx > &  dims 
)

Partial transpose.

Partial transpose of the multi-partite state vector or density matrix over a list of subsystems

Parameters
AEigen expression
subsysSubsystem indexes
dimsDimensions of the multi-partite system
Returns
Partial transpose $(\cdot)^{T_{subsys}}$ over the subsytems subsys in a multi-partite system, as a dynamic matrix over the same scalar field as A

◆ ptranspose() [2/2]

template<typename Derived >
dyn_mat<typename Derived::Scalar> qpp::ptranspose ( const Eigen::MatrixBase< Derived > &  A,
const std::vector< idx > &  subsys,
idx  d = 2 
)

Partial transpose.

Partial transpose of the multi-partite state vector or density matrix over a list of subsystems

Parameters
AEigen expression
subsysSubsystem indexes
dSubsystem dimensions
Returns
Partial transpose $(\cdot)^{T_{subsys}}$ over the subsytems subsys in a multi-partite system, as a dynamic matrix over the same scalar field as A

◆ qmutualinfo() [1/2]

template<typename Derived >
double qpp::qmutualinfo ( const Eigen::MatrixBase< Derived > &  A,
const std::vector< idx > &  subsysA,
const std::vector< idx > &  subsysB,
const std::vector< idx > &  dims 
)

Quantum mutual information between 2 subsystems of a composite system.

Parameters
AEigen expression
subsysAIndexes of the first subsystem
subsysBIndexes of the second subsystem
dimsDimensions of the multi-partite system
Returns
Mutual information between the 2 subsystems

◆ qmutualinfo() [2/2]

template<typename Derived >
double qpp::qmutualinfo ( const Eigen::MatrixBase< Derived > &  A,
const std::vector< idx > &  subsysA,
const std::vector< idx > &  subsysB,
idx  d = 2 
)

Quantum mutual information between 2 subsystems of a composite system.

Parameters
AEigen expression
subsysAIndexes of the first subsystem
subsysBIndexes of the second subsystem
dSubsystem dimensions
Returns
Mutual information between the 2 subsystems

◆ rand() [1/5]

double qpp::rand ( double  a,
double  b 
)
inline

Generates a random real number uniformly distributed in the interval [a, b)

Parameters
aBeginning of the interval, belongs to it
bEnd of the interval, does not belong to it
Returns
Random real number (double) uniformly distributed in the interval [a, b)

◆ rand() [2/5]

bigint qpp::rand ( bigint  a,
bigint  b 
)
inline

Generates a random big integer uniformly distributed in the interval [a, b].

Note
To avoid ambiguity with double qpp::rand(double, double) cast at least one of the arguments to qpp::bigint
Parameters
aBeginning of the interval, belongs to it
bEnd of the interval, belongs to it
Returns
Random big integer uniformly distributed in the interval [a, b]

◆ rand() [3/5]

template<typename Derived >
Derived qpp::rand ( idx  rows,
idx  cols,
double  a = 0,
double  b = 1 
)

Generates a random matrix with entries uniformly distributed in the interval [a, b)

If complex, then both real and imaginary parts are uniformly distributed in [a, b)

This is the generic version that always throws qpp::Exception::Type::UNDEFINED_TYPE. It is specialized only for qpp::dmat and qpp::cmat

◆ rand() [4/5]

template<>
dmat qpp::rand ( idx  rows,
idx  cols,
double  a,
double  b 
)
inline

Generates a random real matrix with entries uniformly distributed in the interval [a, b), specialization for double matrices (qpp::dmat)

The template parameter cannot be automatically deduced and must be explicitly provided

Example:

// generates a 3 x 3 random Eigen::MatrixXd,
// with entries uniformly distributed in [-1,1)
dmat mat = rand<dmat>(3, 3, -1, 1);
Parameters
rowsNumber of rows of the random generated matrix
colsNumber of columns of the random generated matrix
aBeginning of the interval, belongs to it
bEnd of the interval, does not belong to it
Returns
Random real matrix

◆ rand() [5/5]

template<>
cmat qpp::rand ( idx  rows,
idx  cols,
double  a,
double  b 
)
inline

Generates a random complex matrix with entries (both real and imaginary) uniformly distributed in the interval [a, b), specialization for complex matrices (qpp::cmat)

The template parameter cannot be automatically deduced and must be explicitly provided

Example:

// generates a 3 x 3 random Eigen::MatrixXcd,
// with entries (both real and imaginary) uniformly distributed in [-1,1)
cmat mat = rand<cmat>(3, 3, -1, 1);
Parameters
rowsNumber of rows of the random generated matrix
colsNumber of columns of the random generated matrix
aBeginning of the interval, belongs to it
bEnd of the interval, does not belong to it
Returns
Random complex matrix

◆ randH()

cmat qpp::randH ( idx  D = 2)
inline

Generates a random Hermitian matrix.

Parameters
DDimension of the Hilbert space
Returns
Random Hermitian matrix

◆ randidx()

idx qpp::randidx ( idx  a = std::numeric_limits<idx>::min(),
idx  b = std::numeric_limits<idx>::max() 
)
inline

Generates a random index (idx) uniformly distributed in the interval [a, b].

Parameters
aBeginning of the interval, belongs to it
bEnd of the interval, belongs to it
Returns
Random index (idx) uniformly distributed in the interval [a, b]

◆ randket()

ket qpp::randket ( idx  D = 2)
inline

Generates a random normalized ket (pure state vector)

Parameters
DDimension of the Hilbert space
Returns
Random normalized ket

◆ randkraus()

std::vector<cmat> qpp::randkraus ( idx  N,
idx  D = 2 
)
inline

Generates a set of random Kraus operators.

Note
The set of Kraus operators satisfy the closure condition $ \sum_i K_i^\dagger K_i = I$
Parameters
NNumber of Kraus operators
DDimension of the Hilbert space
Returns
Set of N Kraus operators satisfying the closure condition

◆ randn() [1/4]

template<typename Derived >
Derived qpp::randn ( idx  rows,
idx  cols,
double  mean = 0,
double  sigma = 1 
)

Generates a random matrix with entries normally distributed in N(mean, sigma)

If complex, then both real and imaginary parts are normally distributed in N(mean, sigma)

This is the generic version that always throws qpp::Exception::Type::UNDEFINED_TYPE. It is specialized only for qpp::dmat and qpp::cmat

◆ randn() [2/4]

template<>
dmat qpp::randn ( idx  rows,
idx  cols,
double  mean,
double  sigma 
)
inline

Generates a random real matrix with entries normally distributed in N(mean, sigma), specialization for double matrices (qpp::dmat)

The template parameter cannot be automatically deduced and must be explicitly provided

Example:

// generates a 3 x 3 random Eigen::MatrixXd,
// with entries normally distributed in N(0,2)
dmat mat = randn<dmat>(3, 3, 0, 2);
Parameters
rowsNumber of rows of the random generated matrix
colsNumber of columns of the random generated matrix
meanMean
sigmaStandard deviation
Returns
Random real matrix

◆ randn() [3/4]

template<>
cmat qpp::randn ( idx  rows,
idx  cols,
double  mean,
double  sigma 
)
inline

Generates a random complex matrix with entries (both real and imaginary) normally distributed in N(mean, sigma), specialization for complex matrices (qpp::cmat)

The template parameter cannot be automatically deduced and must be explicitly provided

Example:

// generates a 3 x 3 random Eigen::MatrixXcd,
// with entries (both real and imaginary) normally distributed in N(0,2)
cmat mat = randn<cmat>(3, 3, 0, 2);
Parameters
rowsNumber of rows of the random generated matrix
colsNumber of columns of the random generated matrix
meanMean
sigmaStandard deviation
Returns
Random complex matrix

◆ randn() [4/4]

double qpp::randn ( double  mean = 0,
double  sigma = 1 
)
inline

Generates a random real number (double) normally distributed in N(mean, sigma)

Parameters
meanMean
sigmaStandard deviation
Returns
Random real number normally distributed in N(mean, sigma)

◆ randperm()

std::vector<idx> qpp::randperm ( idx  N)
inline

Generates a random uniformly distributed permutation.

Uses Knuth shuffle method (as implemented by std::shuffle), so that all permutations are equally probable

Parameters
NSize of the permutation
Returns
Random permutation of size N

◆ randprime()

bigint qpp::randprime ( bigint  a,
bigint  b,
idx  N = 1000 
)
inline

Generates a random big prime uniformly distributed in the interval [a, b].

Parameters
aBeginning of the interval, belongs to it
bEnd of the interval, belongs to it
NMaximum number of candidates
Returns
Random big integer uniformly distributed in the interval [a, b]

◆ randprob()

std::vector<double> qpp::randprob ( idx  N)
inline

Generates a random probability vector uniformly distributed over the probability simplex.

Parameters
NSize of the probability vector
Returns
Random probability vector

◆ randrho()

cmat qpp::randrho ( idx  D = 2)
inline

Generates a random density matrix.

Parameters
DDimension of the Hilbert space
Returns
Random density matrix

◆ randU()

cmat qpp::randU ( idx  D = 2)
inline

Generates a random unitary matrix.

Parameters
DDimension of the Hilbert space
Returns
Random unitary

◆ randV()

cmat qpp::randV ( idx  Din,
idx  Dout 
)
inline

Generates a random isometry matrix.

Parameters
DinSize of the input Hilbert space
DoutSize of the output Hilbert space
Returns
Random isometry matrix

◆ renyi() [1/2]

template<typename Derived >
double qpp::renyi ( const Eigen::MatrixBase< Derived > &  A,
double  alpha 
)

Renyi- $\alpha$ entropy of the density matrix A, for $\alpha\geq 0$.

Note
When $ \alpha\to 1$ the Renyi entropy converges to the von-Neumann entropy, with the logarithm in base 2
Parameters
AEigen expression
alphaNon-negative real number, use qpp::infty for $\alpha = \infty$
Returns
Renyi- $\alpha$ entropy, with the logarithm in base 2

◆ renyi() [2/2]

double qpp::renyi ( const std::vector< double > &  prob,
double  alpha 
)
inline

Renyi- $\alpha$ entropy of the probability distribution prob, for $\alpha\geq 0$.

Note
When $ \alpha\to 1$ the Renyi entropy converges to the Shannon entropy, with the logarithm in base 2
Parameters
probReal probability vector
alphaNon-negative real number, use qpp::infty for $\alpha = \infty$
Returns
Renyi- $\alpha$ entropy, with the logarithm in base 2

◆ save()

template<typename Derived >
void qpp::save ( const Eigen::MatrixBase< Derived > &  A,
const std::string &  fname 
)

Saves Eigen expression to a binary file (internal format) in double precision.

See also
qpp::load()
Parameters
AEigen expression
fnameOutput file name

◆ saveMATLAB() [1/2]

template<typename Derived >
std::enable_if< std::is_same<typename Derived::Scalar, cplx>::value>::type qpp::saveMATLAB ( const Eigen::MatrixBase< Derived > &  A,
const std::string &  mat_file,
const std::string &  var_name,
const std::string &  mode 
)

Saves a complex Eigen dynamic matrix to a MATLAB .mat file,.

See also
qpp::loadMATLAB()
Template Parameters
ComplexEigen type
Parameters
AEigen expression over the complex field
mat_fileMATALB .mat file
var_nameVariable name in the .mat file representing the matrix to be saved
modeSaving mode (append, overwrite etc.), see MATLAB matOpen() documentation for details

◆ saveMATLAB() [2/2]

template<typename Derived >
std::enable_if< !std::is_same<typename Derived::Scalar, cplx>::value>::type qpp::saveMATLAB ( const Eigen::MatrixBase< Derived > &  A,
const std::string &  mat_file,
const std::string &  var_name,
const std::string &  mode 
)

Saves a non-complex Eigen dynamic matrix to a MATLAB .mat file,.

See also
qpp::loadMATLAB()
Template Parameters
Npn-complexEigen type
Parameters
ANon-complex Eigen expression
mat_fileMATALB .mat file
var_nameVariable name in the .mat file representing the matrix to be saved
modeSaving mode (append, overwrite etc.), see MATLAB matOpen() documentation for details

◆ schmidtA() [1/2]

template<typename Derived >
cmat qpp::schmidtA ( const Eigen::MatrixBase< Derived > &  A,
const std::vector< idx > &  dims 
)

Schmidt basis on Alice side.

Parameters
AEigen expression
dimsDimensions of the bi-partite system
Returns
Unitary matrix $ U $ whose columns represent the Schmidt basis vectors on Alice side.

◆ schmidtA() [2/2]

template<typename Derived >
cmat qpp::schmidtA ( const Eigen::MatrixBase< Derived > &  A,
idx  d = 2 
)

Schmidt basis on Alice side.

Parameters
AEigen expression
dSubsystem dimensions
Returns
Unitary matrix $ U $ whose columns represent the Schmidt basis vectors on Alice side.

◆ schmidtB() [1/2]

template<typename Derived >
cmat qpp::schmidtB ( const Eigen::MatrixBase< Derived > &  A,
const std::vector< idx > &  dims 
)

Schmidt basis on Bob side.

Parameters
AEigen expression
dimsDimensions of the bi-partite system
Returns
Unitary matrix $ V $ whose columns represent the Schmidt basis vectors on Bob side.

◆ schmidtB() [2/2]

template<typename Derived >
cmat qpp::schmidtB ( const Eigen::MatrixBase< Derived > &  A,
idx  d = 2 
)

Schmidt basis on Bob side.

Parameters
AEigen expression
dSubsystem dimensions
Returns
Unitary matrix $ V $ whose columns represent the Schmidt basis vectors on Bob side.

◆ schmidtcoeffs() [1/2]

template<typename Derived >
dyn_col_vect<double> qpp::schmidtcoeffs ( const Eigen::MatrixBase< Derived > &  A,
const std::vector< idx > &  dims 
)

Schmidt coefficients of the bi-partite pure state A.

Note
The sum of the squares of the Schmidt coefficients equals 1
See also
qpp::schmidtprobs()
Parameters
AEigen expression
dimsDimensions of the bi-partite system
Returns
Schmidt coefficients of A, ordered in decreasing order, as a real dynamic column vector

◆ schmidtcoeffs() [2/2]

template<typename Derived >
dyn_col_vect<double> qpp::schmidtcoeffs ( const Eigen::MatrixBase< Derived > &  A,
idx  d = 2 
)

Schmidt coefficients of the bi-partite pure state A.

Note
The sum of the squares of the Schmidt coefficients equals 1
See also
qpp::schmidtprobs()
Parameters
AEigen expression
dSubsystem dimensions
Returns
Schmidt coefficients of A, ordered in decreasing order, as a real dynamic column vector

◆ schmidtprobs() [1/2]

template<typename Derived >
std::vector<double> qpp::schmidtprobs ( const Eigen::MatrixBase< Derived > &  A,
const std::vector< idx > &  dims 
)

Schmidt probabilities of the bi-partite pure state A.

Defined as the squares of the Schmidt coefficients. The sum of the Schmidt probabilities equals 1.

See also
qpp::schmidtcoeffs()
Parameters
AEigen expression
dimsDimensions of the bi-partite system
Returns
Real vector consisting of the Schmidt probabilites of A, ordered in decreasing order

◆ schmidtprobs() [2/2]

template<typename Derived >
std::vector<double> qpp::schmidtprobs ( const Eigen::MatrixBase< Derived > &  A,
idx  d = 2 
)

Schmidt probabilities of the bi-partite pure state A.

Defined as the squares of the Schmidt coefficients. The sum of the Schmidt probabilities equals 1.

See also
qpp::schmidtcoeffs()
Parameters
AEigen expression
dSubsystem dimensions
Returns
Real vector consisting of the Schmidt probabilites of A, ordered in decreasing order

◆ sigma()

template<typename Container >
double qpp::sigma ( const std::vector< double > &  prob,
const Container &  X,
typename std::enable_if< is_iterable< Container >::value >::type *  = nullptr 
)

Standard deviation.

Parameters
probReal probability vector representing the probability distribution of X
XReal random variable values represented by an STL-like container
Returns
Standard deviation of X

◆ super2choi()

cmat qpp::super2choi ( const cmat A)
inline

Converts superoperator matrix to Choi matrix.

See also
qpp::choi2super()
Parameters
ASuperoperator matrix
Returns
Choi matrix

◆ syspermute() [1/2]

template<typename Derived >
dyn_mat<typename Derived::Scalar> qpp::syspermute ( const Eigen::MatrixBase< Derived > &  A,
const std::vector< idx > &  perm,
const std::vector< idx > &  dims 
)

Subsystem permutation.

Permutes the subsystems of a state vector or density matrix. The qubit perm[i] is permuted to the location i.

Parameters
AEigen expression
permPermutation
dimsDimensions of the multi-partite system
Returns
Permuted system, as a dynamic matrix over the same scalar field as A

◆ syspermute() [2/2]

template<typename Derived >
dyn_mat<typename Derived::Scalar> qpp::syspermute ( const Eigen::MatrixBase< Derived > &  A,
const std::vector< idx > &  perm,
idx  d = 2 
)

Subsystem permutation.

Permutes the subsystems of a state vector or density matrix. The qubit perm[i] is permuted to the location i.

Parameters
AEigen expression
permPermutation
dSubsystem dimensions
Returns
Permuted system, as a dynamic matrix over the same scalar field as A

◆ tsallis() [1/2]

template<typename Derived >
double qpp::tsallis ( const Eigen::MatrixBase< Derived > &  A,
double  q 
)

Tsallis- $q$ entropy of the density matrix A, for $q\geq 0$.

Note
When $ q\to 1$ the Tsallis entropy converges to the von-Neumann entropy, with the logarithm in base $ e $
Parameters
AEigen expression
qNon-negative real number
Returns
Tsallis- $q$ entropy

◆ tsallis() [2/2]

double qpp::tsallis ( const std::vector< double > &  prob,
double  q 
)
inline

Tsallis- $q$ entropy of the probability distribution prob, for $q\geq 0$.

Note
When $ q\to 1$ the Tsallis entropy converges to the Shannon entropy, with the logarithm in base $ e $
Parameters
probReal probability vector
qNon-negative real number
Returns
Tsallis- $q$ entropy

◆ uniform()

std::vector<double> qpp::uniform ( idx  N)
inline

Uniform probability distribution vector.

Parameters
NSize of the alphabet
Returns
Real vector consisting of a uniform distribution of size N

◆ var()

template<typename Container >
double qpp::var ( const std::vector< double > &  prob,
const Container &  X,
typename std::enable_if< is_iterable< Container >::value >::type *  = nullptr 
)

Variance.

Parameters
probReal probability vector representing the probability distribution of X
XReal random variable values represented by an STL-like container
Returns
Variance of X

◆ x2contfrac()

std::vector<int> qpp::x2contfrac ( double  x,
idx  N,
idx  cut = 1e5 
)
inline

Simple continued fraction expansion.

See also
qpp::contfrac2x()
Parameters
xReal number
NMaximum number of terms in the expansion
cutStop the expansion when the next term is greater than cut
Returns
Integer vector containing the simple continued fraction expansion of x. If there are M less than N terms in the expansion, a shorter vector with M components is returned.

Variable Documentation

◆ chop

constexpr double qpp::chop = 1e-10

Used in qpp::disp() for setting to zero numbers that have their absolute value smaller than qpp::chop.

◆ ee

constexpr double qpp::ee = 2.718281828459045235360287471352662497

Base of natural logarithm, $e$.

◆ eps

constexpr double qpp::eps = 1e-12

Used to decide whether a number or expression in double precision is zero or not.

Example:

if(std::abs(x) < qpp::eps) // x is zero

◆ infty

constexpr double qpp::infty = std::numeric_limits<double>::max()

Used to denote infinity in double precision.

◆ maxn

constexpr idx qpp::maxn = 64

Maximum number of allowed qubits/qudits (subsystems)

Used internally to allocate arrays on the stack (for performance reasons):

◆ pi

constexpr double qpp::pi = 3.141592653589793238462643383279502884

$ \pi $