[Numpy-discussion] Adopt Mersenne Twister 64bit?

Neal Becker ndbecker2@gmail....
Thu Mar 14 05:54:18 CDT 2013


Robert Kern wrote:

> On Wed, Mar 13, 2013 at 12:16 AM, Neal Becker <ndbecker2@gmail.com> wrote:
>> I guess I talked to you about 100 years ago about sharing state between numpy
>> rng and code I have in c++ that wraps boost::random.  So is there a C-api for
>> this RandomState object I could use to call from c++?  Maybe I could do
>> something with that.
> 
> There is not one currently. Cython has provisions for sharing such
> low-level access to other Cython extensions, but I'm not sure how well
> it works for exporting data pointers and function pointers to general
> C/++ code. We could probably package the necessities into a struct and
> export a pointer to it via a PyCapsule.
> 

I did find a way to do this, and the results are good enough.  Timing is quite 
comparable to my pure c++ implementation.

I used rk_ulong from mtrand.so.  I also tried using rk_fill, but it was a bit 
slower.

The boost::python c++ code is attached, for posterity.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pn64.cc
Type: text/x-c++src
Size: 7382 bytes
Desc: not available
Url : http://mail.scipy.org/pipermail/numpy-discussion/attachments/20130314/869f1d90/attachment.bin 


More information about the NumPy-Discussion mailing list