Frobenius norm of an MPO

I am looking for a function to compute the Frobenius norm of a complex MPO, i.e. the sum of squared modulus of all elements.
Thanks in advance for your help,
Sylvain

Hi Sylvain, thanks for the question. Here are some diagrams showing how I wouldcompute it, and some sample code below that should work correctly. I didn’t test it in the complex case but I did test it for a real-valued MPO.

Sample code:

auto N = 4;
auto s = SpinHalf(N);

// Make an MPO for testing:
auto ampo = AutoMPO(s);
for(int j = 1; j < N; ++j)
    {
    ampo += 0.5,"S+",j,"S-",j+1;
    ampo += 0.5,"S-",j,"S+",j+1;
    ampo +=     "Sz",j,"Sz",j+1;
    }
auto H = toMPO(ampo);

// Compute Frobenius norm:
auto F = ITensor(1.);
auto Hd = dag(prime(H,"Link")); // <-- important to prime the Links !
for(auto j : range1(N))
    {
    F *= Hd(j);
    F *= H(j);
    }
auto Fnorm = elt(F);

Print(Fnorm);