Re: bigloo-4.5a, release time

Joseph Donaldson <[email protected]> Sat, 5 Nov 2022 00:31:03 +0000 (UTC)
Newsgroups gmane.lisp.scheme.bigloo
Message-ID <[email protected]>
------=_Part_144793_1204469869.1667608263874
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

 Hello, Manuel,
I noted another peculiarity with 4.5a in regards to srfi27. The random-sour=
ce-make-integers creates a generator that always returns bignums even if th=
e range is well within a fixnum. I was able to correct this by altering mrg=
32k3a-c.srfi so that the gambit optimization declarations were translated i=
nto bigloo type declarations and flonum specific arithmetic operations. My =
changes are below. Is this something that we can include in 4.5a?
Thanks,Joe





; 54-BIT FLONUM IMPLEMENTATION OF THE "MRG32K3A"-GENERATOR
; =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D
;
; [email protected], 2002.
;
; This code is a floating point implementation in Scheme of Pierre L'Ecuyer=
's=20
; MRG32k3a generator. The implementation runs under the Gambit 3.0 Scheme
; system. It makes use of Gambit's f64vector. The code is based on Brad
; Lucier's code for this generator. Please refer to Brad's original posting
; in the SRFI-27 discussion archive and to his posting of an optimization.
;
; compliance:
;=C2=A0=C2=A0 Scheme R5RS with flonums covering at least {-2^53..2^53-1} ex=
actly.
;=C2=A0=C2=A0 In addition: declare f64vector ##fixnum?
;
; loading this file into Gambit 3.0:
;=C2=A0=C2=A0 (load "mrg32k3a-2.scm")
;
; history of this file:
;=C2=A0=C2=A0 SE, 18-Mar-2002: initial version
;=C2=A0=C2=A0 SE, 25-Mar-2002: adapted to new interface
;=C2=A0=C2=A0 SE, 04-Apr-2002: debugged; simplified
;=C2=A0=C2=A0 SE, 10-Apr-2002: incorporated Brad Lucier's optimizations

; the actual generator

(define (mrg32k3a-random-m1 state) ; from Brad Lucier
=C2=A0 (let* ((x10 (-fl (*fl 1403580.0 (f64vector-ref state 1))=20
=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 (*fl 810728.0 (f64vector-ref state 2=
))))
=C2=A0=C2=A0 =C2=A0 (y10 (-fl x10 (*fl (floorfl (/fl x10 4294967087.0)) 429=
4967087.0)))
=C2=A0=C2=A0 =C2=A0 (x20 (-fl (*fl 527612.0 (f64vector-ref state 3))=20
=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 (*fl 1370589.0 (f64vector-ref state =
5))))
=C2=A0=C2=A0 =C2=A0 (y20 (-fl x20 (*fl (floorfl (/fl x20 4294944443.0)) 429=
4944443.0)))
=C2=A0=C2=A0 =C2=A0 (dx (-fl y10 y20))
=C2=A0=C2=A0 =C2=A0 (dy (-fl dx (*fl (floorfl (/fl dx 4294967087.0)) 429496=
7087.0))))
=C2=A0=C2=A0=C2=A0 (f64vector-set! state 5 (f64vector-ref state 4))
=C2=A0=C2=A0=C2=A0 (f64vector-set! state 4 (f64vector-ref state 3))
=C2=A0=C2=A0=C2=A0 (f64vector-set! state 3 y20)
=C2=A0=C2=A0=C2=A0 (f64vector-set! state 2 (f64vector-ref state 1))
=C2=A0=C2=A0=C2=A0 (f64vector-set! state 1 (f64vector-ref state 0))
=C2=A0=C2=A0=C2=A0 (f64vector-set! state 0 y10)
=C2=A0=C2=A0=C2=A0 dy))

; interface to 'random.scm'

(define (mrg32k3a-pack-state unpacked-state)
=C2=A0 (list->f64vector (map exact->inexact (vector->list unpacked-state)))=
)

(define (mrg32k3a-unpack-state state)
=C2=A0 (list->vector (map inexact->exact (f64vector->list state))))

(define (mrg32k3a-random-range::obj)
=C2=A0 (if (fixnum? 4294967087)
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 4294967087
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 536870911)) ; 2^29-1

(define (mrg32k3a-random-integer::long state range::long) ; from Brad Lucie=
r
=C2=A0=C2=A0 (let* ((n::double (fixnum->flonum range))
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (q::double (floorfl =
(/fl 4294967087.0 n)))
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (qn::double (*fl q n=
)))
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (do ((x::double (mrg32k3a-random-m1 state) (=
mrg32k3a-random-m1 state)))
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ((<fl x qn)=20
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (flonum->fixnu=
m (floorfl (/fl x q)))))))

(define (mrg32k3a-random-real state)
=C2=A0 (*fl 0.0000000002328306549295728 (+fl 1.0 (mrg32k3a-random-m1 state)=
)))


------=_Part_144793_1204469869.1667608263874
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<html><head></head><body><div class=3D"ydp9e13b2abyahoo-style-wrap" style=
=3D"font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:13px=
;"><div></div>
        <div dir=3D"ltr" data-setdir=3D"false">Hello, Manuel,</div><div dir=
