chiark / gitweb /
Forgot to shuffle the num[] array! That was probably introducing
authorSimon Tatham <anakin@pobox.com>
Mon, 19 Feb 2007 19:38:00 +0000 (19:38 +0000)
committerSimon Tatham <anakin@pobox.com>
Mon, 19 Feb 2007 19:38:00 +0000 (19:38 +0000)
some really subtle probabilistic bias in the generated latin squares.

[originally from svn r7302]

latin.c

diff --git a/latin.c b/latin.c
index 22488a744bf66c6cf0a2bfb9ff54a3214e398fd1..2d6ae747bdc642e4fb4e795c0646a10edbe299c3 100644 (file)
--- a/latin.c
+++ b/latin.c
@@ -1092,6 +1092,7 @@ digit *latin_generate(int o, random_state *rs)
        for (j = 0; j < o; j++)
            col[j] = num[j] = j;
        shuffle(col, j, sizeof(*col), rs);
+       shuffle(num, j, sizeof(*num), rs);
        /* We need the num permutation in both forward and inverse forms. */
        for (j = 0; j < o; j++)
            numinv[num[j]] = j;