From b750a675b29defac3b8de7c34623e8bcd9e2c83f Mon Sep 17 00:00:00 2001 From: augustss Date: Wed, 2 Feb 2005 11:22:42 +0000 Subject: Fix a bug in quantum_measure() that returns the wrong state when measuring a quantum register. --- misc/libquantum/distinfo | 3 ++- misc/libquantum/patches/patch-aa | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 misc/libquantum/patches/patch-aa (limited to 'misc') diff --git a/misc/libquantum/distinfo b/misc/libquantum/distinfo index 68d105bcfe8..ed8f59a7277 100644 --- a/misc/libquantum/distinfo +++ b/misc/libquantum/distinfo @@ -1,4 +1,5 @@ -$NetBSD: distinfo,v 1.1 2005/02/01 20:52:38 augustss Exp $ +$NetBSD: distinfo,v 1.2 2005/02/02 11:22:42 augustss Exp $ SHA1 (libquantum-0.2.4.tar.gz) = dbd76434b7d4026db96aedcd16ae4cd01fb341cd Size (libquantum-0.2.4.tar.gz) = 211403 bytes +SHA1 (patch-aa) = 734170cbc1a30815e89311f0a2d2df5a8d30b3d2 diff --git a/misc/libquantum/patches/patch-aa b/misc/libquantum/patches/patch-aa new file mode 100644 index 00000000000..e6ef630fead --- /dev/null +++ b/misc/libquantum/patches/patch-aa @@ -0,0 +1,36 @@ +*** measure.c.old Tue Jan 11 22:12:21 2005 +--- measure.c Wed Feb 2 12:17:54 2005 +*************** +*** 39,45 **** + double + quantum_frand() + { +! return (double) rand() / RAND_MAX; + } + + /* Measure the contents of a quantum register */ +--- 39,45 ---- + double + quantum_frand() + { +! return (double) random() / RAND_MAX; + } + + /* Measure the contents of a quantum register */ +*************** +*** 64,70 **** + result. Otherwise, continue with the next base state. */ + + r -= quantum_prob_inline(reg.node[i].amplitude); +! if(quantum_prob_inline(reg.node[i].amplitude) >= r) + return reg.node[i].state; + } + +--- 64,70 ---- + result. Otherwise, continue with the next base state. */ + + r -= quantum_prob_inline(reg.node[i].amplitude); +! if(0 >= r) + return reg.node[i].state; + } + -- cgit v1.2.3