# Functions and operations [Quantum States and Operations library]

Collaboration diagram for Functions and operations:

Collected useful quantum routines, usually functions of matrices/vectors, or operations on them. More...

## Functions

template<class T>
DenseMatrix< T > Commutator (const DenseMatrix< T > &m1, const DenseMatrix< T > &m2)
Creates a new DenseMatrix containing the commutator of two DenseMatrices: .
template<class T>
DenseMatrix< T > AntiCommutator (const DenseMatrix< T > &m1, const DenseMatrix< T > &m2)
Creates a new DenseMatrix containing the anticommutator of two DenseMatrices: .
template<class T>
DenseMatrix< T > & scavenge (DenseMatrix< T > &m, typename linalg_traits< T >::abs_type minabs)
Sets all the entries of m whose absolute value falls below minabs to zero, and returns a reference to the result.
template<class T>
DenseVector< T > & scavenge (DenseVector< T > &v, typename linalg_traits< T >::abs_type minabs)
Sets all the entries of v whose absolute value falls below minabs to zero, and returns a reference to the result.
template<class T>
DenseMatrix< T > scavenge (const DenseMatrix< T > &m, typename linalg_traits< T >::abs_type minabs)
Creates a new DenseMatrix which is a scavenged copy of m, and returns it.
template<class T>
DenseVector< T > scavenge (const DenseVector< T > &v, typename linalg_traits< T >::abs_type minabs)
Creates a new DenseVector which is a scavenged copy of m, and returns it.
double Entropy (Operator &rho)
Computes the Von Neumann entropy of the positive semidefinite matrix rho.
double LinearEntropy (Operator &rho)
Computes the linear entropy of the positive semidefinite matrix rho.
OperatorRandomMixedState (Operator &Rho, itype Nancillae)
Assigns to Rho a random mixed state from the induced measure on 1+Nancillae copies.
OperatorHaarRandomize (Operator &Rho)
Assigns to Rho a random pure state. Equivalent to RandomMixedState() with Nancillae=0.
OperatorHilbertSchmidtRandomize (Operator &Rho)
Assigns to Rho a positive semidefinite matrix selected from Hilbert-Schmidt measure. Equivalent to RandomMixedState() with Nancillae=1.
double TraceNorm (Operator &M)
Computes the sum of the absolute values of the eigenvalues of a Hermitian matrix M.
double InfinityNorm (Operator &M)
Computes the square root of the largest eigenvalue of . If is Hermitian, then this is the maximum of the absolute values of 's eigenvalues.
double Fidelity (Operator &Sigma, Operator &Rho)
Computes the fidelity between two states as .
double Fidelity (Operator &Sigma, State &Psi)
Computes the fidelity between a mixed state and a pure state : .
double Fidelity (State &Psi, Operator &Rho)
Computes the fidelity between a pure state and a mixed state a mixed state : .
double Fidelity (State &Psi, State &Phi)
Computes the fidelity between two pure states and : .
double NullspaceProjection (Operator &Sigma, Operator &Rho, double MinProbability=DBL_EPSILON)
Computes the projection of onto the nullspace of .
double RelativeEntropy (Operator &Sigma, Operator &Rho, double MinProbability=DBL_EPSILON)
Computes the relative entropy, or Kullback-Leibler divergence, of relative to : .
void RelativeEntropyAndNullProjection (double &RelEnt, double &NullProj, Operator &Sigma, Operator &Rho, double MinProbability)
Computes the relative entropy of relative to and the projection of onto 's null space.
OperatorPositivize (Operator &M)
Converts M to a positive-definite matrix by replacing all its negative eigenvalues with 0.
OperatorSquareRoot (Operator &M)
Replaces the Hermitian positive-definite matrix M with its unique positive-definite square root.
template<class Op>
double Entanglement (const State &psi, const TensorProductStructure &Universe, ISet &SubSystem, Op EntropyFunction)
Computes the bipartite entanglement of psi between SubSystem and its complement, using the user-supplied EntropyFunction.
double Entanglement (const State &psi, const TensorProductStructure &Universe, ISet &Subsystem)
Computes the bipartite entanglement of psi between SubSystem and its complement, using Von Neumann entropy.

## Detailed Description

Collected useful quantum routines, usually functions of matrices/vectors, or operations on them.

