Collaboration diagram for Partial traces:
Functions  
Operator &  PTrace (const State &psi, Operator &rho, bool flagTraceOverMSB=false) 
Does a simple partial trace of over as many dimensions as needed to fit the result in .  
DenseMatrix< complex >  partial_trace (const DenseMatrix< complex > &m, const TensorProductStructure &TPS, ISet &indices) 
Creates and returns a new matrix which is the partial trace of m , over the indices indices in the tensor product structure TPS .  
DenseMatrix< complex >  partial_trace (const DenseVector< complex > &v, const TensorProductStructure &TPS, ISet &indices) 
Creates and returns a new matrix which is the partial trace of the projector onto v , over the indices indices in the tensor product structure TPS .  
DenseMatrix< complex >  partial_trace_asymm (const DenseVector< complex > &ket, const DenseVector< complex > &bra, const TensorProductStructure &TPS, ISet &indices) 
Creates and returns a new matrix which is the partial trace of the (nonHermitian) outer product ket><bra , over the indices indices in the tensor product structure TPS .  
State &  Purify (const Operator &rho, State &psi) 

Does a simple partial trace of over as many dimensions as needed to fit the result in . must evenly divide . PTrace will trace out part of to fit the result in . The assumption is that we want to trace over the least significant indices of  i.e., , but if flagTraceOverMSB is set, then we'll compute . 

must evenly divide . This function basically undoes a partial trace (nonuniquely!), by generating a pure state on a larger Hilbert space which, when partially traced over its least significant bits (the ancilla), will yield the desired density matrix. This is not necessarily possible unless the ancilla is just as big as the system with the mixed state, but we try anyway. Eigenvalues of less than are ignored. All others get their eigenvectors correlated with one of a set of mutually orthogonal pure states on the ancilla. The whole superposition is returned in psi. If the ancilla is smaller than the original system but the Schmidt rank of is low, then purification will be successful. Otherwise we generate another warning message, and return a state that might do sort of well. 