Implementation of random_permutation



Hi,

In our work, we make quite a lot of use of functions such as
random_permutation for various experiments. In certain instances where
performance is a big issue, we'd like to implement parts of the system
in C++. However, we'd like to make sure that anything we write matches
up with what we have at the Maxima level.

To be able to do this, we need to know how the function
random_permutation works to be able to replicate it in C++. The C++
standard has a std::random_shuffle and the boost library offers random
number generators utilising the Mersenne twister (which the
documentation suggests is used for the Maxima random number
generator), so it seems it should be easy, however, it's not clear
exactly how Maxima extracts integers from the state of the Mersenne
twister, or precisely the implementation of the random_permutation
function even if the random number generation were the same.

Could anyone point me to some relevant documentation or maybe point me
to some code for how these are implemented?

Thanks!

Matthew Gwynne
http://cs.swan.ac.uk/~csmg/

P.S - As a note, in the coming C++ standard there will be random
number generators and so on guaranteed by the standard library, and so
it might make sense if simply using std::random_shuffle with the
standard number generator yielded the same results as
random_permutation in Maxima? This would make a description of the
behaviour in the documentation very simple, as one could just point to
the more elaborated C++ standard.