Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AutoMPO concat function for local operators #229

Open
wants to merge 1 commit into
base: v2
Choose a base branch
from

Conversation

ryanlevy
Copy link

Addressing #219 and this forum post, this provides a concatenation function for local operators and AutoMPO

Usage:

auto ampo = AutoMPO(sites);

//loop in a function
for(auto n: range1(N))
   ampo.concat("Sz",n);
ampo.combine(); //done concating, does the += step

//For coefficients and a function
Real J = -1.7;
//same as ampo += J,"Sz",1,"Sz",2,"Sz",3;
ampo.concat(J);
for(auto n: range1(3))
    ampo.concat("Sz",n);
ampo.combine();

//don't like the comma operator? This works too
//same as ampo += 3.14,"Nup",2,"Ndn",4,"Nupdn",7";
ampo.concat(3.14,"Nup",2)
    .concat("Ndn",4,"Nupdn",7) //takes any number of arguments
    .combine();

Caveat: only one concat sequence is allowed at a time.

I'm not 100% in love with the names, so please feel free to suggest alternatives.

@dkweiss31
Copy link

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants