GTorlai / PastaQ.jl

Package for Simulation, Tomography and Analysis of Quantum Computers
Apache License 2.0
141 stars 23 forks source link

"MPS is not normalized" when I try to `PastaQ.getsamples(ψ, bases)` #310

Open Mi-Peng opened 2 months ago

Mi-Peng commented 2 months ago

I got an error that "MPS is not normalized, norm=1.000000042243257" when I tried to PastaQ.getsamples(ψ, bases). I understand that the MPS norm should be 1, but I'm curious about the reason why the norm is not 1. Does the approximation of floating point numbers cause it, or is there something wrong with my code? In addition, the norm obtained by running my code is usually 1e-8 orders of magnitude different from 1. Could this error be larger? Thanks very much.

mtfishman commented 2 months ago

Probably the check is too strict. Can you try normalizing your MPS explicitly?

Mi-Peng commented 2 months ago

Probably the check is too strict. Can you try normalizing your MPS explicitly?

Thanks for your reply. I fix it by dividing by its norm,i.e., ψ=ψ / LinearAlgebra.norm(ψ), and then it doesn't raise any error. I'm not sure about the meaning of the check is too strict, since I didn't find something like eps in the docs. Actually, I'm curious about the reason and I can accept the current error, 1e-8, but I'm worried that this error could get larger in some extreme cases.