https://github.com/ITensor/ITensor
Tip revision: 127526447e9a22be1b847ff5703fd80b055e0941 authored by Miles Stoudenmire on 07 July 2016, 15:45:24 UTC
Made SiteSet operator string parsing recursive, now supports "A*B*C*D*..."
Made SiteSet operator string parsing recursive, now supports "A*B*C*D*..."
Tip revision: 1275264
qcounter.h
//
// Distributed under the ITensor Library License, Version 1.1.
// (See accompanying LICENSE file.)
//
#ifndef __ITENSOR_QCOUNTER_H
#define __ITENSOR_QCOUNTER_H
#include "itensor/counter.h"
#include "itensor/iqindex.h"
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
#endif