## Function Documentation

 template DenseMatrix< T > & scavenge ( DenseMatrix< T > & m, typename linalg_traits< T >::abs_type minabs )
 Sets all the entries of m whose absolute value falls below minabs to zero, and returns a reference to the result. For complex-valued matrices, scavenge acts independently on the real and imaginary components of each entry.

 template DenseVector< T > & scavenge ( DenseVector< T > & v, typename linalg_traits< T >::abs_type minabs )
 Sets all the entries of v whose absolute value falls below minabs to zero, and returns a reference to the result. For complex-valued vectors, scavenge acts independently on the real and imaginary components of each entry.

 double Entropy ( Operator & rho )
 Computes the Von Neumann entropy of the positive semidefinite matrix rho. The Von Neumann entropy is computed by diagonalizing the density matrix, and computing the sum of over all eigenvalues $x_i$. We assume Hermiticity, but we do verify that: rho is square (NxN); violation will cause an error message and failure,Trace(rho) = 1 to within ; violation will cause a warning to std::cerr,each eigenvalue is between 0 and 1; violation will cause a warning to std::cerr,the eigenvalues add up to the trace (to within ); violation will cause a warning to std::cerr. Failure (and an error message) can also be caused by any failure of the (LAPACK) EigenValuesHermitian() routine.

 Operator& RandomMixedState ( Operator & Rho, itype Nancillae )
 Assigns to Rho a random mixed state from the induced measure on 1+Nancillae copies. There is no unique measure from which to choose a random mixed state. One appealing class of measures is the set of induced measures obtained by partial-tracing a random pure state (according to Haar measure) on a larger system. This function generates such a state for a D-dimensional system (where D is the size of Rho). The larger system comprises Nancillae + 1 D-dimensional systems. Warning: be cautious in setting Nancillae too high; generating the state could take huge amounts of memory, increasing exponentially with Nancillae.

 double Fidelity ( Operator & Sigma, Operator & Rho )
 Computes the fidelity between two states as . Both arguments must be positive-definite, or the routine will complain to std::cerr and return 0. This routine is rather computationally intensive, so if one of the two states is known to be pure, use the faster routine for that case.

 double NullspaceProjection ( Operator & Sigma, Operator & Rho, double MinProbability = DBL_EPSILON )
 Computes the projection of onto the nullspace of . This can be interpreted as the maximum of the probability that an event for which predicts zero probability is selected from an ensemble represented by . Any eigenvalue of less than MinProbability will be considered effectively zero for the purposes of computing the null space. MinProbability can therefore be any real number, although the default value is DBL_EPSILON, which is defined in float.h as the smallest number such that in double-precision arithmetic.

 double RelativeEntropy ( Operator & Sigma, Operator & Rho, double MinProbability = DBL_EPSILON )
 Computes the relative entropy, or Kullback-Leibler divergence, of relative to : . If has zero or negative eigenvalues (which may occur due to rounding error), then the relative entropy will probably be infinite. In order to avoid this, all eigenvalues of less than MinProbability will be rounded up to MinProbability. This parameter should always be a positive number; by default it is DBL_EPSILON, which is defined in float.h as the smallest number such that in double-precision arithmetic.

 void RelativeEntropyAndNullProjection ( double & RelEnt, double & NullProj, Operator & Sigma, Operator & Rho, double MinProbability )
 Computes the relative entropy of relative to and the projection of onto 's null space. The results are stored in RelEnt and NullProj, respectively. The parameter MinProbability divides the eigenvalues of into: those below MinProbability, which are treated as null space, andthose above it, which are used to compute relative entropy.

 Operator& SquareRoot ( Operator & M )
 Replaces the Hermitian positive-definite matrix M with its unique positive-definite square root. NOTE: if the argument turns out not to be positive-definite, then the result is non-unique, non-Hermitian, and will be constructed by setting . Hermiticity is a precondition; non-Hermitian inputs will lead to undefined results including possible failure.

 template double Entanglement ( const State & psi, const TensorProductStructure & Universe, ISet & SubSystem, Op EntropyFunction )
 Computes the bipartite entanglement of psi between SubSystem and its complement, using the user-supplied EntropyFunction. The entropy function should be a function pointer or class such that for a density matrix rho, EntropyFunction( rho ) is well-defined. The entanglement will be computed as the entropy of the reduced density matrix either for SubSystem or for its complement. These are equivalent, thanks to the Schmidt decomposition, provided that EntropyFunction( rho ) is (a) a function only of rho's eigenvalues, and (b) not affected by adding zero eigenvalues.

Generated on Wed Jun 14 22:25:40 2006 for linalg by  1.4.4