Commit fc704be9 authored by Alvarez, Gonzalo's avatar Alvarez, Gonzalo
Browse files

Operators: clean up again

parent 2a968697
......@@ -243,19 +243,18 @@ public:
assert(operatorsPerSite_.size() > 0);
}
PairType localOperatorIndices(SizeType i,SizeType sigma) const
SizeType localOperatorIndex(SizeType i,SizeType sigma) const
{
SizeType sum = 0;
for (SizeType j=0;j<i;j++) {
assert(j<operatorsPerSite_.size());
assert(i <= operatorsPerSite_.size());
for (SizeType j = 0; j < i; ++j)
sum += operatorsPerSite_[j];
}
assert(i<operatorsPerSite_.size());
return PairType(sum + sigma,operatorsPerSite_[i]);
assert(i < operatorsPerSite_.size());
return sum + sigma;
}
const OperatorType& localOperatorByIndex(int i) const
const OperatorType& localOperator(SizeType i) const
{
return operators_.getLocalByIndex(i);
}
......@@ -325,7 +324,7 @@ private:
const SizeType nlocalOps = numberOfLocalOperators();
for (SizeType i = 0; i < nlocalOps; ++i) {
if (i<basis2.numberOfLocalOperators()) {
const OperatorType& myOp = basis2.localOperatorByIndex(i);
const OperatorType& myOp = basis2.localOperator(i);
bool isFermion = (myOp.fermionOrBoson() ==
ProgramGlobals::FermionOrBosonEnum::FERMION);
if (savedSign != myOp.fermionOrBoson() || fermionicSigns.size() == 0) {
......@@ -344,7 +343,7 @@ private:
} else {
const OperatorType& myOp = basis3.
localOperatorByIndex(i - basis2.numberOfLocalOperators());
localOperator(i - basis2.numberOfLocalOperators());
bool isFermion = (myOp.fermionOrBoson() ==
ProgramGlobals::FermionOrBosonEnum::FERMION);
......
......@@ -107,15 +107,12 @@ private:
SizeType i,
SizeType sigma) const
{
PairSizeType ii;
if (type == ProgramGlobals::SysOrEnvEnum::SYSTEM) {
ii = lrs_.left().localOperatorIndices(i, sigma);
} else {
assert(type == ProgramGlobals::SysOrEnvEnum::ENVIRON);
ii = lrs_.right().localOperatorIndices(i, sigma);
}
assert(type == ProgramGlobals::SysOrEnvEnum::SYSTEM ||
type == ProgramGlobals::SysOrEnvEnum::ENVIRON);
return ii.first;
return (type == ProgramGlobals::SysOrEnvEnum::SYSTEM) ?
lrs_.left(). localOperatorIndex(i, sigma) :
lrs_.right().localOperatorIndex(i, sigma);
}
PairSizeType finalIndices4sites(const VectorSizeType& hItems) const
......
......@@ -59,10 +59,10 @@ public:
const OperatorStorageType* m = 0;
if (type == ProgramGlobals::SysOrEnvEnum::SYSTEM) {
m = &(lrs_.left().localOperatorByIndex(iifirst).getStorage());
m = &(lrs_.left().localOperator(iifirst).getStorage());
} else {
assert(type == ProgramGlobals::SysOrEnvEnum::ENVIRON);
m =&(lrs_.right().localOperatorByIndex(iifirst).getStorage());
m =&(lrs_.right().localOperator(iifirst).getStorage());
}
m->checkValidity();
......
......@@ -9,6 +9,8 @@ class PrinterInDetail {
typedef typename LeftRightSuperType::BasisWithOperatorsType BasisWithOperatorsType;
typedef typename BasisWithOperatorsType::QnType QnType;
typedef typename BasisWithOperatorsType::OperatorsType OperatorsType;
typedef typename OperatorsType::OperatorType OperatorType;
public:
......@@ -57,11 +59,10 @@ private:
os<<"Operators at site "<<site<<" ("<<siteC<<")\n";
for (SizeType sigma = 0; sigma < end; ++sigma) {
typename BasisWithOperatorsType::PairType p = basis.localOperatorIndices(siteC,
sigma);
const OperatorType& myop = basis.localOperator(basis.localOperatorIndex(siteC,
sigma));
os<<sigma<<" non-zeroes=";
os<<basis.localOperatorByIndex(p.first).getStorage().nonZeros();
os<<" rows="<<basis.localOperatorByIndex(p.first).getStorage().rows()<<"\n";
os<<myop.getStorage().nonZeros()<<" rows="<<myop.getStorage().rows()<<"\n";
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment