From: Lucas K Date: Wed, 17 Mar 2021 22:59:55 +0000 (-0700) Subject: test bash script comparison logic between algorithm and trivial Hilbert space impleme... X-Git-Url: https://s3miclassical.com/gitweb/?a=commitdiff_plain;h=235837976a2d4e9f6c0497589bc1e0506b7265fb;p=strong_simulation_stabilizer_rank.git test bash script comparison logic between algorithm and trivial Hilbert space implementation fixed --- diff --git a/test.bash b/test.bash index 841e28f..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) @@ -18,13 +20,23 @@ 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 " "); 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!" -exit + 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!"