X-Git-Url: https://s3miclassical.com/gitweb/?p=strong_simulation_stabilizer_rank.git;a=blobdiff_plain;f=test.bash;h=fdf3b8a37fcc48b1ff212e7ad787bfc15d1c4a47;hp=243d0991da0eff632ca5298d4ca593ce7d61ef66;hb=bce2108bbb4eada26cfe1561a5f0b06528ab470c;hpb=2bcc6f0ade1d894dcb6fd0122911fdd41fe459a6 diff --git a/test.bash b/test.bash index 243d099..fdf3b8a 100644 --- a/test.bash +++ b/test.bash @@ -7,7 +7,9 @@ numqubits=6 numTgates=6 -numruns=20 +threshold=0.005 # absolute value threshold difference between computed and exact value + +numruns=100 echo "Starting test of $numruns random $numqubits-Pauli expectation values..." for i in $(seq 1 $numruns) @@ -17,15 +19,24 @@ sleep 1;a=$(stdbuf -oL ./randominputPauli $numqubits $numTgates > inputfullPauli b=$(stdbuf -oL ./multipauli < inputfullPauli.txt | tail -n1) are=$(echo "$a" | cut -f 1 -d " " | cut -c 1-5); aim=$(echo "$a" | cut -f 3 -d " " | cut -c 1-5); aimsign=$(echo $a | cut -f 2 -d " "); bimsign=$(echo $b | cut -f 2 -d " "); -echo $aimsign; bre=$(echo "$b" | cut -f 1 -d " " | cut -c 1-5); -bim=$(echo "$b" | cut -f 3 -d " " | cut -c 1-5); echo "$i: $are $aimsign $aim and $bre $bimsign $bim" -if [ "$are" == "$bre" ] && [ "$aim" == "$bim" ] && [ "$aimsign" == "$bimsign" ] +bim=$(echo "$b" | cut -f 3 -d " " | cut -c 1-5); +c=$( printf 'scale=5; (%.5f)^2 + (%.5f)^2\n' "$are" "$aim" | bc -l ) +echo "$i: $are $aimsign $aim and $bre $bimsign $bim" +rediff=$( printf 'sqrt((%f - %f)^2)\n' "$are" "$bre" | bc -l ) +imdiff=$( printf 'sqrt((%f - %f)^2)\n' "$aim" "$bim" | bc -l ) +if (( $(echo "$rediff < $threshold" |bc -l) )) && (( $(echo "$imdiff < $threshold" |bc -l) )) then -continue -else -echo "NOT EQUAL!" -break + if (( $(echo "$bim < $threshold" |bc -l) )) || [ "$aimsign" == "$bimsign" ] + then + continue + else + echo "NOT EQUAL!" + exit + fi + else + echo "NOT EQUAL!" + exit fi done echo "Test passed!"