#include "linalg.h"
#include <iostream>
#include <cstdlib>
#include <stdarg.h>
#include <vector>
#include <set>
#include <algorithm>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <float.h>
Include dependency graph for quantum.h:
Namespaces | |
namespace | ConstStates |
Classes | |
class | TensorProductStructure |
Defines a tensor product structure on a finite dimensional Hilbert space. More... | |
class | TensorProductIndex |
Defines an index for iterating over a tensor product structure. More... | |
class | ProductState |
A tensor product state vector. More... | |
class | SinglyBranchingState |
A sum of product states that can be distinguished perfectly by measuring one (special) subsystem. More... | |
class | ProductOperator |
A tensor product of operators (complex matrices). More... | |
class | ProductOperatorSum |
A sum of TensorProductOperator operators. More... | |
class | Histogram |
Class to hold and compute histograms over the real numbers. More... | |
class | Accumulator |
Class to compute simple statistics of a stream of (currently real) numbers. More... | |
class | Timer |
The Timer class is used to precisely profile the running time of algorithms. More... | |
Typedefs | |
typedef std::set< itype, std::less< itype > > | ISet |
An ISet is an unordered set of distinct indices (unsigned int). | |
typedef std::vector< itype > | IArray |
An IArray is an ordered array of indices (unsigned int). | |
typedef DenseVector< complex > | State |
State holds a quantum state vector. It is a synonym for DenseVector<complex>. | |
typedef DenseMatrix< complex > | Operator |
Operator holds an operator on quantum states. It is a synonym for DenseMatrix<complex>. | |
Functions | |
std::ostream & | operator<< (std::ostream &os, const TensorProductStructure &TPS) |
Prints a TensorProductStructure to a stream, as a list "{a,b,...,z}". | |
std::ostream & | operator<< (std::ostream &os, const TensorProductIndex &TPI) |
Prints a TensorProductIndex to a stream, as a list "{a,b,...,z}". | |
void | SimplifySubsystemDivision (TensorProductStructure &Universe, ISet &Subsystem) |
Specialized function to collapse a TensorProductStructure for partial iteration. | |
complex | c_dot (ProductState &star, ProductState &nostar, int index=(-1)) |
Computes the conjugate dot product between two ProductStates, or between two of their subsystem states if the optional index parameter is provided. | |
template<class T> | |
DenseVector< T > | tensor (const DenseVector< T > &v1, const DenseVector< T > &v2) |
Creates and returns a new DenseVector containing the tensor product of v1 and v2 . | |
template<class T> | |
DenseVector< T > | tensor (itype N, DenseVector< T > *v_arr1[]) |
Creates and returns a new DenseVector containing the tensor product of v_arr[0...N-1]. | |
template<class T> | |
DenseMatrix< T > | tensor (const DenseMatrix< T > &m1, const DenseMatrix< T > &m2) |
Creates and returns a new DenseMatrix containing the tensor product of m1 and m2. | |
template<class T> | |
DenseMatrix< T > | tensor (itype N, DenseMatrix< T > *m_arr[]) |
Creates and returns a new DenseMatrix containing the tensor product of v_arr[0...N-1]. | |
template<class T> | |
DenseVector< T > & | tensor_into (const DenseVector< T > &v1, const DenseVector< T > &v2, DenseVector< T > &result, T scalar=T(1)) |
Overwrites result with scalar times the tensor product of v1 and v2, and returns a reference to result. | |
template<class T> | |
DenseVector< T > & | tensor_into (itype N, DenseVector< T > *v_arr[], DenseVector< T > &result, T scalar=T(1)) |
Overwrites result with scalar times the tensor product of v_arr[0...N-1], and returns a reference to result. | |
template<class T> | |
DenseMatrix< T > & | tensor_into (const DenseMatrix< T > &m1, const DenseMatrix< T > &m2, DenseMatrix< T > &result, T scalar=T(1)) |
Overwrites result with scalar times the tensor product of m1 and m2, and returns a reference to result. | |
template<class T> | |
DenseMatrix< T > & | tensor_into (itype N, DenseMatrix< T > *m_arr[], DenseMatrix< T > &result, T scalar=T(1)) |
Overwrites result with scalar times the tensor product of m_arr[0...N-1], and returns a reference to result. | |
template<class T> | |
DenseVector< T > & | add_tensor (const DenseVector< T > &v1, const DenseVector< T > &v2, DenseVector< T > &accumulator, T scalar=T(1)) |
Adds scalar times the tensor product of v1 and v2 to result, and returns a reference to result. | |
template<class T> | |
DenseVector< T > & | add_tensor (itype N, DenseVector< T > *v_arr[], DenseVector< T > &accumulator, T scalar=T(1)) |
Adds scalar times the tensor product of v_arr[0...N-1] to result, and returns a reference to result. | |
template<class T> | |
DenseMatrix< T > & | add_tensor (const DenseMatrix< T > &m1, const DenseMatrix< T > &m2, DenseMatrix< T > &accumulator, T scalar=T(1)) |
Adds scalar times the tensor product of m1 and m2 to result, and returns a reference to result. | |
template<class T> | |
DenseMatrix< T > & | add_tensor (itype N, DenseMatrix< T > *m_arr[], DenseMatrix< T > &accumulator, T scalar=T(1)) |
Adds scalar times the tensor product of v_arr[0...N-1] to result, and returns a reference to result. | |
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> | |
T | scavenge (T scalar, typename linalg_traits< T >::abs_type minabs) |
Returns scalar if its absolute value is not less than minabs , or 0 otherwise. | |
complex | scavenge (complex scalar, double minabs) |
Overloads scavenge<T> to scavenge the real and imaginary parts of scalar independently. | |
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. | |
Operator & | PTrace (const State &psi, Operator &rho, bool flagTraceOverMSB=false) |
Does a simple partial trace of ![]() ![]() | |
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 (non-Hermitian) outer product |ket><bra| , over the indices indices in the tensor product structure TPS . | |
State & | Purify (const Operator &rho, State &psi) |
bool | PathOpen (const char *pathname, std::ofstream &os) |
Opens os for writing to the file given by pathname . Creating all necessary directories. Returns FALSE if it fails. | |
double | Entropy (Operator &rho) |
Computes the Von Neumann entropy ![]() rho . | |
double | LinearEntropy (Operator &rho) |
Computes the linear entropy ![]() rho . | |
Operator & | RandomMixedState (Operator &Rho, itype Nancillae) |
Assigns to Rho a random mixed state from the induced measure on 1+Nancillae copies. | |
Operator & | HaarRandomize (Operator &Rho) |
Assigns to Rho a random pure state. Equivalent to RandomMixedState() with Nancillae =0. | |
Operator & | HilbertSchmidtRandomize (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 ![]() ![]() ![]() | |
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 ![]() ![]() ![]() | |
double | Fidelity (State &Psi, Operator &Rho) |
Computes the fidelity between a pure state ![]() ![]() ![]() | |
double | Fidelity (State &Psi, State &Phi) |
Computes the fidelity between two pure states ![]() ![]() ![]() | |
double | NullspaceProjection (Operator &Sigma, Operator &Rho, double MinProbability=DBL_EPSILON) |
Computes the projection of ![]() ![]() | |
double | RelativeEntropy (Operator &Sigma, Operator &Rho, double MinProbability=DBL_EPSILON) |
Computes the relative entropy, or Kullback-Leibler divergence, of ![]() ![]() ![]() | |
void | RelativeEntropyAndNullProjection (double &RelEnt, double &NullProj, Operator &Sigma, Operator &Rho, double MinProbability) |
Computes the relative entropy of ![]() ![]() ![]() ![]() | |
Operator & | Positivize (Operator &M) |
Converts M to a positive-definite matrix by replacing all its negative eigenvalues with 0. | |
Operator & | SquareRoot (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. | |
void | GenerateChebyshevMatrix (itype N, DenseMatrix< complex > &M) |
Computes an NxN matrix, where ![]() ![]() ![]() | |
void | ResizeChebyshevMatrix (itype N, DenseMatrix< complex > &M) |
Efficiently resizes an existing Chebyshev polynomial matrix to NxN, using the coefficients already computed. | |
void | GenerateChebyshevEvolutionVector (double time, itype N, DenseVector< complex > &V) |
Computes an N-element vector, where ![]() ![]() ![]() | |
int | ChebyshevPrep (double timestep, double prec, DenseVector< complex > &PowerCoeffs, DenseVector< double > &CoeffsBoundSeq) |
Precomputes the coefficients needed to evolve a state using ChebyshevStep(), for time timestep , with accuracy prec . | |
template<typename T> | |
int | ChebyshevStep (const State &initial, State &final, DenseVector< complex > &PowerCoeffs, DenseVector< double > &CoeffsBoundSeq, const T &Hamiltonian, double E_bound, double prec) |
Transforms the quantum state initial by ![]() final . Requires precomputation by ChebyshevPrep(). | |
template<typename T> | |
int | ChebyshevEvolve (const State &initial, State &final, double time, const T &Hamiltonian, double E_bound, double prec=1e-10) |
Evolves the quantum state initial for a single step of duration time according to Hamiltonian , placing the result in final . | |
template<typename T> | |
int | ChebyshevStepEvolve (const State &initial, State &final, double time, double maxtimestep, const T &Hamiltonian, double E_bound, double prec=1e-10) |
Evolves the quantum state initial ==> final , for duration time , in steps no longer than maxtimestep , according to Hamiltonian . | |
Operator | ConstStates::Identity (itype D) |
Returns the identity operator in D dimensions. | |
Operator | ConstStates::Zero (itype D) |
Returns the zero operator in D dimensions. | |
Operator | ConstStates::Hadamard () |
Returns the Hadamard matrix for qubits. | |
Operator | ConstStates::HalfPhase () |
Returns the phase-flip matrix (square root of SigmaZ) for qubits. | |
Operator | ConstStates::SigmaX () |
Returns the J=1/2 Pauli spin operator along the X axis. | |
Operator | ConstStates::SigmaY () |
Returns the J=1/2 Pauli spin operator along the Y axis. | |
Operator | ConstStates::SigmaZ () |
Returns the J=1/2 Pauli spin operator along the Z axis. | |
Operator | ConstStates::SigmaI () |
Returns the J=1/2 Identity operator. | |
Operator | ConstStates::Sigma (itype i) |
Returns the i th matrix from the Pauli group, {X,Y,Z,I}. | |
Operator | ConstStates::QubitSpinOperator (double x, double y, double z) |
Returns an arbitrary J=1/2 spin operator ![]() | |
State | ConstStates::QubitSpinState (double x, double y, double z) |
Returns a J=1/2 pure state so that <X>=x , <Y>=y , and <Z>=z , up to normalization. | |
State | ConstStates::XPlus () |
Returns the +1 eigenstate of SigmaX. | |
State | ConstStates::XMinus () |
Returns the -1 eigenstate of SigmaX. | |
State | ConstStates::YPlus () |
Returns the +1 eigenstate of SigmaY. | |
State | ConstStates::YMinus () |
Returns the -1 eigenstate of SigmaY. | |
State | ConstStates::ZPlus () |
Returns the +1 eigenstate of SigmaZ. | |
State | ConstStates::ZMinus () |
Returns the -1 eigenstate of SigmaZ. | |
State | ConstStates::QubitMUBState (itype i) |
Returns the i th state from the 6-element qubit MUB set: {|0>, |1>, |+>, |->, |+i>, |-i>}. | |
State | ConstStates::QubitSICPState (itype i) |
Returns the i th state from a 4-element qubit SICPOVM chosen so that the 1st is |0>, and the 2nd is in the X-Z plane. | |
Operator | ConstStates::Jz (itype d) |
Returns the Jz (angular momentum along the z-axis) operator in d dimensions. | |
Operator | ConstStates::Jx (itype d) |
Returns the Jz (angular momentum along the z-axis) operator in d dimensions. | |
Operator | ConstStates::Jy (itype d) |
Returns the Jz (angular momentum along the z-axis) operator in d dimensions. | |
Operator | ConstStates::Jn (itype d, double x, double y, double z) |
Returns the d -dimensional angular-momentum-along-the-(x,y,z)-axis operator. | |
template<class T> | |
DenseVector< T > & | internal_tensor (const DenseVector< T > &v1, const DenseVector< T > &v2, DenseVector< T > &result, T scalar, bool overwrite) |
Internal method used to place scalar times the tensor product of v1 and v2 into result. | |
template<class T> | |
DenseVector< T > & | internal_tensor (itype N, DenseVector< T > *v_arr[], DenseVector< T > &result, T scalar, bool overwrite) |
Internal method used to place scalar times the tensor product of the first N elements of v_arr into result. | |
template<class T> | |
DenseMatrix< T > & | internal_tensor (const DenseMatrix< T > &m1, const DenseMatrix< T > &m2, DenseMatrix< T > &result, T scalar, bool overwrite) |
Internal method used to place scalar times the tensor product of m1 and m2 into result. | |
template<class T> | |
DenseMatrix< T > & | internal_tensor (itype N, DenseMatrix< T > *m_arr[], DenseMatrix< T > &result, T scalar, bool overwrite) |
Internal method used to place scalar times the tensor product of the first N elements of v_arr into result. |