That sounds like a good approach for doing what you want to do. In the code above, is
phi a copy of
I am not sure why it would be seg faulting. The reason would not be that
psi.A(b) have different ordering of indices, since ITensor doesn't care what the ordering of the indices are. Could you run your code in debug mode and see if it outputs any more specific errors?
In order to help debug it would be helpful to have a minimal working example of the code that is failing.
Here is a minimal example of how this approach would work (this runs correctly for me):
auto N = 10;
auto sites = SpinHalf(N);
auto psi = MPS(sites);
auto b = 4;
// Set the center site gauge with ITensor
// Move the center gauge manually
auto lb = linkInd(psi,b);
psi.Aref(b+1) *= S*V;
linkInd(psi,b) is a shorthand for
commonIndex(psi.A(b),psi.A(b+1),Link). Also note that if you put indices only on the
V tensor, the
svd function will use those to determine how to reshape the input tensor.
Note that a more efficient alternative to using
svd, if you don't need extremely high accuracy of your singular values, is to use
denmatDecomp ( http://itensor.org/docs.cgi?page=classes/decomp ), which directly computes
T = U*B where
B = S*V.