+1 vote
asked by (170 points)

Hello,

I use the function .svdBond() and would like to obtain the truncation error. According to the documentation of this function, .svdBond() should return the corresponding spectrum containing information about the truncation error. However, I receive the error message "no match for ‘operator=’ (operand types are ‘itensor::Spectrum’ and ‘void’)", which indicates that .svdBond() does nor return any value. I suspect that I am missing something obvious but cannot resolve this problem.

Could you please help me with this problem?

Walter

commented by (480 points)
Can you post the code (or some minimal example of it)?
commented by (70.1k points)
Thanks Jared - agreed: Walter I looked at all the definitions for svdBond and they do or should return a Spectrum object. So yes please do post a minimal code example, as the issue may be due to something else.

Miles
commented by (170 points)
Hi Jared and Miles,

thank you for offering help. Please find below the relevant code. It is a function based on gateTEvol with some minor changes. When leaving out the definition "itensor::Spectrum spctr;" and not using spctr later, the code compiles and runs properly. When trying to compile when using spctr, the first error message is "error: no match for ‘operator=’ (operand types are ‘itensor::Spectrum’ and ‘void’)
   41 |                     spctr = rho.svdBond(i1,AA,Fromleft,args);"

Here is the code:

#include "itensor/mps/mpo.h"
#include "itensor/mps/bondgate.h"
#include "itensor/mps/TEvolObserver.h"

inline void gateTEvolMPO_spctr(std::vector<BondGate> const& gatelist,
          Real ttotal,
          Real tstep,
          MPO & rho,
          Args args)
    {
    const int nt = int(ttotal/tstep+(1e-9*(ttotal/tstep)));  
    itensor::Spectrum spctr;
    
    rho.position(gatelist.front().i1());

    int i1, i2, ni1, ni2;
    ITensor AA;
    for(auto tt : range1(nt))
        {
        auto g = gatelist.begin();
        while(g != gatelist.end())
            {
            i1 = g->i1();
            i2 = g->i2();
            AA = rho(i1)*rho(i2)*prime(g->gate());
            AA *= swapTags(conj(g->gate()),"Site,1","Site,0");
            AA.replaceTags("Site,1","Site,0");
            AA.replaceTags("Site,2","Site,1");

            ++g;
            if(g != gatelist.end())
                {
                //Look ahead to next gate position
                ni1 = g->i1();
                ni2 = g->i2();
                //SVD AA to restore MPO form
                //before applying current gate
                if(ni1 >= i2)
                    {
                    spctr = rho.svdBond(i1,AA,Fromleft,args);
                    rho.position(ni1); //does no work if position already ni1
                    }
                else
                    {
                    spctr = rho.svdBond(i1,AA,Fromright,args);
                    rho.position(ni2); //does no work if position already ni2
                    }
                }
            else
                {
                //No next gate to analyze, just restore MPO form
                spctr = rho.svdBond(i1,AA,Fromright,args);
                }
            }
        }
    } // gateTEvolMPO

Please log in or register to answer this question.

Welcome to ITensor Support Q&A, where you can ask questions and receive answers from other members of the community.

Formatting Tips:
  • To format code, indent by four spaces
  • To format inline LaTeX, surround it by @@ on both sides
  • To format LaTeX on its own line, surround it by $$ above and below
  • For LaTeX, it may be necessary to backslash-escape underscore characters to obtain proper formatting. So for example writing \sum\_i to represent a sum over i.
If you cannot register due to firewall issues (e.g. you cannot see the capcha box) please email Miles Stoudenmire to ask for an account.

To report ITensor bugs, please use the issue tracker.

Categories

...