0 votes
asked by (330 points)

I'd like to create a vector of QNs in a for loop that are then used to create one Index. The relevant code in my .h defining my class ExcitonSite is

ExcitonSite(Args const& args = Args::global())
{
    int dim = args.getInt("on_site_dim", 5);
    auto ts = TagSet("Site,S="+str(dim));
    auto v = stdx::reserve_vector<Index>(2 * dim + 1);
    for (int j = -dim; j <= dim; ++j)
    {
        auto q = QN({"Sz",j});
        v.emplace_back(q, 1);
    }
    s = Index(std::move(v),Out,ts);
}

This however is throwing an error "error: no matching function for call to..." in the last line. Thoughts?

1 Answer

+1 vote
answered by (330 points)
edited by

For those who are interested, this is the solution:

   ExcitonSite(Args const& args = Args::global())
{
    dim = args.getInt("on_site_dim", 5);
    auto ts = TagSet("Site,Exciton");
    int n = args.getInt("SiteNumber");
    ts.addTags("n="+str(n));
    auto v = std::vector<std::pair<QN, long int>>(2 * dim + 1);
    int cntr = 0; 
    for (int j = -dim; j <= dim; ++j)
    {
        auto q = QN({"Sz",j});
        v.emplace_back(q, 1);
    }
    s = Index(std::move(v),Out,ts);
}
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

...