Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Newsgroups | sci.math, comp.lang.c, comp.lang.fortran, comp.lang.pl1, comp.lang.ada |
| Subject | Re: KISS4691, a potentially top-ranked RNG. |
| Date | 2011-05-02 07:58 +1200 |
| Message-ID | <925saiFj03U7@mid.individual.net> (permalink) |
| References | <4dae2a4b$0$55577$c30e37c6@exi-reader.telstra.net> <4db90113$0$77724$c30e37c6@exi-reader.telstra.net> <4dbd6e9c$0$12957$892e0abb@auth.newsreader.octanews.com> |
Cross-posted to 5 groups.
On 05/ 2/11 03:31 AM, Thad Smith wrote:
>
> Here is a modification of the program with masking to produce correct results
> with any conforming C implementation. It truncates where when required. A good
> optimizer should eliminate the unneeded masking for 32-bit unsigned long.
Why oh why can't people just use fixed width types? What's the
obsession with unsigned long and masking?
Add
#include <stdint.h>
change all references to "unsigned long" to uint32_t, remove all
references to M32.
> static unsigned long xs = 521288629;
> static unsigned long xcng = 362436069;
> static unsigned long Q[4691];
> #define M32 0xffffffff
>
> unsigned long MWC(void)
> {
> static unsigned long c = 0;
> static unsigned long j = 4691;
> unsigned long t;
> unsigned long x;
> j = (j< 4690) ? j + 1 : 0;
> x = Q[j];
> t = ((x<< 13) + c)& M32;
> if (t< c) {
> c = (x>> 19) + 1;
> t = (t + x)& M32;
> } else {
> t = (t + x)& M32;
> c = (x>> 19) + (t< x);
> }
> return (Q[j] = t);
>
> }
>
> void initMWC(void)
> {
> unsigned long i;
> for (i = 0; i< sizeof Q / sizeof Q[0]; i++)
> Q[i] = ((xcng = 69069 * xcng + 123) + (xs = (xs ^ (xs<< 13))& M32,
> xs ^= (xs>> 17), xs ^= (xs<< 5)))& M32;
>
> }
>
> #ifdef UNIT_TEST
>
> #include<stdio.h>
>
> int main()
> {
> unsigned long i;
> unsigned long x;
>
> initMWC();
>
> printf("Does MWC result=3740121002 ?\n");
> for (i = 0; i< 1000000000; i++)
> x = MWC();
> printf("%27u\n", x);
>
> printf("Does KISS result=2224631993 ?\n");
> for (i = 0; i< 1000000000; i++)
> x = (MWC() + (xcng = 69069 * xcng + 123) + (xs = (xs ^ (xs<< 13))& M32,
> xs ^= (xs>> 17), xs ^= (xs<< 5)));
> printf("%27u\n", x);
> return 0;
> }
>
> #endif
>
>
>
--
Ian Collins
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: KISS4691, a potentially top-ranked RNG. "robin" <robin51@dodo.mapson.com.au> - 2011-04-28 11:14 +1000
Re: KISS4691, a potentially top-ranked RNG. "e p chandler" <epc8@juno.com> - 2011-04-28 07:42 -0400
Re: KISS4691, a potentially top-ranked RNG. Gib Bogle <g.bogle@auckland.ac.nz> - 2011-04-29 12:55 +1200
Re: KISS4691, a potentially top-ranked RNG. David Bernier <david250@videotron.ca> - 2011-04-28 21:50 -0400
Re: KISS4691, a potentially top-ranked RNG. Ian Collins <ian-news@hotmail.com> - 2011-04-29 14:09 +1200
Re: KISS4691, a potentially top-ranked RNG. Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-04-28 23:01 -0400
Re: KISS4691, a potentially top-ranked RNG. Ian Collins <ian-news@hotmail.com> - 2011-04-29 15:09 +1200
Re: KISS4691, a potentially top-ranked RNG. Uno <merrilljensen@q.com> - 2011-05-08 00:34 -0700
Re: KISS4691, a potentially top-ranked RNG. Marni Zollinger <marni@altgreendesigns.com> - 2011-05-10 23:38 -0600
Re: KISS4691, a potentially top-ranked RNG. nmm1@cam.ac.uk - 2011-04-29 07:15 +0100
Re: KISS4691, a potentially top-ranked RNG. David Bernier <david250@videotron.ca> - 2011-04-28 23:16 -0400
Re: KISS4691, a potentially top-ranked RNG. glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2011-04-29 02:34 +0000
Re: KISS4691, a potentially top-ranked RNG. Uno <Uno@example.invalid> - 2011-04-29 01:04 -0600
Re: KISS4691, a potentially top-ranked RNG. "robin" <robin51@dodo.mapson.com.au> - 2011-04-30 20:48 +1000
Re: KISS4691, a potentially top-ranked RNG. Uno <Uno@example.invalid> - 2011-05-04 19:12 -0600
Re: KISS4691, a potentially top-ranked RNG. Keith Thompson <kst-u@mib.org> - 2011-04-29 08:13 -0700
Re: KISS4691, a potentially top-ranked RNG. glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2011-04-29 17:41 +0000
Re: KISS4691, a potentially top-ranked RNG. Keith Thompson <kst-u@mib.org> - 2011-04-29 12:53 -0700
Re: KISS4691, a potentially top-ranked RNG. Michael Press <rubrum@pacbell.net> - 2011-05-05 16:38 -0700
Re: KISS4691, a potentially top-ranked RNG. Seebs <usenet-nospam@seebs.net> - 2011-04-29 22:45 +0000
Re: KISS4691, a potentially top-ranked RNG. "Randy Brukardt" <randy@rrsoftware.com> - 2011-04-29 23:36 -0500
Re: KISS4691, a potentially top-ranked RNG. Seebs <usenet-nospam@seebs.net> - 2011-04-29 22:43 +0000
Re: KISS4691, a potentially top-ranked RNG. "robin" <robin51@dodo.mapson.com.au> - 2011-04-29 19:43 +1000
Re: KISS4691, a potentially top-ranked RNG. Thad Smith <ThadSmith@acm.org> - 2011-05-01 08:31 -0700
Re: KISS4691, a potentially top-ranked RNG. Ian Collins <ian-news@hotmail.com> - 2011-05-02 07:58 +1200
Re: KISS4691, a potentially top-ranked RNG. James Kuyper <jameskuyper@verizon.net> - 2011-05-01 20:01 -0400
Re: KISS4691, a potentially top-ranked RNG. Ian Collins <ian-news@hotmail.com> - 2011-05-02 12:42 +1200
Re: KISS4691, a potentially top-ranked RNG. James Kuyper <jameskuyper@verizon.net> - 2011-05-01 22:34 -0400
Re: KISS4691, a potentially top-ranked RNG. glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2011-05-02 02:50 +0000
Re: KISS4691, a potentially top-ranked RNG. Thad Smith <ThadSmith@acm.org> - 2011-05-01 21:21 -0700
Re: KISS4691, a potentially top-ranked RNG. nmm1@cam.ac.uk - 2011-05-02 08:31 +0100
Re: KISS4691, a potentially top-ranked RNG. "robin" <robin51@dodo.mapson.com.au> - 2011-05-23 16:52 +1000
Re: KISS4691, a potentially top-ranked RNG. "robin" <robin51@dodo.mapson.com.au> - 2011-05-23 14:18 +1000
Re: KISS4691, a potentially top-ranked RNG. "robin" <robin51@dodo.mapson.com.au> - 2011-05-23 17:20 +1000
Re: KISS4691, a potentially top-ranked RNG. "robin" <robin51@dodo.mapson.com.au> - 2011-05-23 16:52 +1000
Re: KISS4691, a potentially top-ranked RNG. "robin" <robin51@dodo.mapson.com.au> - 2011-05-23 16:52 +1000
Re: KISS4691, a potentially top-ranked RNG. "robin" <robin51@dodo.mapson.com.au> - 2011-05-23 16:53 +1000
Re: KISS4691, a potentially top-ranked RNG. Georg Bauhaus <rm.dash-bauhaus@futureapps.de> - 2011-05-23 09:16 +0200
Re: KISS4691, a potentially top-ranked RNG. Ilmari Karonen <usenet2@vyznev.invalid> - 2011-05-26 22:06 +0000
Re: KISS4691, a potentially top-ranked RNG. "robin" <robin51@dodo.mapson.com.au> - 2011-06-28 17:19 +1000
Re: KISS4691, a potentially top-ranked RNG. "Vinzent Hoefler" <0439279208b62c95f1880bf0f8776eeb@t-domaingrabbing.de> - 2011-06-28 10:44 +0200
Re: KISS4691, a potentially top-ranked RNG. Chris H <chris@phaedsys.org> - 2011-06-28 10:19 +0100
Re: KISS4691, a potentially top-ranked RNG. Georg Bauhaus <rm.dash-bauhaus@futureapps.de> - 2011-06-28 11:14 +0200
Re: KISS4691, a potentially top-ranked RNG. "robin" <robin51@dodo.mapson.com.au> - 2011-06-28 21:59 +1000
Re: KISS4691, a potentially top-ranked RNG. Chris H <chris@phaedsys.org> - 2011-06-28 13:16 +0100
Re: KISS4691, a potentially top-ranked RNG. Peter Flass <Peter_Flass@Yahoo.com> - 2011-06-28 11:44 -0400
Re: KISS4691, a potentially top-ranked RNG. James Kuyper <jameskuyper@verizon.net> - 2011-06-28 08:33 -0400
Re: KISS4691, a potentially top-ranked RNG. Georg Bauhaus <rm.dash-bauhaus@futureapps.de> - 2011-06-28 15:53 +0200
Re: KISS4691, a potentially top-ranked RNG. Brian Salter-Duke <b_duke@bigpond.com.au> - 2011-06-28 22:39 +0000
Re: KISS4691, a potentially top-ranked RNG. James Kuyper <jameskuyper@verizon.net> - 2011-06-28 08:32 -0400
Re: KISS4691, a potentially top-ranked RNG. Chris H <chris@phaedsys.org> - 2011-06-28 14:03 +0100
Re: KISS4691, a potentially top-ranked RNG. James Kuyper <jameskuyper@verizon.net> - 2011-06-28 10:25 -0400
Re: KISS4691, a potentially top-ranked RNG. Chris H <chris@phaedsys.org> - 2011-06-28 16:01 +0100
Re: KISS4691, a potentially top-ranked RNG. James Kuyper <jameskuyper@verizon.net> - 2011-06-28 20:20 -0400
Re: KISS4691, a potentially top-ranked RNG. Michael Press <rubrum@pacbell.net> - 2011-06-29 01:38 -0700
Re: KISS4691, a potentially top-ranked RNG. Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2011-06-28 10:04 -0600
Re: KISS4691, a potentially top-ranked RNG. Chris H <chris@phaedsys.org> - 2011-06-28 17:36 +0100
Re: KISS4691, a potentially top-ranked RNG. Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2011-06-28 10:51 -0600
Re: KISS4691, a potentially top-ranked RNG. James Kuyper <jameskuyper@verizon.net> - 2011-06-28 20:27 -0400
Re: KISS4691, a potentially top-ranked RNG. Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2011-06-28 19:00 -0600
Re: KISS4691, a potentially top-ranked RNG. Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2011-06-29 19:48 +0300
Re: KISS4691, a potentially top-ranked RNG. Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2011-06-28 10:52 -0600
Re: KISS4691, a potentially top-ranked RNG. David Bernier <david250@videotron.ca> - 2011-06-28 13:06 -0400
Re: Wiki "robin" <robin51@dodo.mapson.com.au> - 2011-06-29 10:00 +1000
Re: Wiki James Kuyper <jameskuyper@verizon.net> - 2011-06-28 20:25 -0400
Re: Wiki Ivan Shmakov <ivan@gray.siamics.net> - 2011-06-29 16:03 +0700
Re: Wiki Chris H <chris@phaedsys.org> - 2011-06-30 13:39 +0100
Re: Wiki Frederick Williams <freddywilliams@btinternet.com> - 2011-07-01 22:15 +0100
Re: Wiki Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2011-06-28 18:52 -0600
Re: Wiki James Kuyper <jameskuyper@verizon.net> - 2011-06-29 05:52 -0400
Re: Wiki Peter Flass <Peter_Flass@Yahoo.com> - 2011-06-29 10:12 -0400
Re: Wiki Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2011-06-29 14:29 -0600
Re: Wiki Dr Nick <3-nospam@temporary-address.org.uk> - 2011-06-29 07:43 +0100
Re: Wiki Peter Flass <Peter_Flass@Yahoo.com> - 2011-06-29 10:10 -0400
Re: Wiki Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2011-06-29 19:42 +0300
Re: Wiki Chris H <chris@phaedsys.org> - 2011-06-29 18:09 +0100
Re: Wiki Dr Nick <3-nospam@temporary-address.org.uk> - 2011-06-29 18:48 +0100
Re: Wiki Peter Flass <Peter_Flass@Yahoo.com> - 2011-06-29 09:50 -0400
csiph-web