https://github.com/ITensor/ITensor
Tip revision: e2c6ea98c5d68dee7ad38c16a7f71574a46589e0 authored by Miles Stoudenmire on 20 August 2015, 19:47:53 UTC
Shortened some type names in cplx_literal.h and names of constants in global.h
Shortened some type names in cplx_literal.h and names of constants in global.h
Tip revision: e2c6ea9
qcounter.h
//
// Distributed under the ITensor Library License, Version 1.1.
// (See accompanying LICENSE file.)
//
#ifndef __ITENSOR_QCOUNTER_H
#define __ITENSOR_QCOUNTER_H
#include "counter.h"
#include "iqindex.h"
#define Cout std::cout
#define Endl std::endl
namespace itensor {
//
// QCounter
//
class QCounter : public Counter
{
public:
QCounter(const std::vector<IQIndex>& v)
{
rn = v.size();
r = rn;
n[0] = 0;
for(int j = 0; j < rn; ++j)
n[j+1] = v[j].nindex();
for(int j = rn+1; j <= NMAX; ++j)
n[j] = 1;
reset();
}
QCounter(const IndexSet<IQIndex>& is)
{
rn = is.rn();
r = is.r();
n[0] = 0;
for(int j = 1; j <= rn; ++j)
n[j] = is.index(j).nindex();
for(int j = rn+1; j <= NMAX; ++j)
n[j] = 1;
reset();
}
int
getVecInd(const std::vector<IQIndex>& origv,
std::vector<Index>& vind, QN& q) const
{
int pos = 0,
dim = 1;
const int size = origv.size();
vind.resize(size);
q = QN();
for(int k = 0; k < size; ++k)
{
const IQIndex& I = origv[k];
const int j = i[k+1];
vind[k] = I[j];
q += I.qn(1+j)*I.dir();
pos += dim*j;
dim *= I.nindex();
}
return pos;
}
};
} //namespace itensor
#undef Cout
#undef Endl
#endif