29      std::vector < std::vector < Complex > >  B;
 
   32        Complex innerProduct(std::vector<Complex>& a, std::vector<Complex>& b)
 
   34            Complex sum = 0 + 0*I;
 
   36            for(
unsigned int i=0; i<a.size(); ++i)
 
   39                c = creal(b[i]) - cimag(b[i])*I;
 
   47        double norm(std::vector <Complex>& a)
 
   51            for(
unsigned int i=0; i<a.size(); ++i)
 
   54                c = creal(a[i]) - cimag(a[i])*I;
 
   69            for(
int i=0; i<n; ++i)
 
   81            for(
unsigned int i=0; i<ket.size(); ++i)
 
   85        void print(std::ostream& f)
 
   87          f << 
"(" << creal(p) << 
"+" << cimag(p) << 
"i)|";
 
   88            for(
unsigned int i=0; i<ket.size(); ++i)
 
   91            for(
unsigned int i=0; i<bra.size(); ++i)
 
   96        Complex trace(std::vector <Basis>& basis);
 
   99        std::vector <int> ket, bra;
 
  108        void applyOp(
int space);    
 
  109        void applyOp(
int startSpace, 
int endSpace);
 
  111        void applyOp(
int space1, 
int space2, 
Basis& op);
 
  112        void applyOp(
int space1, 
int space2, 
int space3, 
Basis& op);
 
  117        void applyConditionalOp(
int condSpace, 
int cond, 
int space, 
algebra::mat& U);
 
  119        void swap(
int space1, 
int space2);
 
  120        void measureAndSave(
int measureSpace, 
int saveSpace);
 
  121        void measure(
int measureSpace);
 
  123        double SafeLog(
double x)
 
  127          return log(x) / log(2.0);
 
  129        double ShannonEntropy(); 
 
  132        double calculatePr(
int measureSpace, 
int state);
 
  133        double calculatePr(
int space1, 
int state1, 
int space2, 
int state2);
 
  134        double calculatePr(
const std::vector <int>& spaceList, 
const std::vector <int>& stateList);
 
  137        void splitAndSave(
double p1, 
double p2, 
int space);
 
  140        void computeDensityMat(std::vector <Basis>& basis, 
algebra::mat& output);
 
  144        void trace(
int space);
 
  146        void project(
int space, 
int state, 
DensityList& output);
 
  147        void project(
int space, 
int state);
 
  148        void CNOT(
int controlSpace, 
int targetSpace);
 
  151        void applyHadamard(
int space);
 
  152        void applyRotation(
int space, 
double rotation);
 
  153        void applySU2(
int space, 
double p, 
double theta, 
double psi);
 
  157        void applyHadamard(
int target, 
int control);
 
  158        void applyNOT(
int target, 
int control);
 
  159        void applyPiOver8(
int target, 
int control);
 
  160        void applySU2(
int target, 
int control, 
double p, 
double theta, 
double psi);
 
  164        void conditionalSet(std::vector <int>& targetSpace, std::vector <int>& targetVal, std::vector <int>& condSpace, std::vector <int>& condVal);
 
  166        void print(std::ostream& f)
 
  168            std::list <KetBra>::iterator Iter;
 
  170            for(Iter = density.begin(); Iter != density.end(); ++Iter)
 
  172              if(creal(Iter->p) == 0 && cimag(Iter->p) == 0) 
continue;
 
  182        std::vector <int> dimension;
 
  183        std::list <KetBra> density;
 
void computeDensityMatFast(algebra::mat &output)