|
From: | Juergen Sauermann |
Subject: | Re: [Bug-apl] RNG |
Date: | Wed, 18 May 2016 18:39:28 +0200 |
User-agent: | Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 |
Hi, does not work because Xiao-Yong is looking for a portable solution. A simple and fast - although not portable - solution is this: 1. write your favourite RNG in C/C++ (ie. copy the source code from Numerical Recipes and write the random number, say 8 bytes each, to stdout, 2. popen() the C/C++ program with ⎕FIO like: Handle←⎕FIO[24] 'path-to-the-C-program' Every chunk of 8 bytes fread() with, say, 256⊥8 ⎕FIO[6] Handle will then be one (signed) random number. You can also read several random numbers in one go). The above essentially pipes the output of your C/C++ RND directly into GNU APL. The code below will probably run faster if you can avoid to convert between integers and bit vectors too often (like in bit∆mult) and pre-compute constants like (⌽¯1+⍳64) beforehand. /// Jürgen On 05/18/2016 05:44 PM, Elias Mårtenson
wrote:
|
[Prev in Thread] | Current Thread | [Next in Thread] |