=3D"ltr" data-setdir=3D"false"><br></div><div dir=3D"ltr" data-setdir=3D"fa=
lse">I noted another peculiarity with 4.5a in regards to srfi27. The random=
-source-make-integers creates a generator that always returns bignums even =
if the range is well within a fixnum. I was able to correct this by alterin=
g mrg32k3a-c.srfi so that the gambit optimization declarations were transla=
ted into bigloo type declarations and flonum specific arithmetic operations=
. My changes are below. Is this something that we can include in 4.5a?</div=
><div dir=3D"ltr" data-setdir=3D"false"><br></div><div dir=3D"ltr" data-set=
dir=3D"false">Thanks,</div><div dir=3D"ltr" data-setdir=3D"false">Joe<br></=
div><div dir=3D"ltr" data-setdir=3D"false"><br></div><div dir=3D"ltr" data-=
setdir=3D"false"><br></div><div dir=3D"ltr" data-setdir=3D"false"><br></div=
><div dir=3D"ltr" data-setdir=3D"false"><br></div><div dir=3D"ltr" data-set=
dir=3D"false"><br></div><div dir=3D"ltr" data-setdir=3D"false"><div>; 54-BI=
T FLONUM IMPLEMENTATION OF THE "MRG32K3A"-GENERATOR<br>; =3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
<br>;<br>; [email protected], 2002.<br>;<br>; This code is a floa=
ting point implementation in Scheme of Pierre L'Ecuyer's <br>; MRG32k3a gen=
erator. The implementation runs under the Gambit 3.0 Scheme<br>; system. It=
 makes use of Gambit's f64vector. The code is based on Brad<br>; Lucier's c=
ode for this generator. Please refer to Brad's original posting<br>; in the=
 SRFI-27 discussion archive and to his posting of an optimization.<br>;<br>=
; compliance:<br>;&nbsp;&nbsp; Scheme R5RS with flonums covering at least {=
-2^53..2^53-1} exactly.<br>;&nbsp;&nbsp; In addition: declare f64vector ##f=
ixnum?<br>;<br>; loading this file into Gambit 3.0:<br>;&nbsp;&nbsp; (load =
"mrg32k3a-2.scm")<br>;<br>; history of this file:<br>;&nbsp;&nbsp; SE, 18-M=
ar-2002: initial version<br>;&nbsp;&nbsp; SE, 25-Mar-2002: adapted to new i=
nterface<br>;&nbsp;&nbsp; SE, 04-Apr-2002: debugged; simplified<br>;&nbsp;&=
nbsp; SE, 10-Apr-2002: incorporated Brad Lucier's optimizations<br><br>; th=
e actual generator<br><br>(define (mrg32k3a-random-m1 state) ; from Brad Lu=
cier<br>&nbsp; (let* ((x10 (-fl (*fl 1403580.0 (f64vector-ref state 1)) <br=
>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; (*fl 810728.0 (f64vector-ref state =
2))))<br>&nbsp;&nbsp; &nbsp; (y10 (-fl x10 (*fl (floorfl (/fl x10 429496708=
7.0)) 4294967087.0)))<br>&nbsp;&nbsp; &nbsp; (x20 (-fl (*fl 527612.0 (f64ve=
ctor-ref state 3)) <br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; (*fl 1370589.=
0 (f64vector-ref state 5))))<br>&nbsp;&nbsp; &nbsp; (y20 (-fl x20 (*fl (flo=
orfl (/fl x20 4294944443.0)) 4294944443.0)))<br>&nbsp;&nbsp; &nbsp; (dx (-f=
l y10 y20))<br>&nbsp;&nbsp; &nbsp; (dy (-fl dx (*fl (floorfl (/fl dx 429496=
7087.0)) 4294967087.0))))<br>&nbsp;&nbsp;&nbsp; (f64vector-set! state 5 (f6=
4vector-ref state 4))<br>&nbsp;&nbsp;&nbsp; (f64vector-set! state 4 (f64vec=
tor-ref state 3))<br>&nbsp;&nbsp;&nbsp; (f64vector-set! state 3 y20)<br>&nb=
sp;&nbsp;&nbsp; (f64vector-set! state 2 (f64vector-ref state 1))<br>&nbsp;&=
nbsp;&nbsp; (f64vector-set! state 1 (f64vector-ref state 0))<br>&nbsp;&nbsp=
;&nbsp; (f64vector-set! state 0 y10)<br>&nbsp;&nbsp;&nbsp; dy))<br><br>; in=
terface to 'random.scm'<br><br>(define (mrg32k3a-pack-state unpacked-state)=
<br>&nbsp; (list-&gt;f64vector (map exact-&gt;inexact (vector-&gt;list unpa=
cked-state))))<br><br>(define (mrg32k3a-unpack-state state)<br>&nbsp; (list=
-&gt;vector (map inexact-&gt;exact (f64vector-&gt;list state))))<br><br>(de=
fine (mrg32k3a-random-range::obj)<br>&nbsp; (if (fixnum? 4294967087)<br>&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp; 4294967087<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 53=
6870911)) ; 2^29-1<br><br>(define (mrg32k3a-random-integer::long state rang=
e::long) ; from Brad Lucier<br>&nbsp;&nbsp; (let* ((n::double (fixnum-&gt;f=
lonum range))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (q:=
:double (floorfl (/fl 4294967087.0 n)))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp; (qn::double (*fl q n)))<br>&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp; (do ((x::double (mrg32k3a-random-m1 state) (mrg32k3a-random-m1 state)=
))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ((&lt;fl x qn)=
 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (flonum-&=
gt;fixnum (floorfl (/fl x q)))))))<br><br>(define (mrg32k3a-random-real sta=
te)<br>&nbsp; (*fl 0.0000000002328306549295728 (+fl 1.0 (mrg32k3a-random-m1=
 state))))<br><br></div></div></div></body></html>
------=_Part_144793_1204469869.1667608263874--