[Numpy-svn] r3642 - trunk/numpy/random/mtrand

numpy-svn@scip... numpy-svn@scip...
Mon Apr 2 07:08:36 CDT 2007


Author: cookedm
Date: 2007-04-02 07:08:34 -0500 (Mon, 02 Apr 2007)
New Revision: 3642

Modified:
   trunk/numpy/random/mtrand/randomkit.c
Log:
Fixes #488. In rk_interval, use rk_random if the interval size is less than 2**32.
For 64-bit machines, this means results will agree with 32-bit machines,
and will be faster for these interval sizes (one less rk_random evaluation).


Modified: trunk/numpy/random/mtrand/randomkit.c
===================================================================
--- trunk/numpy/random/mtrand/randomkit.c	2007-04-02 12:06:06 UTC (rev 3641)
+++ trunk/numpy/random/mtrand/randomkit.c	2007-04-02 12:08:34 UTC (rev 3642)
@@ -248,7 +248,15 @@
 #endif
 
 	/* Search a random value in [0..mask] <= max */
+#if ULONG_MAX > 0xffffffffUL
+	if (max <= 0xffffffffUL) {
+		while ((value = (rk_random(state) & mask)) > max);
+	} else {
+		while ((value = (rk_ulong(state) & mask)) > max);
+	}
+#else
 	while ((value = (rk_ulong(state) & mask)) > max);
+#endif
 
 	return value;
 }



More information about the Numpy-svn mailing list