Quantum++
v1.0-rc3
A modern C++11 quantum computing library
|
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 ![]() | |
constexpr cplx | operator"" _i (long double x) noexcept |
User-defined literal for complex ![]() | |
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- ![]() ![]() | |
double | renyi (const std::vector< double > &prob, double alpha) |
Renyi- ![]() ![]() | |
template<typename Derived > | |
double | tsallis (const Eigen::MatrixBase< Derived > &A, double q) |
Tsallis- ![]() ![]() | |
double | tsallis (const std::vector< double > &prob, double q) |
Tsallis- ![]() ![]() | |
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, cmat > | 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. More... | |
template<typename Derived > | |
std::tuple< std::vector< idx >, double, cmat > | 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. 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< idx > | invperm (const std::vector< idx > &perm) |
Inverse permutation. More... | |
std::vector< idx > | compperm (const std::vector< idx > &perm, const std::vector< idx > &sigma) |
Compose permutations. More... | |
std::vector< bigint > | factors (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, bigint > | egcd (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< cmat > | choi2kraus (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< cmat > | randkraus (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< idx > | randperm (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 |
![]() | |
constexpr double | ee = 2.718281828459045235360287471352662497 |
Base of natural logarithm, ![]() | |
constexpr double | infty = std::numeric_limits<double>::max() |
Used to denote infinity in double precision. More... | |
Quantum++ main namespace.
using qpp::bigint = typedef long long int |
Big integer.
using qpp::bra = typedef Eigen::RowVectorXcd |
Complex (double precision) dynamic Eigen row vector.
using qpp::cmat = typedef Eigen::MatrixXcd |
Complex (double precision) dynamic Eigen matrix.
using qpp::cplx = typedef std::complex<double> |
Complex number in double precision.
using qpp::dmat = typedef Eigen::MatrixXd |
Real (double precision) dynamic Eigen matrix.
using qpp::dyn_col_vect = typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1> |
Dynamic Eigen column vector over the field specified by Scalar.
Example:
using qpp::dyn_mat = typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> |
Dynamic Eigen matrix over the field specified by Scalar.
Example:
using qpp::dyn_row_vect = typedef Eigen::Matrix<Scalar, 1, Eigen::Dynamic> |
Dynamic Eigen row vector over the field specified by Scalar.
Example:
using qpp::idx = typedef std::size_t |
Non-negative integer index.
using qpp::ket = typedef Eigen::VectorXcd |
Complex (double precision) dynamic Eigen column vector.
using qpp::to_void = typedef typename make_void<Ts...>::type |
Alias template that implements the proposal for void_t.
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.
state | Eigen expression |
A | Eigen expression |
subsys | Subsystem indexes where the gate A is applied |
dims | Dimensions of the multi-partite system |
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.
state | Eigen expression |
A | Eigen expression |
subsys | Subsystem indexes where the gate A is applied |
d | Subsystem dimensions |
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.
A | Eigen expression |
Ks | Set of Kraus operators |
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.
A | Eigen expression |
Ks | Set of Kraus operators |
subsys | Subsystem indexes where the Kraus operators Ks are applied |
dims | Dimensions of the multi-partite system |
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.
A | Eigen expression |
Ks | Set of Kraus operators |
subsys | Subsystem indexes where the Kraus operators Ks are applied |
d | Subsystem dimensions |
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.
state | Eigen expression |
A | Eigen expression |
ctrl | Control subsystem indexes |
subsys | Subsystem indexes where the gate A is applied |
dims | Dimensions of the multi-partite system |
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.
state | Eigen expression |
A | Eigen expression |
ctrl | Control subsystem indexes |
subsys | Subsystem indexes where the gate A is applied |
d | Subsystem dimensions |
double qpp::avg | ( | const std::vector< double > & | prob, |
const Container & | X, | ||
typename std::enable_if< is_iterable< Container >::value >::type * | = nullptr |
||
) |
Average.
prob | Real probability vector representing the probability distribution of X |
X | Real random variable values represented by an STL-like container |
Orthogonal Kraus operators from Choi matrix.
Extracts a set of orthogonal (under Hilbert-Schmidt operator norm) Kraus operators from the Choi matrix A
A | Choi matrix |
Converts Choi matrix to superoperator matrix.
A | Choi matrix |
|
inline |
Compose permutations.
perm | Permutation |
sigma | Permutation |
double qpp::concurrence | ( | const Eigen::MatrixBase< Derived > & | A | ) |
Wootters concurrence of the bi-partite qubit mixed state A.
A | Eigen expression |
Real representation of a simple continued fraction.
cf | Integer vector containing the simple continued fraction expansion |
N | Number of terms considered in the continued fraction expansion. |
double qpp::cor | ( | const dmat & | probXY, |
const Container & | X, | ||
const Container & | Y, | ||
typename std::enable_if< is_iterable< Container >::value >::type * | = nullptr |
||
) |
Correlation.
probXY | Real matrix representing the joint probability distribution of X and Y in lexicographical order (X labels the rows, Y labels the columns) |
X | Real random variable values represented by an STL-like container |
Y | Real random variable values represented by an STL-like container |
double qpp::cov | ( | const dmat & | probXY, |
const Container & | X, | ||
const Container & | Y, | ||
typename std::enable_if< is_iterable< Container >::value >::type * | = nullptr |
||
) |
Covariance.
probXY | Real matrix representing the joint probability distribution of X and Y in lexicographical order (X labels the rows, Y labels the columns) |
X | Real random variable values represented by an STL-like container |
Y | Real random variable values represented by an STL-like container |
internal::IOManipEigen qpp::disp | ( | const Eigen::MatrixBase< Derived > & | A, |
double | chop = qpp::chop |
||
) |
Eigen expression ostream manipulator.
A | Eigen expression |
chop | Set to zero the elements smaller in absolute value than chop |
|
inline |
Complex number ostream manipulator.
z | Complex number (or any other type implicitly cast-able to std::complex<double>) |
chop | Set to zero the elements smaller in absolute value than chop |
internal::IOManipRange<InputIterator> qpp::disp | ( | InputIterator | first, |
InputIterator | last, | ||
const std::string & | separator, | ||
const std::string & | start = "[" , |
||
const std::string & | end = "]" |
||
) |
Range ostream manipulator.
first | Iterator to the first element of the range |
last | Iterator to the last element of the range |
separator | Separator |
start | Left marking |
end | Right marking |
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.
c | Container |
separator | Separator |
start | Left marking |
end | Right marking |
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.
p | Pointer to the first element |
N | Number of elements to be displayed |
separator | Separator |
start | Left marking |
end | Right marking |
Extended greatest common divisor of two integers.
a | Integer |
b | Integer |
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
A | Eigen expression |
dims | Dimensions of the bi-partite system |
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
A | Eigen expression |
d | Subsystem dimensions |
double qpp::entropy | ( | const Eigen::MatrixBase< Derived > & | A | ) |
von-Neumann entropy of the density matrix A
A | Eigen expression |
|
inline |
Shannon entropy of the probability distribution prob.
prob | Real probability vector |
Prime factor decomposition.
a | Integer different from 0, 1 or -1 |
Greatest common divisor of two integers.
a | Integer |
b | Integer |
Greatest common divisor of a list of integers.
as | List of integers |
double qpp::gconcurrence | ( | const Eigen::MatrixBase< Derived > & | A | ) |
G-concurrence of the bi-partite pure state A.
Uses qpp::logdet() to avoid overflows
A | Eigen expression |
Inverse permutation.
perm | Permutation |
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.
phi | Column vector Eigen expression |
psi | Column vector Eigen expression |
subsys | Subsystem indexes over which phi is defined |
dims | Dimensions of the multi-partite system |
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.
phi | Column vector Eigen expression |
psi | Column vector Eigen expression |
subsys | Subsystem indexes over which phi is defined |
d | Subsystem dimensions |
Primality test based on the Miller-Rabin's algorithm.
p | Integer different from 0, 1 or -1 |
k | Number of iterations. The probability of a false positive is ![]() |
Choi matrix.
Constructs the Choi matrix of the channel specified by the set of Kraus operators Ks in the standard operator basis ordered in lexicographical order, i.e.
,
etc.
Ks | Set of Kraus operators |
Superoperator matrix.
Constructs the superoperator matrix of the channel specified by the set of Kraus operators Ks in the standard operator basis ordered in lexicographical order, i.e.
,
etc.
Ks | Set of Kraus operators |
Least common multiple of two integers.
a | Integer |
b | Integer |
Least common multiple of a list of integers.
as | List of integers |
dyn_mat<typename Derived::Scalar> qpp::load | ( | const std::string & | fname | ) |
Loads Eigen matrix from a binary file (internal format) in double precision.
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:
fname | Output file name |
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,.
The template parameter cannot be automatically deduced and must be explicitly provided
Example:
Derived | Complex Eigen type |
mat_file | MATALB .mat file |
var_name | Variable name in the .mat file representing the matrix to be loaded |
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,.
The template parameter cannot be automatically deduced and must be explicitly provided
Example:
Derived | Non-complex Eigen type |
mat_file | MATALB .mat file |
var_name | Variable name in the .mat file representing the matrix to be loaded |
double qpp::lognegativity | ( | const Eigen::MatrixBase< Derived > & | A, |
const std::vector< idx > & | dims | ||
) |
Logarithmic negativity of the bi-partite mixed state A.
A | Eigen expression |
dims | Dimensions of the bi-partite system |
double qpp::lognegativity | ( | const Eigen::MatrixBase< Derived > & | A, |
idx | d = 2 |
||
) |
Logarithmic negativity of the bi-partite mixed state A.
A | Eigen expression |
d | Subsystem dimensions |
|
inline |
Marginal distribution.
probXY | Real matrix representing the joint probability distribution of X and Y in lexicographical order (X labels the rows, Y labels the columns) |
|
inline |
Marginal distribution.
probXY | Real matrix representing the joint probability distribution of X and Y in lexicographical order (X labels the rows, Y labels the columns) |
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.
A | Eigen expression |
Ks | Set of Kraus operators |
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.
A | Eigen expression |
Ks | Set of Kraus operators |
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.
A | Eigen expression |
U | Unitary matrix whose columns represent the measurement basis vectors |
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.
A | Eigen expression |
Ks | Set of Kraus operators |
subsys | Subsystem indexes that are measured |
dims | Dimensions of the multi-partite system |
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.
A | Eigen expression |
Ks | Set of Kraus operators |
subsys | Subsystem indexes that are measured |
dims | Dimensions of the multi-partite system |
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.
A | Eigen expression |
Ks | Set of Kraus operators |
subsys | Subsystem indexes that are measured |
d | Subsystem dimensions |
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.
A | Eigen expression |
Ks | Set of Kraus operators |
subsys | Subsystem indexes that are measured |
d | Subsystem dimensions |
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.
A | Eigen expression |
V | Matrix whose columns represent the measurement basis vectors or the bra parts of the rank-1 POVM |
subsys | Subsystem indexes that are measured |
dims | Dimensions of the multi-partite system |
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.
A | Eigen expression |
V | Matrix whose columns represent the measurement basis vectors or the bra parts of the rank-1 POVM |
subsys | Subsystem indexes that are measured |
d | Subsystem dimensions |
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.
A | Eigen expression |
subsys | Subsystem indexes that are measured |
dims | Dimensions of the multi-partite system |
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.
A | Eigen expression |
subsys | Subsystem indexes that are measured |
d | Subsystem dimensions |
Modular inverse of a mod p.
a | Non-negative integer |
p | Non-negative integer |
Modular multiplication without overflow.
Computes
without overflow
a | Integer |
b | Integer |
p | Positive integer |
Fast integer power modulo p based on the SQUARE-AND-MULTIPLY algorithm.
Computes
a | Non-negative integer |
n | Non-negative integer |
p | Strictly positive integer |
double qpp::negativity | ( | const Eigen::MatrixBase< Derived > & | A, |
const std::vector< idx > & | dims | ||
) |
Negativity of the bi-partite mixed state A.
A | Eigen expression |
dims | Dimensions of the bi-partite system |
double qpp::negativity | ( | const Eigen::MatrixBase< Derived > & | A, |
idx | d = 2 |
||
) |
Negativity of the bi-partite mixed state A.
A | Eigen expression |
d | Subsystem dimensions |
D-th root of unity.
D | Non-negative integer |
|
inlinenoexcept |
User-defined literal for complex (integer overload)
Example:
|
inlinenoexcept |
User-defined literal for complex (real overload)
Example:
dyn_mat<typename Derived::Scalar> qpp::ptrace | ( | const Eigen::MatrixBase< Derived > & | A, |
const std::vector< idx > & | subsys, | ||
const std::vector< idx > & | dims | ||
) |
Partial trace.
Partial trace of the multi-partite state vector or density matrix over a list of subsystems
A | Eigen expression |
subsys | Subsystem indexes |
dims | Dimensions of the multi-partite system |
dyn_mat<typename Derived::Scalar> qpp::ptrace | ( | const Eigen::MatrixBase< Derived > & | A, |
const std::vector< idx > & | subsys, | ||
idx | d = 2 |
||
) |
Partial trace.
Partial trace of the multi-partite state vector or density matrix over a list of subsystems
A | Eigen expression |
subsys | Subsystem indexes |
d | Subsystem dimensions |
dyn_mat<typename Derived::Scalar> qpp::ptrace1 | ( | const Eigen::MatrixBase< Derived > & | A, |
const std::vector< idx > & | dims | ||
) |
Partial trace.
Partial trace over the first subsystem of bi-partite state vector or density matrix
A | Eigen expression |
dims | Dimensions of the bi-partite system |
dyn_mat<typename Derived::Scalar> qpp::ptrace1 | ( | const Eigen::MatrixBase< Derived > & | A, |
idx | d = 2 |
||
) |
Partial trace.
Partial trace over the first subsystem of bi-partite state vector or density matrix
A | Eigen expression |
d | Subsystem dimensions |
dyn_mat<typename Derived::Scalar> qpp::ptrace2 | ( | const Eigen::MatrixBase< Derived > & | A, |
const std::vector< idx > & | dims | ||
) |
Partial trace.
Partial trace over the second subsystem of bi-partite state vector or density matrix
A | Eigen expression |
dims | Dimensions of the bi-partite system |
dyn_mat<typename Derived::Scalar> qpp::ptrace2 | ( | const Eigen::MatrixBase< Derived > & | A, |
idx | d = 2 |
||
) |
Partial trace.
Partial trace over the second subsystem of bi-partite state vector or density matrix
A | Eigen expression |
d | Subsystem dimensions |
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
A | Eigen expression |
subsys | Subsystem indexes |
dims | Dimensions of the multi-partite system |
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
A | Eigen expression |
subsys | Subsystem indexes |
d | Subsystem dimensions |
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.
A | Eigen expression |
subsysA | Indexes of the first subsystem |
subsysB | Indexes of the second subsystem |
dims | Dimensions of the multi-partite system |
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.
A | Eigen expression |
subsysA | Indexes of the first subsystem |
subsysB | Indexes of the second subsystem |
d | Subsystem dimensions |
|
inline |
Generates a random real number uniformly distributed in the interval [a, b)
a | Beginning of the interval, belongs to it |
b | End of the interval, does not belong to it |
Generates a random big integer uniformly distributed in the interval [a, b].
a | Beginning of the interval, belongs to it |
b | End of the interval, belongs to it |
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
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:
rows | Number of rows of the random generated matrix |
cols | Number of columns of the random generated matrix |
a | Beginning of the interval, belongs to it |
b | End of the interval, does not belong to it |
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:
rows | Number of rows of the random generated matrix |
cols | Number of columns of the random generated matrix |
a | Beginning of the interval, belongs to it |
b | End of the interval, does not belong to it |
Generates a random Hermitian matrix.
D | Dimension of the Hilbert space |
|
inline |
Generates a random index (idx) uniformly distributed in the interval [a, b].
a | Beginning of the interval, belongs to it |
b | End of the interval, belongs to it |
Generates a random normalized ket (pure state vector)
D | Dimension of the Hilbert space |
Generates a set of random Kraus operators.
N | Number of Kraus operators |
D | Dimension of the Hilbert space |
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
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:
rows | Number of rows of the random generated matrix |
cols | Number of columns of the random generated matrix |
mean | Mean |
sigma | Standard deviation |
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:
rows | Number of rows of the random generated matrix |
cols | Number of columns of the random generated matrix |
mean | Mean |
sigma | Standard deviation |
|
inline |
Generates a random real number (double) normally distributed in N(mean, sigma)
mean | Mean |
sigma | Standard deviation |
Generates a random uniformly distributed permutation.
Uses Knuth shuffle method (as implemented by std::shuffle), so that all permutations are equally probable
N | Size of the permutation |
Generates a random big prime uniformly distributed in the interval [a, b].
a | Beginning of the interval, belongs to it |
b | End of the interval, belongs to it |
N | Maximum number of candidates |
|
inline |
Generates a random probability vector uniformly distributed over the probability simplex.
N | Size of the probability vector |
Generates a random density matrix.
D | Dimension of the Hilbert space |
Generates a random unitary matrix.
D | Dimension of the Hilbert space |
Generates a random isometry matrix.
Din | Size of the input Hilbert space |
Dout | Size of the output Hilbert space |
double qpp::renyi | ( | const Eigen::MatrixBase< Derived > & | A, |
double | alpha | ||
) |
Renyi- entropy of the density matrix A, for
.
A | Eigen expression |
alpha | Non-negative real number, use qpp::infty for ![]() |
|
inline |
Renyi- entropy of the probability distribution prob, for
.
prob | Real probability vector |
alpha | Non-negative real number, use qpp::infty for ![]() |
void qpp::save | ( | const Eigen::MatrixBase< Derived > & | A, |
const std::string & | fname | ||
) |
Saves Eigen expression to a binary file (internal format) in double precision.
A | Eigen expression |
fname | Output file name |
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,.
Complex | Eigen type |
A | Eigen expression over the complex field |
mat_file | MATALB .mat file |
var_name | Variable name in the .mat file representing the matrix to be saved |
mode | Saving mode (append, overwrite etc.), see MATLAB matOpen() documentation for details |
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,.
Npn-complex | Eigen type |
A | Non-complex Eigen expression |
mat_file | MATALB .mat file |
var_name | Variable name in the .mat file representing the matrix to be saved |
mode | Saving mode (append, overwrite etc.), see MATLAB matOpen() documentation for details |
cmat qpp::schmidtA | ( | const Eigen::MatrixBase< Derived > & | A, |
const std::vector< idx > & | dims | ||
) |
Schmidt basis on Alice side.
A | Eigen expression |
dims | Dimensions of the bi-partite system |
cmat qpp::schmidtA | ( | const Eigen::MatrixBase< Derived > & | A, |
idx | d = 2 |
||
) |
Schmidt basis on Alice side.
A | Eigen expression |
d | Subsystem dimensions |
cmat qpp::schmidtB | ( | const Eigen::MatrixBase< Derived > & | A, |
const std::vector< idx > & | dims | ||
) |
Schmidt basis on Bob side.
A | Eigen expression |
dims | Dimensions of the bi-partite system |
cmat qpp::schmidtB | ( | const Eigen::MatrixBase< Derived > & | A, |
idx | d = 2 |
||
) |
Schmidt basis on Bob side.
A | Eigen expression |
d | Subsystem dimensions |
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.
A | Eigen expression |
dims | Dimensions of the bi-partite system |
dyn_col_vect<double> qpp::schmidtcoeffs | ( | const Eigen::MatrixBase< Derived > & | A, |
idx | d = 2 |
||
) |
Schmidt coefficients of the bi-partite pure state A.
A | Eigen expression |
d | Subsystem dimensions |
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.
A | Eigen expression |
dims | Dimensions of the bi-partite system |
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.
A | Eigen expression |
d | Subsystem dimensions |
double qpp::sigma | ( | const std::vector< double > & | prob, |
const Container & | X, | ||
typename std::enable_if< is_iterable< Container >::value >::type * | = nullptr |
||
) |
Standard deviation.
prob | Real probability vector representing the probability distribution of X |
X | Real random variable values represented by an STL-like container |
Converts superoperator matrix to Choi matrix.
A | Superoperator matrix |
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.
A | Eigen expression |
perm | Permutation |
dims | Dimensions of the multi-partite system |
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.
A | Eigen expression |
perm | Permutation |
d | Subsystem dimensions |
double qpp::tsallis | ( | const Eigen::MatrixBase< Derived > & | A, |
double | q | ||
) |
Tsallis- entropy of the density matrix A, for
.
A | Eigen expression |
q | Non-negative real number |
|
inline |
Tsallis- entropy of the probability distribution prob, for
.
prob | Real probability vector |
q | Non-negative real number |
|
inline |
Uniform probability distribution vector.
N | Size of the alphabet |
double qpp::var | ( | const std::vector< double > & | prob, |
const Container & | X, | ||
typename std::enable_if< is_iterable< Container >::value >::type * | = nullptr |
||
) |
Variance.
prob | Real probability vector representing the probability distribution of X |
X | Real random variable values represented by an STL-like container |
Simple continued fraction expansion.
x | Real number |
N | Maximum number of terms in the expansion |
cut | Stop the expansion when the next term is greater than cut |
constexpr double qpp::chop = 1e-10 |
Used in qpp::disp() for setting to zero numbers that have their absolute value smaller than qpp::chop.
constexpr double qpp::ee = 2.718281828459045235360287471352662497 |
Base of natural logarithm, .
constexpr double qpp::eps = 1e-12 |
Used to decide whether a number or expression in double precision is zero or not.
Example:
constexpr double qpp::infty = std::numeric_limits<double>::max() |
Used to denote infinity in double precision.
constexpr idx qpp::maxn = 64 |
Maximum number of allowed qubits/qudits (subsystems)
Used internally to allocate arrays on the stack (for performance reasons):
constexpr double qpp::pi = 3.141592653589793238462643383279502884 |