Dear community,
The problem I have in hand is: I have three MPS, |\psi1>, |\psi2>, |\psi3>, with length 2*N, N, N, respectively. I want to contract the first N index of |\psi1> with |\psi2>, and the second N index with |\psi3>.
I had a solution for the small system, which requires me to change the data type from MPS to ITensor, since I cannot multiply MPS using innerC
with different size. Here is my code:
// Change the data type, so that we can perform contraction
ITensor mpsToTensor(MPS & psi0){
ITensor psi = psi0.A(1);
int N = length(psi0);
for (int j=2; j <=N; ++j){
psi *= psi0.A(j);
}
return psi;
}
This works for small system. But when I tried N=20, it throws error terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
.
Do you have a smarter way to perform this task that won't cause this error? I am thinking about making a big MPS by combining |\psi2> and |\psi3>, but haven't found a way to do this.
Many thanks,
Yuhan