How to extract the MPS coefficients of an Electron siteset


I’m writing a snippet for extracting the coefficients of an MPS with siteset Electron by following this tutorial. Here it is my attempt:

double get_MPS_coefficient(MPS psi,
                           Electron sites,
                           std::vector<std::string> conf)

// args: psi MPS representing the state psi= \sum c_gamma |gamma>
// conf is a vector of length(psi) containing the indices of the MPS |gamma> to extract: ex: configurations = [Up, Dn, Up, Dn] if length(psi) = 4
// return: coefficients c_gamma

    int N = length(psi);
	auto coeff = ITensor(1.);
    for(auto j : range1(N))
    // sites(j, conf[j-1]) is an IndexVal representing the index of site(j) 
    // corresponding to the internal state given by conf[j-1] \in {Emp, Up, Dn, UpDn}
    // setElt(IndexVal) initializes a zero tensor with an element equal to 1
    // at the index position given by the ival

	IndexVal ival = dag(sites(j, el[j-1]));
    coeff *= psi(j) * setElt(ival);


    double val_coeff = elt(coeff);

    return val_coeff;

However, I am having some troubles in understanding what is the implicit order that is assumed for the fermionic operators, because some of the coefficients that I get by an exact diagonalization have flipped signs wrt the ones I get with code above and this is not an overall minus.

My guess is that something like the following happens:

Suppose I construct a state as |\psi\rangle = c^\dag_{1\uparrow} c^\dag_{2\downarrow} |0\rangle.

If I assume that my operators are ordered with increasing indices and \uparrow < \downarrow, then the coefficient in the expansions of |\psi\rangle will be +1, but if I assume a different ordering the coefficient might be -1.

Thanks a lot for any insights/help in advance!

Hi Davide,
Good question because fermions and tensor networks can be a subtle thing. Here is an answer that I think could clear things up for you.

You should think of the MPS as representing a tensor of amplitudes in a certain basis, where the basis handles all of the fermionic antisymmetry implicitly, so that the tensor elements can have any sign or value and still represent a valid fermionic state. Specifically, the state is of the form:

\ket{\Psi} = \sum_{i_1 i_2 i_3 i_4} \Psi^{i_1 i_2 i_3 i_4} \ket{i_1 i_2 i_3 i_4}

and the MPS is a tensor network representation of the tensor \Psi^{i_1 i_2 i_3 i_4} and for electrons the indices run over the values i_n = 1,2,3,4.

Then, to map this to the usual fermionic representation you’re used to, you can use the following definition of the basis states \ket{i_1 i_2 i_3 i_4}:

\ket{i_1 i_2 i_3 i_4} = \hat{D}_{i_1} \hat{D}_{i_2} \hat{D}_{i_3} \hat{D}_{i_4} \ket{0}


\hat{D}_1 = \hat{I} \\ \hat{D}_2 = \hat{c}^\dagger_\uparrow \\ \hat{D}_3 = \hat{c}^\dagger_\downarrow \\ \hat{D}_4 = \hat{c}^\dagger_\uparrow \hat{c}^\dagger_\downarrow

Does that help answer your question? So in a specific case, if your el vector is {1,1,2,3} the amplitude you’d be computing is \Psi^{1,1,2,3} and it would be the one that corresponds to the basis state

\hat{I}_1 \hat{I}_2 \hat{c}^\dagger_{\uparrow, 2} \hat{c}^\dagger_{\downarrow,3} \ket{0} = \hat{c}^\dagger_{\uparrow, 2} \hat{c}^\dagger_{\downarrow,3} \ket{0}

Hi Miles,

thanks! That is exactly what I was looking for. Thanks for clarifying that.

Thanks also for the whole ITensor project.



Hi Davide,
Great – I hope it helps to check things against the ED calculation & that I’m not off by a sign anywhere, but the above should be correct.

Appreciate the positive feedback!