Hello!
If I write
for(int i = L-1; i >= 1; --i)
{
auto hterm = sites.op("Adag",i)*sites.op("A",i+1);
hterm += sites.op("A",i)*sites.op("Adag",i+1);
auto g = Gate(sites,i,i+1,Gate::tReal,tstep/2.,hterm);
gates.push_back(g);
}
it is OK, but if I write
for(int i = L-1; i >= 1; --i)
{
if (i % 2 == 0)
{
auto hterm = sites.op("Adag",i)*sites.op("A",i+1);
hterm += sites.op("A",i)*sites.op("Adag",i+1);
}
else
{
auto hterm = 2.0*sites.op("Adag",i)*sites.op("A",i+1);
hterm += 2.0*sites.op("A",i)*sites.op("Adag",i+1);
}
auto g = Gate(sites,i,i+1,Gate::tReal,tstep/2.,hterm);
gates.push_back(g);
}
It says
error: no declaration of the variable «hterm»
auto g = Gate(sites,i,i+1,Gate::tReal,tstep/2.,hterm);
But the following snippet gives "ITensorT::operator+=: different index structure
"
for(int i = L-1; i >= 1; --i)
{
if (i % 2 == 0)
{
auto hterm = sites.op("Adag",i)*sites.op("A",i+1);
hterm += sites.op("A",1)*sites.op("Adag",i+1);
auto g = Gate(sites,i,i+1,Gate::tReal,tstep/2.,hterm);
gates.push_back(g);
}
else
{
auto hterm = 2.0*sites.op("Adag",i)*sites.op("A",i+1);
hterm += 2.0*sites.op("A",i)*sites.op("Adag",i+1);
auto g = Gate(sites,i,i+1,Gate::tReal,tstep/2.,hterm);
gates.push_back(g);
}
How one can curcumvent this issue? I need different hamiltonians for even and odd i