├── AUTHORS ├── ChangeLog ├── INSTALL ├── doc ├── Makefile.am └── myarticle.sty ├── examples ├── vax.bin ├── my16807.h ├── xorshift.c ├── bat2.c ├── bat1.c ├── scat.c ├── birth1.c ├── bat3.c ├── Makefile.am ├── ex7.c ├── scat2.c ├── speedpcg32.c ├── excel.dat ├── fbirth.c ├── speedxoshiro128plusplus.c ├── birth2.c ├── bat1.res ├── testpcg32.c ├── ex1.c ├── testxoshiro128plusplus.c ├── mrg32k3a.c ├── ex3.c ├── bat2.res ├── fcoll.c ├── pcg32.c ├── ex3.res ├── ex4.c ├── xoshiro128plusplus.c ├── my16807.c ├── birth1.res ├── fcoll.res2.tex ├── fbirth.res2.tex ├── fbirth.res1.tex └── fcoll.res1.tex ├── mylib ├── guidemylib.pdf ├── Makefile.am ├── guidemylib.bbl ├── guidemylib.tex ├── titre.tex ├── num.h ├── mystr.tex ├── addstr.tex ├── gdef.c ├── tcode.tex ├── annexea.tex ├── bitset.tex ├── addstr.c ├── num2.tex ├── util.c ├── bitset.c └── mystr.c ├── param ├── LCGGranger.par ├── Makefile.am ├── InvExpl2a.par ├── InvExpl2b.par ├── InvImpl2a.par ├── InvImpl2b.par ├── Cubic1.par ├── InvExpl.par ├── LCGPow2.par ├── LFSR1.par ├── CombCubLCG.par ├── InvImpl.par ├── CombCubic2.par ├── LCGBad2.par ├── LFSR2.par ├── LFSR3.par ├── MRG2.par ├── LCGGood.par ├── MRG3.par ├── CombL2.par ├── CombWH2.par ├── LCGWu2.par └── TausLCG2.par ├── probdist ├── guideprobdist.pdf ├── Makefile.am ├── copyright.tex ├── wdist.c ├── titre.tex ├── guideprobdist.tex └── wdist.tex ├── testu01 ├── guidelongtestu01.pdf ├── guideshorttestu01.pdf ├── tu01_sha1.tex ├── copyright.tex ├── Makefile.am ├── fresshort.tex ├── sresshort.tex ├── uxorshift.h ├── unumrec.tex ├── TestU01.h ├── fspectral.tex ├── uquad.tex ├── uwu.tex ├── utezuka.tex ├── udeng.tex ├── title.tex ├── rijndael-alg-fst.tex ├── uweyl.tex ├── fspectral.c ├── ufile.tex ├── uknuth.tex ├── ucubic.tex ├── bintro.tex ├── fwalk.tex ├── ffsr.tex ├── uvaria.tex ├── guidetestu01.tex ├── fnpair.tex └── fvaria.tex ├── Makefile.am ├── bootstrap ├── include ├── gdefconf.h.in ├── Makefile.am ├── makedef ├── config.h.in └── Makefile.def ├── configure.ac ├── mkinstalldirs └── README.md /AUTHORS: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | Read the file README. 2 | -------------------------------------------------------------------------------- /doc/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = lmac.tex myarticle.sty 2 | -------------------------------------------------------------------------------- /examples/vax.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/umontreal-simul/TestU01-2009/HEAD/examples/vax.bin -------------------------------------------------------------------------------- /mylib/guidemylib.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/umontreal-simul/TestU01-2009/HEAD/mylib/guidemylib.pdf -------------------------------------------------------------------------------- /param/LCGGranger.par: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/umontreal-simul/TestU01-2009/HEAD/param/LCGGranger.par -------------------------------------------------------------------------------- /probdist/guideprobdist.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/umontreal-simul/TestU01-2009/HEAD/probdist/guideprobdist.pdf -------------------------------------------------------------------------------- /testu01/guidelongtestu01.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/umontreal-simul/TestU01-2009/HEAD/testu01/guidelongtestu01.pdf -------------------------------------------------------------------------------- /testu01/guideshorttestu01.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/umontreal-simul/TestU01-2009/HEAD/testu01/guideshorttestu01.pdf -------------------------------------------------------------------------------- /examples/my16807.h: -------------------------------------------------------------------------------- 1 | #include "unif01.h" 2 | 3 | unif01_Gen *CreateMy16807 (int s); 4 | 5 | void DeleteMy16807 (unif01_Gen * gen); 6 | -------------------------------------------------------------------------------- /examples/xorshift.c: -------------------------------------------------------------------------------- 1 | static unsigned int y = 2463534242U; 2 | 3 | unsigned int xorshift (void) 4 | { 5 | y ^= (y << 13); 6 | y ^= (y >> 17); 7 | return y ^= (y << 5); 8 | } 9 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | INCLUDES = -I${top_builddir} 2 | 3 | SUBDIRS = . include mylib probdist testu01 examples doc param 4 | 5 | bin_PROGRAMS = tcode 6 | tcode_SOURCES = ${top_srcdir}/mylib/tcode.c 7 | 8 | noinst_SCRIPTS = bootstrap 9 | -------------------------------------------------------------------------------- /examples/bat2.c: -------------------------------------------------------------------------------- 1 | #include "gdef.h" 2 | #include "swrite.h" 3 | #include "bbattery.h" 4 | 5 | int main (void) 6 | { 7 | swrite_Basic = FALSE; 8 | bbattery_RabbitFile ("vax.bin", 1048576); 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /examples/bat1.c: -------------------------------------------------------------------------------- 1 | #include "ulcg.h" 2 | #include "unif01.h" 3 | #include "bbattery.h" 4 | 5 | int main (void) 6 | { 7 | unif01_Gen *gen; 8 | gen = ulcg_CreateLCG (2147483647, 16807, 0, 12345); 9 | bbattery_SmallCrush (gen); 10 | ulcg_DeleteGen (gen); 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /examples/scat.c: -------------------------------------------------------------------------------- 1 | #include "unif01.h" 2 | #include "ufile.h" 3 | #include "scatter.h" 4 | 5 | int main (void) 6 | { 7 | unif01_Gen *gen; 8 | gen = ufile_CreateReadText ("excel.pts", 100000); 9 | scatter_PlotUnif (gen, "excel"); 10 | ufile_DeleteReadText (gen); 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /mylib/Makefile.am: -------------------------------------------------------------------------------- 1 | include $(top_srcdir)/include/Makefile.def 2 | 3 | lib_LTLIBRARIES = libmylib.la 4 | libmylib_la_SOURCES = $(MYLIBSOURCES) 5 | libmylib_la_LIBADD = @LIBM@ 6 | libmylib_la_LDFLAGS = -no-undefined -version-info 0:1:0 7 | 8 | EXTRA_DIST = guidemylib.tex tcode.tex titre.tex guidemylib.bbl 9 | 10 | doc_DATA = guidemylib.pdf 11 | -------------------------------------------------------------------------------- /probdist/Makefile.am: -------------------------------------------------------------------------------- 1 | include $(top_srcdir)/include/Makefile.def 2 | 3 | lib_LTLIBRARIES = libprobdist.la 4 | libprobdist_la_SOURCES = $(PROBDISTSOURCES) 5 | libprobdist_la_LIBADD = $(top_builddir)/mylib/libmylib.la 6 | libprobdist_la_LDFLAGS = -no-undefined -version-info 0:1:0 7 | 8 | EXTRA_DIST = guideprobdist.tex titre.tex copyright.tex guideprobdist.bbl 9 | 10 | doc_DATA = guideprobdist.pdf 11 | -------------------------------------------------------------------------------- /param/Makefile.am: -------------------------------------------------------------------------------- 1 | pardir = ${prefix}/share/TestU01/param 2 | 3 | par_DATA = CombCubLCG.par InvExpl.par InvImpl2b.par LCGWu2.par \ 4 | CombCubic2.par InvExpl2a.par LCGBad2.par LFSR1.par TausLCG2.par \ 5 | CombL2.par InvExpl2b.par LCGGood.par LFSR2.par MRG3.par \ 6 | CombWH2.par InvImpl.par LCGGranger.par LFSR3.par \ 7 | Cubic1.par InvImpl2a.par LCGPow2.par MRG2.par 8 | -------------------------------------------------------------------------------- /param/InvExpl2a.par: -------------------------------------------------------------------------------- 1 | # Package: TestU01 2 | # File: InvExpl2a.par 3 | # Generator: uinv_CreateInvExpl2a 4 | 5 | # Description: Parameter values for the InvExpl2a generators. 6 | #----------------------------------------------------------------- 7 | 8 | # Give the name of the family first 9 | 10 | InvExpl2a 11 | 12 | # Give a which will be used for all generators of the family. 13 | 14 | 15 | 18 16 | -------------------------------------------------------------------------------- /param/InvExpl2b.par: -------------------------------------------------------------------------------- 1 | # Package: TestU01 2 | # File: InvExpl2b.par 3 | # Generator: uinv_CreateInvExpl2b 4 | 5 | # Description: Parameter values for the InvExpl2b generators. 6 | #----------------------------------------------------------------- 7 | 8 | # Give the name of the family first 9 | 10 | InvExpl2b 11 | 12 | # Give a which will be used for all generators of the family. 13 | 14 | 15 | 18 16 | -------------------------------------------------------------------------------- /examples/birth1.c: -------------------------------------------------------------------------------- 1 | 2 | #include "unif01.h" 3 | #include "ulcg.h" 4 | #include "smarsa.h" 5 | #include 6 | 7 | int main (void) 8 | { 9 | unif01_Gen *gen; 10 | gen = ulcg_CreateLCG (2147483647, 397204094, 0, 12345); 11 | smarsa_BirthdaySpacings (gen, NULL, 1, 1000, 0, 10000, 2, 1); 12 | smarsa_BirthdaySpacings (gen, NULL, 1, 10000, 0, 1000000, 2, 1); 13 | ulcg_DeleteGen (gen); 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /param/InvImpl2a.par: -------------------------------------------------------------------------------- 1 | # Package: TestU01 2 | # File: InvImpl2a.par 3 | # Generator: uinv_CreateInvImpl2a 4 | 5 | # Description: Parameter values for the InvImpl2a generators. 6 | #----------------------------------------------------------------- 7 | 8 | # Give the name of the family first 9 | 10 | InvImpl2a 11 | 12 | # Give a1, a2 which will be used for all generators of the family. 13 | 14 | 15 | 18 131 16 | -------------------------------------------------------------------------------- /param/InvImpl2b.par: -------------------------------------------------------------------------------- 1 | # Package: TestU01 2 | # File: InvImpl2b.par 3 | # Generator: uinv_CreateInvImpl2b 4 | 5 | # Description: Parameter values for the InvImpl2b generators. 6 | #----------------------------------------------------------------- 7 | 8 | # Give the name of the family first 9 | 10 | InvImpl2b 11 | 12 | # Give a1, a2 which will be used for all generators of the family. 13 | 14 | 15 | 17 13 16 | -------------------------------------------------------------------------------- /bootstrap: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This script can be used to rebuild the derived configuration files 4 | # whenever the primary configuration files have been changed or when 5 | # a new source file is added or removed. 6 | # This script should not be used by the user compiling the package. 7 | 8 | cd include 9 | ./makedef 10 | cd .. 11 | libtoolize --copy --force 12 | aclocal 13 | autoheader 14 | automake --add-missing --copy 15 | autoconf 16 | -------------------------------------------------------------------------------- /examples/bat3.c: -------------------------------------------------------------------------------- 1 | #include "usoft.h" 2 | #include "unif01.h" 3 | #include "bbattery.h" 4 | 5 | int main (void) 6 | { 7 | unif01_Gen *gen; 8 | int n = 1024*1024; 9 | 10 | /* Test the first n bits of binary file vax.bin */ 11 | bbattery_AlphabitFile ("vax.bin", n); 12 | 13 | /* Test the Java random number generator */ 14 | gen = usoft_CreateJava48 (1234567, 1); 15 | bbattery_Alphabit (gen, n, 0, 32); 16 | 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /testu01/tu01_sha1.tex: -------------------------------------------------------------------------------- 1 | \code 2 | #ifndef TU01_SHA1_H 3 | #define TU01_SHA1_H 4 | #include "gdef.h" 5 | 6 | 7 | typedef struct 8 | { 9 | uint32_t state[5]; 10 | uint32_t count[2]; 11 | unsigned char buffer[64]; 12 | } SHA1_CTX; 13 | 14 | 15 | void SHA1Init (SHA1_CTX * context); 16 | void SHA1Update (SHA1_CTX * context, const unsigned char data[], uint32_t len); 17 | void SHA1Final (unsigned char digest[20], SHA1_CTX * context); 18 | 19 | #endif 20 | \endcode 21 | -------------------------------------------------------------------------------- /probdist/copyright.tex: -------------------------------------------------------------------------------- 1 | \section*{Copyright} 2 | 3 | %\begin{verbatim} 4 | Copyright \copyright {} 2002 by Pierre L'Ecuyer, 5 | Universit\'e de Montr\'eal.\\ 6 | Web address: \url{http://www.iro.umontreal.ca/~lecuyer/} \\ 7 | All rights reserved. 8 | 9 | \noindent This package is provided under the Apache 2 License. 10 | 11 | \noindent In scientific publications which used this software, a reference to it 12 | would be appreciated. 13 | %\end{verbatim} 14 | -------------------------------------------------------------------------------- /testu01/copyright.tex: -------------------------------------------------------------------------------- 1 | \section*{Copyright} 2 | 3 | %\begin{verbatim} 4 | Copyright \copyright {} 2002 by Pierre L'Ecuyer, 5 | Universit\'e de Montr\'eal.\\ 6 | Web address: \url{http://www.iro.umontreal.ca/~lecuyer/} \\ 7 | All rights reserved. 8 | 9 | \noindent This package is provided under the Apache 2 License. 10 | 11 | \noindent In scientific publications which used this software, a reference to it 12 | would be appreciated. 13 | %\end{verbatim} 14 | -------------------------------------------------------------------------------- /examples/Makefile.am: -------------------------------------------------------------------------------- 1 | exdir = ${prefix}/share/TestU01/examples 2 | 3 | ex_DATA = bat1.res bat2.res birth1.res ex3.res excel.dat vax.bin my16807.h \ 4 | bat1.c bat2.c bat3.c birth1.c birth2.c ex1.c ex3.c ex4.c ex7.c \ 5 | fcoll.c fbirth.c scat.c scat2.c my16807.c mrg32k3a.c pcg32.c speedpcg32.c \ 6 | speedxoshiro128plusplus.c testpcg32.c testxoshiro128plusplus.c \ 7 | xorshift.c xoshiro128plusplus.c \ 8 | fbirth.res1.tex fbirth.res2.tex fcoll.res1.tex fcoll.res2.tex 9 | -------------------------------------------------------------------------------- /include/gdefconf.h.in: -------------------------------------------------------------------------------- 1 | /* gdef.h for ANSI C */ 2 | #ifndef GDEFCONF_H 3 | #define GDEFCONF_H 4 | 5 | #undef HAVE_LEBOOL 6 | 7 | #undef HAVE_LONG_LONG 8 | 9 | #undef HAVE_ERF 10 | 11 | #undef HAVE_RANDOM 12 | 13 | #undef HAVE_LGAMMA 14 | 15 | #undef HAVE_GMP_H 16 | 17 | #undef HAVE_MATHEMATICA 18 | 19 | #undef HAVE_SYS_UTSNAME_H 20 | 21 | #undef HAVE_UNISTD_H 22 | 23 | #undef HAVE_STDINT_H 24 | 25 | #undef HAVE_UINT32_T 26 | 27 | #undef HAVE_UINT8_T 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /examples/ex7.c: -------------------------------------------------------------------------------- 1 | 2 | #include "unif01.h" 3 | #include "bbattery.h" 4 | 5 | unsigned int xorshift (void); 6 | double MRG32k3a (void); 7 | 8 | int main (void) 9 | { 10 | unif01_Gen *gen; 11 | 12 | gen = unif01_CreateExternGen01 ("MRG32k3a", MRG32k3a); 13 | bbattery_SmallCrush (gen); 14 | unif01_DeleteExternGen01 (gen); 15 | 16 | gen = unif01_CreateExternGenBits ("xorshift", xorshift); 17 | bbattery_SmallCrush (gen); 18 | unif01_DeleteExternGenBits (gen); 19 | 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /examples/scat2.c: -------------------------------------------------------------------------------- 1 | #include "unif01.h" 2 | #include "usoft.h" 3 | #include "scatter.h" 4 | 5 | int Proj[] = { 1, 3 }; 6 | long LacI[] = { 1, 2, 6}; 7 | double Lower[] = { 0.0, 0.0, 0.0 }; 8 | double Upper[] = { 0.0001, 0.5, 1.0 }; 9 | 10 | int main (void) 11 | { 12 | unif01_Gen *gen; 13 | 14 | gen = usoft_CreateVisualBasic (12345); 15 | scatter_PlotUnif1 (gen, 10000000, 3, FALSE, Proj, Lower, Upper, 16 | scatter_latex, 8, TRUE, LacI, "bone"); 17 | usoft_DeleteGen (gen); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /include/Makefile.am: -------------------------------------------------------------------------------- 1 | %.h: ${MYLIB}/%.tex 2 | ${top_srcdir}/tcode $< $@ 3 | 4 | %.h: ${PROBDIST}/%.tex 5 | ${top_srcdir}/tcode $< $@ 6 | 7 | %.h: ${TESTU01}/%.tex 8 | ${top_srcdir}/tcode $< $@ 9 | 10 | include Makefile.def 11 | 12 | include_HEADERS = $(MYLIBHEADERS) $(PROBDISTHEADERS) $(TESTU01HEADERS) gdefconf.h 13 | 14 | noinst_HEADERS = $(MYLIBTEX) $(PROBDISTTEX) $(TESTU01TEX) 15 | noinst_SCRIPTS = makedef 16 | 17 | CLEANFILES = $(MYLIBHEADERS) $(PROBDISTHEADERS) $(TESTU01HEADERS) gdefconf.h 18 | MAINTAINERCLEANFILES = Makefile.in Makefile.def 19 | -------------------------------------------------------------------------------- /testu01/Makefile.am: -------------------------------------------------------------------------------- 1 | include $(top_srcdir)/include/Makefile.def 2 | 3 | include_HEADERS = TestU01.h 4 | 5 | lib_LTLIBRARIES = libtestu01.la 6 | libtestu01_la_SOURCES = $(TESTU01SOURCES) 7 | libtestu01_la_LIBADD = $(top_builddir)/probdist/libprobdist.la $(top_builddir)/mylib/libmylib.la 8 | libtestu01_la_LDFLAGS = -no-undefined -version-info 0:1:0 9 | 10 | EXTRA_DIST = guidetestu01.tex intro.tex title.tex scatfig.tex bintro.tex copyright.tex fintro.tex sintro.tex uintro.tex guidetestu01.bbl 11 | 12 | doc_DATA = guideshorttestu01.pdf guidelongtestu01.pdf 13 | -------------------------------------------------------------------------------- /examples/speedpcg32.c: -------------------------------------------------------------------------------- 1 | /* After compiling TESTU01 and adding the libraries to your paths, 2 | * compile this program with 3 | * cc -O3 speedpcg32.c pcg32.c -o speedpcg32 -ltestu01 -lprobdist -lmylib -lm 4 | * then run it using ./speedpcg32.c 5 | */ 6 | 7 | #include "unif01.h" 8 | #include "ulec.h" 9 | 10 | uint32_t pcg32_random_r (void); 11 | 12 | int main (void) 13 | { 14 | unif01_Gen *gen; 15 | 16 | gen = unif01_CreateExternGenBits("pcg32_random_r", pcg32_random_r); 17 | unif01_TimerSumGenWr (gen, 100000000, FALSE); 18 | ulec_DeleteGen (gen); 19 | 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /examples/excel.dat: -------------------------------------------------------------------------------- 1 | 1500000 Number of points 2 | 2 Dimension = t 3 | TRUE Overlapping 4 | 1 2 Components shown 5 | 1 0.0 0.0005 Component and bounds on x1 6 | 2 0.0 1.0 Component and bounds on xt 7 | 13.0 13.0 Size of plot in centimeters 8 | latex Output format: latex, gnu_term or gnu_ps 9 | 8 Precision 10 | FALSE Lacunary 11 | 1 Lacunary indices 12 | 3 13 | -------------------------------------------------------------------------------- /examples/fbirth.c: -------------------------------------------------------------------------------- 1 | #include "fcong.h" 2 | #include "ffam.h" 3 | #include "fcho.h" 4 | #include "fmarsa.h" 5 | 6 | int main (void) 7 | { 8 | ffam_Fam *fam; 9 | fcho_Cho *chon; 10 | fcho_Cho *chod; 11 | fcho_Cho2 *cho; 12 | 13 | fam = fcong_CreateLCGPow2 (NULL, 10, 30, 1); 14 | chon = fcho_CreateSampleSize (1.0/3.0, 1, 0, NULL, "n"); 15 | chod = fmarsa_CreateBirthEC (1, 2, 1.0); 16 | cho = fcho_CreateCho2 (chon, chod); 17 | fmarsa_BirthdayS1 (fam, NULL, cho, 1, 0, 2, 1, 21, 1, 5, 1); 18 | fcho_DeleteCho2 (cho); 19 | fmarsa_DeleteBirthEC (chod); 20 | fcho_DeleteSampleSize (chon); 21 | fcong_DeleteLCGPow2 (fam); 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /examples/speedxoshiro128plusplus.c: -------------------------------------------------------------------------------- 1 | /* After compiling TESTU01 and adding the libraries to your paths, 2 | * compile this program with 3 | * cc -O3 speedxoshiro128plusplus.c xoshiro128plusplus.c \ 4 | * -o speedxoshiro128plusplus -ltestu01 -lprobdist -lmylib -lm 5 | * then run it using ./speedxoshiro128plusplus.c 6 | */ 7 | 8 | #include "unif01.h" 9 | #include "ulec.h" 10 | 11 | uint32_t xoshiro128plusplus (void); 12 | 13 | int main (void) 14 | { 15 | unif01_Gen *gen; 16 | 17 | gen = unif01_CreateExternGenBits("xoshiro128plusplus", xoshiro128plusplus); 18 | unif01_TimerSumGenWr (gen, 100000000, FALSE); 19 | ulec_DeleteGen (gen); 20 | 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /examples/birth2.c: -------------------------------------------------------------------------------- 1 | 2 | #include "unif01.h" 3 | #include "ulcg.h" 4 | #include "sres.h" 5 | #include "swrite.h" 6 | #include "smarsa.h" 7 | 8 | int main (void) 9 | { 10 | unif01_Gen *gen; 11 | sres_Poisson *res; 12 | swrite_Basic = FALSE; 13 | 14 | gen = ulcg_CreateLCG (2147483647, 397204094, 0, 12345); 15 | res = sres_CreatePoisson (); 16 | 17 | smarsa_BirthdaySpacings (gen, res, 1, 1000, 0, 10000, 2, 1); 18 | /* .... Examine or postprocess res */ 19 | 20 | smarsa_BirthdaySpacings (gen, res, 1, 10000, 0, 1000000, 2, 1); 21 | /* .... Examine or postprocess res */ 22 | 23 | sres_DeletePoisson (res); 24 | ulcg_DeleteGen (gen); 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /examples/bat1.res: -------------------------------------------------------------------------------- 1 | ========= Summary results of SmallCrush ========= 2 | 3 | Version: TestU01 1.2.3 4 | Generator: ulcg_CreateLCG 5 | Number of statistics: 15 6 | Total CPU time: 00:00:19.35 7 | The following tests gave p-values outside [0.001, 0.9990]: 8 | (eps means a value < 1.0e-300): 9 | (eps1 means a value < 1.0e-15): 10 | 11 | Test p-value 12 | ---------------------------------------------- 13 | 1 BirthdaySpacings eps 14 | 2 Collision eps 15 | 6 MaxOft eps 16 | ---------------------------------------------- 17 | All other tests were passed 18 | -------------------------------------------------------------------------------- /examples/testpcg32.c: -------------------------------------------------------------------------------- 1 | /* After compiling TESTU01 and adding the libraries to your paths, 2 | * compile this program with 3 | * cc -O3 testpcg32.c pcg32.c -o testpcg32 -ltestu01 -lprobdist -lmylib -lm 4 | * then run it using ./testpcg32.c 5 | * You can change the code to replace bbattery_SmallCrush, with 6 | * bbattery_Crush and bbattery_BigCrush 7 | */ 8 | 9 | #include "unif01.h" 10 | #include "bbattery.h" 11 | 12 | uint32_t pcg32_random_r (void); 13 | 14 | int main (void) 15 | { 16 | unif01_Gen *gen; 17 | 18 | gen = unif01_CreateExternGenBits("pcg32_random_r", pcg32_random_r); 19 | bbattery_SmallCrush (gen); 20 | unif01_DeleteExternGenBits (gen); 21 | 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /examples/ex1.c: -------------------------------------------------------------------------------- 1 | 2 | #include "unif01.h" 3 | #include "ulcg.h" 4 | #include "ulec.h" 5 | #include 6 | 7 | int main (void) 8 | { 9 | int i; 10 | double x; 11 | unsigned long z; 12 | unif01_Gen *gen; 13 | 14 | gen = ulcg_CreateLCG (2147483647, 16807, 0, 12345); 15 | x = 0.0; 16 | for (i = 0; i < 50; i++) 17 | x += gen->GetU01(gen->param, gen->state); 18 | for (i = 0; i < 50; i++) 19 | x += unif01_StripD (gen, 0); 20 | printf ("Sum = %14.10f\n\n", x); 21 | ulcg_DeleteGen (gen); 22 | 23 | gen = ulec_Createlfsr113 (12345, 12345, 12345, 12345); 24 | for (i = 0; i < 5; i++) { 25 | z = unif01_StripB (gen, 4, 10); 26 | printf ("%10lu\n", z); 27 | } 28 | ulec_DeleteGen (gen); 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /examples/testxoshiro128plusplus.c: -------------------------------------------------------------------------------- 1 | /* After compiling TESTU01 and adding the libraries to your paths, 2 | * compile this program with 3 | * cc -O3 testxoshiro128plusplus.c xoshiro128plusplus.c -o \ 4 | * testxoshiro128plusplus -ltestu01 -lprobdist -lmylib -lm 5 | * then run it using ./testxoshiro128plusplus 6 | * You can change the code to replace bbattery_SmallCrush, with 7 | * bbattery_Crush and bbattery_BigCrush 8 | */ 9 | 10 | #include "unif01.h" 11 | #include "bbattery.h" 12 | 13 | uint32_t xoshiro128plusplus (void); 14 | 15 | int main (void) 16 | { 17 | unif01_Gen *gen; 18 | 19 | gen = unif01_CreateExternGenBits("xoshiro128plusplus", xoshiro128plusplus); 20 | bbattery_SmallCrush (gen); 21 | unif01_DeleteExternGenBits (gen); 22 | 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /testu01/fresshort.tex: -------------------------------------------------------------------------------- 1 | \defmodule {fres} 2 | 3 | This module defines common structures used to keep the results of tests 4 | in the {\tt f} modules. They are described in the detailed version of 5 | this guide. 6 | 7 | 8 | The argument {\tt res} of each testing function is a structure 9 | that can keep the test results, i.e. tables of $p$-values, \ldots. 10 | This is useful if one wishes to do something else with the 11 | results or the information generated during a test. 12 | If one does not want to post-process or use the results after a test, 13 | it suffices to set the {\tt res} argument to the {\tt NULL} pointer. 14 | Then, the structure is created and deleted automatically inside the 15 | testing function. In any case, the tables of results will be printed 16 | automatically on standard output. 17 | -------------------------------------------------------------------------------- /mylib/guidemylib.bbl: -------------------------------------------------------------------------------- 1 | \begin{thebibliography}{1} 2 | 3 | \bibitem{mCLE62a} 4 | C.~W. Clenshaw. 5 | \newblock Chebychev series for mathematical functions. 6 | \newblock National Physical Laboratory Mathematical Tables~5, Her Majesty's 7 | Stationery Office, London, 1962. 8 | 9 | \bibitem{iKNU81a} 10 | D.~E. Knuth. 11 | \newblock {\em The Art of Computer Programming, Vol. 2}. 12 | \newblock Addison-Wesley, Reading, Mass., second edition, 1981. 13 | 14 | \bibitem{rLEC91a} 15 | P.~L'Ecuyer and S.~C{\^o}t{\'e}. 16 | \newblock Implementing a random number package with splitting facilities. 17 | \newblock {\em ACM Transactions on Mathematical Software}, 17(1):98--111, 1991. 18 | 19 | \bibitem{mWOL96a} 20 | S.~Wolfram. 21 | \newblock {\em The Mathematica Book}. 22 | \newblock Wolfram Media/Cambridge University Press, Champaign, USA, third 23 | edition, 1996. 24 | 25 | \end{thebibliography} 26 | -------------------------------------------------------------------------------- /examples/mrg32k3a.c: -------------------------------------------------------------------------------- 1 | 2 | #define norm 2.328306549295728e-10 3 | #define m1 4294967087.0 4 | #define m2 4294944443.0 5 | #define a12 1403580.0 6 | #define a13n 810728.0 7 | #define a21 527612.0 8 | #define a23n 1370589.0 9 | 10 | static double s10 = 12345, s11 = 12345, s12 = 123, 11 | s20 = 12345, s21 = 12345, s22 = 123; 12 | 13 | double MRG32k3a (void) 14 | { 15 | long k; 16 | double p1, p2; 17 | /* Component 1 */ 18 | p1 = a12 * s11 - a13n * s10; 19 | k = p1 / m1; p1 -= k * m1; if (p1 < 0.0) p1 += m1; 20 | s10 = s11; s11 = s12; s12 = p1; 21 | 22 | /* Component 2 */ 23 | p2 = a21 * s22 - a23n * s20; 24 | k = p2 / m2; p2 -= k * m2; if (p2 < 0.0) p2 += m2; 25 | s20 = s21; s21 = s22; s22 = p2; 26 | 27 | /* Combination */ 28 | if (p1 <= p2) return ((p1 - p2 + m1) * norm); 29 | else return ((p1 - p2) * norm); 30 | } 31 | -------------------------------------------------------------------------------- /param/Cubic1.par: -------------------------------------------------------------------------------- 1 | # Package: TestU01 2 | # File: Cubic1.par 3 | 4 | # Description: Parameter values for the Cubic1 generators 5 | #----------------------------------------------------------------- 6 | 7 | # Give the name of the family first 8 | 9 | Cubic1 10 | 11 | 12 | # For each generator, the following parameters must be given in 13 | # the right order on the same line 14 | # h m a 15 | # where h is (very close to) the base-2 logarithm of m, m is the 16 | # modulus, and a is the multiplier. 17 | 18 | 19 | 6 59 15 20 | 7 101 61 21 | 8 251 135 22 | 9 503 445 23 | 10 1019 437 24 | 11 2039 243 25 | 12 4091 494 26 | 13 8147 2410 27 | 14 16361 5595 28 | 15 32693 1190 29 | 16 65519 512 30 | 17 131063 110230 31 | 18 262133 168686 32 | -------------------------------------------------------------------------------- /examples/ex3.c: -------------------------------------------------------------------------------- 1 | 2 | #include "unif01.h" 3 | #include "ulcg.h" 4 | #include "ulec.h" 5 | #include "my16807.h" 6 | #include 7 | 8 | int main (void) 9 | { 10 | unif01_Gen *gen; 11 | double x = 0.0; 12 | int i; 13 | 14 | gen = ulcg_CreateLCGFloat (2147483647, 16807, 0, 12345); 15 | unif01_TimerSumGenWr (gen, 10000000, TRUE); 16 | ulcg_DeleteGen (gen); 17 | 18 | gen = CreateMy16807 (12345); 19 | unif01_TimerSumGenWr (gen, 10000000, TRUE); 20 | DeleteMy16807 (gen); 21 | 22 | gen = ulec_CreateMRG32k3a (123., 123., 123., 123., 123., 123.); 23 | unif01_TimerSumGenWr (gen, 10000000, TRUE); 24 | ulec_DeleteGen (gen); 25 | 26 | gen = ulec_Createlfsr113 (12345, 12345, 12345, 12345); 27 | unif01_TimerSumGenWr (gen, 10000000, TRUE); 28 | for (i = 0; i < 100; i++) 29 | x += unif01_StripD (gen, 0); 30 | printf ("Sum = %14.10f\n", x); 31 | ulec_DeleteGen (gen); 32 | 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /examples/bat2.res: -------------------------------------------------------------------------------- 1 | ========= Summary results of Rabbit ========= 2 | 3 | Version: TestU01 1.2.3 4 | File: vax.bin 5 | Number of bits: 1048576 6 | Number of statistics: 38 7 | Total CPU time: 00:00:01.75 8 | The following tests gave p-values outside [0.001, 0.9990]: 9 | (eps means a value < 1.0e-300): 10 | (eps1 means a value < 1.0e-15): 11 | 12 | Test p-value 13 | ---------------------------------------------- 14 | 4 AppearanceSpacings 1.1e-4 15 | 7 Fourier1 eps 16 | 8 Fourier3 3.2e-213 17 | 13 HammingCorr, L = 64 1 - eps1 18 | 16 HammingIndep, L = 32 eps 19 | 17 HammingIndep, L = 64 eps 20 | 24 RandomWalk1 M eps 21 | 24 RandomWalk1 J eps 22 | ---------------------------------------------- 23 | All other tests were passed 24 | -------------------------------------------------------------------------------- /testu01/sresshort.tex: -------------------------------------------------------------------------------- 1 | \defmodule {sres} 2 | 3 | This module defines common structures used to keep the results of tests 4 | in the {\tt s} modules. They are described in the detailed version of 5 | this guide. 6 | 7 | 8 | The first argument of each testing function is the random number generator 9 | to be tested. It must be created by calling the appropriate function 10 | in one of the module {\tt u}, and deleted when no longer needed. 11 | The second argument of each testing function is a structure 12 | {\tt s\ldots\_Res} that can keep the test results (intermediate and final). 13 | This is useful if one wishes to do something else with the 14 | results or the information generated during a test. 15 | If one does not want to post-process or use the results after a test, 16 | it suffices to set the {\tt \ldots\_Res} argument to the {\tt NULL} pointer. 17 | Then, the structure is created and deleted automatically inside the 18 | testing function. 19 | -------------------------------------------------------------------------------- /param/InvExpl.par: -------------------------------------------------------------------------------- 1 | # Package: TestU01 2 | # File: InvExpl.par 3 | # Generator: 4 | 5 | # Description: Parameter values for the InvExpl generators. 6 | #----------------------------------------------------------------- 7 | 8 | # Give the name of the family first 9 | 10 | InvExpl 11 | 12 | 13 | # For each generator, the following parameters must be given in 14 | # the right order on the same line 15 | # h m 16 | # where h is (very close to) the base-2 logarithm of m, m is the modulus. 17 | 18 | 19 | 10 1021 20 | 11 2039 21 | 12 4093 22 | 13 8191 23 | 14 16381 24 | 15 32749 25 | 16 65521 26 | 17 131071 27 | 18 262139 28 | 19 524287 29 | 20 1048573 30 | 21 2097143 31 | 22 4194301 32 | 23 8388593 33 | 24 16777213 34 | 25 33554393 35 | 26 67108859 36 | 27 134217689 37 | 28 268435399 38 | 29 536870909 39 | 30 1073741789 40 | 31 2147483647 41 | -------------------------------------------------------------------------------- /mylib/guidemylib.tex: -------------------------------------------------------------------------------- 1 | \documentclass[12pt]{article} 2 | \usepackage{url} 3 | 4 | \input ../doc/myarticle.sty 5 | 6 | \def\pierre#1 {\fbox {\footnote {\ }}\ \footnotetext { From Pierre: #1}} 7 | \def\richard#1 {\fbox {\footnote {\ }}\ \footnotetext { From Richard: #1}} 8 | \def\hpierre#1 {} 9 | \def\hrichard#1 {} 10 | \def\myurl{\url{http://www.iro.umontreal.ca/~lecuyer}} 11 | 12 | \newcommand\guisec[1]{\vspace{20pt} 13 | \noindent\hrulefill\hspace{10pt}{\bf #1}\hspace{10pt}\hrulefill 14 | \vspace{10pt}\nopagebreak} 15 | 16 | % \includeonly{util} 17 | 18 | \begin{document} 19 | \include {titre} 20 | \pagenumbering{roman} 21 | \tableofcontents 22 | \pagenumbering{arabic} 23 | 24 | \include{gdef} 25 | \include{util} 26 | \include{bitset} 27 | \include{chrono} 28 | \include{num} 29 | \include{num2} 30 | \include{tables} 31 | \include{mystr} 32 | \include{addstr} 33 | \include{tcode} 34 | 35 | \bibliographystyle {plain} 36 | \bibliography{stat,random,simul,math,ift} 37 | \end{document} 38 | -------------------------------------------------------------------------------- /examples/fcoll.c: -------------------------------------------------------------------------------- 1 | #include "fcong.h" 2 | #include "ffam.h" 3 | #include "fcho.h" 4 | #include "fmultin.h" 5 | #include "smultin.h" 6 | 7 | int main (void) 8 | { 9 | int NbDelta = 1; 10 | double ValDelta[] = { -1 }; 11 | int t = 2; 12 | ffam_Fam *fam; 13 | smultin_Param *par; 14 | fmultin_Res *res; 15 | fcho_Cho *chon; 16 | fcho_Cho *chod; 17 | fcho_Cho2 *cho; 18 | 19 | fam = fcong_CreateLCG ("LCGGood.par", 10, 30, 1); 20 | par = smultin_CreateParam (NbDelta, ValDelta, smultin_GenerCellSerial, 2); 21 | res = fmultin_CreateRes (par); 22 | chon = fcho_CreateSampleSize (0.5, 1, 0, NULL, "n"); 23 | chod = fmultin_CreatePer_DT (t, 1); 24 | cho = fcho_CreateCho2 (chon, chod); 25 | 26 | fmultin_Serial1 (fam, par, res, cho, 1, 0, t, TRUE, 21, 1, 5, 1); 27 | 28 | fcho_DeleteCho2 (cho); 29 | fmultin_DeletePer (chod); 30 | fcho_DeleteSampleSize (chon); 31 | fmultin_DeleteRes (res); 32 | smultin_DeleteParam (par); 33 | fcong_DeleteLCG (fam); 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /testu01/uxorshift.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | /* uxorshift.h for ANSI C */ 4 | #ifndef UXORSHIFT_H 5 | #define UXORSHIFT_H 6 | 7 | #include "gdef.h" 8 | #include "unif01.h" 9 | 10 | 11 | unif01_Gen* uxorshift_CreateXorshift32 (int a, int b, int c, unsigned int x); 12 | 13 | 14 | 15 | #ifdef USE_LONGLONG 16 | unif01_Gen* uxorshift_CreateXorshift64 (int a, int b, int c, ulonglong x); 17 | #endif 18 | 19 | 20 | 21 | unif01_Gen * uxorshift_CreateXorshiftC (int a, int b, int c, int r, 22 | unsigned int X[]); 23 | 24 | 25 | 26 | unif01_Gen * uxorshift_CreateXorshiftD (int r, int a[], unsigned int X[]); 27 | 28 | 29 | 30 | unif01_Gen* uxorshift_CreateXorshift7 (unsigned int S[8]); 31 | 32 | 33 | 34 | unif01_Gen* uxorshift_CreateXorshift13 (unsigned int S[8]); 35 | 36 | 37 | void uxorshift_DeleteXorshiftC (unif01_Gen * gen); 38 | 39 | 40 | 41 | void uxorshift_DeleteXorshiftD (unif01_Gen * gen); 42 | 43 | 44 | 45 | void uxorshift_DeleteGen (unif01_Gen * gen); 46 | 47 | #endif 48 | 49 | 50 | -------------------------------------------------------------------------------- /examples/pcg32.c: -------------------------------------------------------------------------------- 1 | #include "stdint.h" 2 | 3 | // This random number generation algorithm is taken from 4 | // M.E. O'Neil "PCG: A Family of Simple Fast Space-Efficient" 5 | // "Statistically Good Algorithms for Random Number" 6 | // "Generation" 7 | // https://www.cs.hmc.edu/tr/hmc-cs-2014-0905.pdf 8 | // https://www.pcg-random.org/download.html 9 | // 10 | // *Really* minimal PCG32 code 11 | // (c) 2014 M.E. O'Neill 12 | // pcg-random.org 13 | // Licensed under Apache License 2.0 (NO WARRANTY, etc. see website) 14 | 15 | static uint64_t state = 5342; 16 | static uint64_t inc = 521; 17 | uint32_t pcg32_random_r(void) 18 | { 19 | uint64_t oldstate = state; 20 | // Advance internal state 21 | state = oldstate * 6364136223846793005ULL + (inc|1); 22 | // Calculate output function (XSH RR), uses old state for 23 | // maximum instruction level parallelism 24 | uint32_t xorshifted = ((oldstate >> 18u) ^ oldstate) >> 27u; 25 | uint32_t rot = oldstate >> 59u; 26 | return (xorshifted >> rot) | (xorshifted << ((-rot) & 31)); 27 | } 28 | -------------------------------------------------------------------------------- /examples/ex3.res: -------------------------------------------------------------------------------- 1 | 2 | ------------- Results of speed test --------------- 3 | 4 | Host: 5 | Generator: ulcg_CreateLCGFloat 6 | Method: GetU01 7 | Mean = 0.499974546727091 8 | Number of calls: 10000000 9 | Total CPU time: 0.28 sec 10 | 11 | 12 | ------------- Results of speed test --------------- 13 | 14 | Host: 15 | Generator: My LCG implementation for a = 16807 16 | Method: GetU01 17 | Mean = 0.499974546727091 18 | Number of calls: 10000000 19 | Total CPU time: 0.28 sec 20 | 21 | 22 | ------------- Results of speed test --------------- 23 | 24 | Host: 25 | Generator: ulec_CreateMRG32k3a 26 | Method: GetU01 27 | Mean = 0.500045268775809 28 | Number of calls: 10000000 29 | Total CPU time: 0.50 sec 30 | 31 | 32 | ------------- Results of speed test --------------- 33 | 34 | Host: 35 | Generator: ulec_Createlfsr113 36 | Method: GetU01 37 | Mean = 0.500154672454091 38 | Number of calls: 10000000 39 | Total CPU time: 0.10 sec 40 | 41 | Sum = 50.6276649707 42 | -------------------------------------------------------------------------------- /mylib/titre.tex: -------------------------------------------------------------------------------- 1 | \begin{titlepage} 2 | 3 | \null 4 | \begin {flushright} \it Last update: \today \end {flushright} 5 | 6 | \vfill 7 | { \centerline {\Large\bf MyLib-C }\bigskip\bigskip 8 | \centerline {\large\bf A Small Library of Basic Utilities in ANSI C }} 9 | \vfill 10 | 11 | \centerline {{\bf Pierre L'Ecuyer and Richard Simard} % 12 | \footnote {Francis Picard and Jean-S\'ebastien S\'en\'ecal 13 | have also participated in the development of MyLib.}} 14 | \medskip 15 | \centerline {D\'epartement d'Informatique et de Recherche op\'erationnelle} 16 | \centerline {Universit\'e de Montr\'eal} 17 | 18 | \vfill 19 | % \centerline {\large\bf Note} 20 | \medskip 21 | 22 | This document describes a set of basic utilities, implemented in ANSI C, 23 | used in the software developed in the author's {\em simulation laboratory}. 24 | Most of these tools were originally implemented in the Modula-2 language. 25 | Some of them have been reimplemented in C in order to facilitate 26 | the code translation of other software from Modula-2 to C. 27 | 28 | \vfill 29 | \end{titlepage} 30 | 31 | -------------------------------------------------------------------------------- /probdist/wdist.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************\ 2 | * 3 | * Package: ProbDist 4 | * File: wdist.c 5 | * Environment: ANSI C 6 | * 7 | * Copyright (c) 2002 Pierre L'Ecuyer, DIRO, Université de Montréal. 8 | * e-mail: lecuyer@iro.umontreal.ca 9 | * All rights reserved. 10 | * 11 | * This software is provided under the Apache 2 License. 12 | * 13 | * In scientific publications which used this software, a reference to it 14 | * would be appreciated. 15 | * 16 | \*************************************************************************/ 17 | 18 | #include "wdist.h" 19 | #include "fdist.h" 20 | 21 | 22 | 23 | /*=========================================================================*/ 24 | 25 | double wdist_Normal (double Junk[], double x) 26 | { 27 | return fdist_Normal2 (x); 28 | } 29 | 30 | 31 | double wdist_ChiSquare (double W[], double x) 32 | { 33 | long N = (long) W[0]; 34 | return fdist_ChiSquare2 (N, 12, x); 35 | } 36 | 37 | 38 | double wdist_Unif (double Junk[], double x) 39 | { 40 | return fdist_Unif (x); 41 | } 42 | 43 | -------------------------------------------------------------------------------- /examples/ex4.c: -------------------------------------------------------------------------------- 1 | 2 | #include "unif01.h" 3 | #include "utaus.h" 4 | #include 5 | 6 | int main (void) 7 | { 8 | unif01_Gen *gen1, *gen2, *gen3; 9 | long I[3] = { 3, 7, 9 }; 10 | int i, n = 20; 11 | double x; 12 | 13 | gen1 = utaus_CreateTaus (31, 3, 12, 12345); 14 | for (i = 0; i < n; i++) 15 | printf ("%f\n", unif01_StripD (gen1, 0)); 16 | utaus_DeleteGen (gen1); 17 | printf ("\n"); 18 | 19 | gen1 = utaus_CreateTaus (31, 3, 12, 12345); 20 | gen2 = unif01_CreateLacGen (gen1, 3, I); 21 | for (i = 0; i < n; i++) 22 | printf ("%f\n", unif01_StripD (gen2, 0)); 23 | 24 | gen3 = unif01_CreateDoubleGen (gen2, 24); 25 | for (i = 0; i < n; i++) 26 | x = unif01_StripD (gen3, 0); 27 | unif01_DeleteDoubleGen (gen3); 28 | unif01_DeleteLacGen (gen2); 29 | 30 | gen2 = utaus_CreateTaus (28, 7, 14, 12345); 31 | gen3 = unif01_CreateCombXor2 (gen1, gen2, "A Combined Tausworthe Gener."); 32 | for (i = 0; i < n; i++) 33 | x = unif01_StripD (gen3, 0); 34 | unif01_DeleteCombGen (gen3); 35 | utaus_DeleteGen (gen2); 36 | utaus_DeleteGen (gen1); 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /probdist/titre.tex: -------------------------------------------------------------------------------- 1 | \begin{titlepage} 2 | 3 | \null 4 | \begin {flushright} \it Last update: \today \end {flushright} 5 | 6 | \vfill 7 | \begin{center} 8 | {\Large\bf ProbDist} \\ \ \\ 9 | {\large\bf A Software Library of Probability Distributions\\[6pt] 10 | and Goodness-of-Fit Statistics in {ANSI C}}\\ 11 | \vfill 12 | {\bf Pierre L'Ecuyer and Richard Simard} \\ \ \\ 13 | % has participated to the development of ProbDist.}} 14 | \medskip 15 | D\'epartement d'Informatique et de Recherche Op\'erationnelle \\ 16 | Universit\'e de Montr\'eal \\ 17 | \end{center} 18 | \vfill 19 | 20 | This document describes a set of basic software utilities, 21 | implemented in ANSI C, developed in our simulation laboratory. 22 | It is part of a larger set of tools used for stochastic simulation 23 | and for testing random number generators. 24 | It provides procedures to compute densities, mass functions, 25 | distribution functions and their inverses, and reliability functions, 26 | for various continuous and discrete probability laws. 27 | It also offers a mechanism for collecting observational data and 28 | computing elementary statistics on it, and tools for performing and 29 | reporting different types of univariate goodness-of-fit tests. 30 | 31 | \vfill 32 | \end{titlepage} 33 | 34 | -------------------------------------------------------------------------------- /param/LCGPow2.par: -------------------------------------------------------------------------------- 1 | # Package: TestU01 2 | # File: LCGPow2.par 3 | 4 | # Description: Parameter values for LCG with a good lattice structure, 5 | # with the modulus equal to 2^h and period length also equal to 2^h. 6 | #----------------------------------------------------------------- 7 | 8 | # Give the name of the family first 9 | 10 | LCGPow2 11 | 12 | 13 | # For each generator, the following parameters must be given in 14 | # the right order on the same line 15 | # h a 16 | # where m = 2^h, m is the modulus, and a is the multiplier, and 17 | # the additice constant c = 1. 18 | 19 | 10 109 20 | 11 37 21 | 12 2117 22 | 13 7517 23 | 14 4661 24 | 15 5125 25 | 16 47989 26 | 17 94941 27 | 18 45005 28 | 19 27949 29 | 20 724765 30 | 21 1386397 31 | 22 2920253 32 | 23 2500717 33 | 24 14672629 34 | 25 22605581 35 | 26 19799485 36 | 27 132354781 37 | 28 245516805 38 | 29 85334093 39 | 30 79762909 40 | 31 37769685 41 | 42 | 32 2891336453 43 | 33 3766383685 44 | 34 3999037245 45 | 35 23946934451 46 | 36 55839444821 47 | 37 107609022189 48 | 38 269689778213 49 | 38 297431448197 50 | 40 330169576829 51 | 52 | # 48 40596478153731 53 | # 60 841513432527741947 54 | -------------------------------------------------------------------------------- /probdist/guideprobdist.tex: -------------------------------------------------------------------------------- 1 | \documentclass[12pt]{article} 2 | \usepackage{url} 3 | \usepackage{amssymb} 4 | 5 | \input ../doc/myarticle.sty 6 | 7 | \newcommand\cH{\mathcal{H}} 8 | \newcommand\guisec[1]{\vspace{20pt} 9 | \noindent\hrulefill\hspace{10pt}{\bf #1}\hspace{10pt}\hrulefill 10 | \vspace{10pt}\nopagebreak} 11 | 12 | \def\pierre#1 {\fbox {\footnote {\ }}\ \footnotetext { From Pierre: #1}} 13 | \def\richard#1 {\fbox {\footnote {\ }}\ \footnotetext { From Richard: #1}} 14 | \def\hpierre#1 {} 15 | \def\hrichard#1 {} 16 | 17 | \newif\ifdetailed\detailedfalse 18 | \newenvironment{detailed}{\protect\ifdetailed }{\protect\fi } 19 | % \detailedtrue % For a more detailed user's guide. 20 | 21 | % \includeonly {wdist} 22 | 23 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 24 | \begin{document} 25 | 26 | \include {titre} 27 | 28 | \pagenumbering{roman} 29 | \include {copyright} 30 | \addcontentsline{toc}{subsection}{Copyright} 31 | \tableofcontents 32 | \clearpage 33 | 34 | \pagenumbering{arabic} 35 | 36 | \include {fmass} 37 | \include {fdist} 38 | \include {wdist} 39 | \include {fbar} 40 | \include {finv} 41 | \include {gofs} 42 | \include {gofw} 43 | \include {statcoll} 44 | % \appendix 45 | 46 | \bibliographystyle {plain} 47 | \bibliography{stat,random,simul,math} 48 | \end{document} 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /testu01/unumrec.tex: -------------------------------------------------------------------------------- 1 | \defmodule {unumrec} 2 | 3 | Implements the generators proposed in 4 | {\em Numerical Recipes: Portable Random Number Generators\/} 5 | \cite{rPRE92a,rPRE92b}. 6 | \index{Generator!Numerical Recipes} 7 | 8 | 9 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 10 | \bigskip 11 | \hrule 12 | \code 13 | \hide 14 | /* unumrec.h for ANSI C */ 15 | 16 | #ifndef UNUMREC_H 17 | #define UNUMREC_H 18 | \endhide 19 | #include "unif01.h" 20 | 21 | 22 | unif01_Gen * unumrec_CreateRan0 (long s); 23 | \endcode 24 | \tab Creates and initializes the generator {\tt Ran0} with the seed $s$. 25 | \index{Generator!Ran0}% 26 | Restriction: $0 < s < 2^{31}$. 27 | \endtab 28 | \code 29 | 30 | 31 | unif01_Gen * unumrec_CreateRan1 (long s); 32 | \endcode 33 | \tab Creates and initializes the generator {\tt Ran1} with the seed $s$. 34 | \index{Generator!Ran1}% 35 | Restriction: $0 < s < 2^{31}$. 36 | \endtab 37 | \code 38 | 39 | 40 | unif01_Gen * unumrec_CreateRan2 (long s); 41 | \endcode 42 | \tab Creates and initializes the generator {\tt Ran2} with the seed $s$. 43 | \index{Generator!Ran2}% 44 | Restriction: $0 < s < 2^{31}$. 45 | \endtab 46 | 47 | 48 | 49 | \guisec{Clean-up functions} 50 | \code 51 | 52 | void unumrec_DeleteGen (unif01_Gen *gen); 53 | \endcode 54 | \tab \DelGen 55 | \endtab 56 | \code 57 | 58 | \hide 59 | #endif 60 | \endhide 61 | \endcode 62 | -------------------------------------------------------------------------------- /param/LFSR1.par: -------------------------------------------------------------------------------- 1 | # Package: TestU01 2 | # File: LFSR1.par 3 | 4 | # Description: Parameter values for the LFSR1 generators. 5 | #----------------------------------------------------------------- 6 | 7 | # Give the name of the family first 8 | 9 | LFSR1 10 | 11 | 12 | # For each generator, the following parameters must be given in 13 | # the right order on the same line 14 | # k q s 15 | # where the parameters are the same as in utaus_CreateTaus. 16 | 17 | # The following parameters are the results of exhaustive searches. 18 | # When there exists no primitive trinomial of degree k, k has been set to 19 | # zero. 20 | 21 | 22 | 10 3 4 23 | 11 2 7 24 | 0 0 0 25 | 0 0 0 26 | 0 0 0 27 | 15 4 9 28 | 0 0 0 29 | 17 5 9 30 | 18 7 10 31 | 0 0 0 32 | 20 3 13 33 | 21 2 12 34 | 22 1 13 35 | 23 5 13 36 | 0 0 0 37 | 25 3 16 38 | 0 0 0 39 | 0 0 0 40 | 28 9 16 41 | 29 2 20 42 | 0 0 0 43 | 31 3 12 44 | 0 0 0 45 | 33 13 15 46 | 0 0 0 47 | 35 2 21 48 | 36 11 16 49 | 0 0 0 50 | 0 0 0 51 | 39 14 23 52 | 0 0 0 53 | 41 3 24 54 | 0 0 0 55 | 0 0 0 56 | 0 0 0 57 | 0 0 0 58 | 0 0 0 59 | 47 5 30 60 | 0 0 0 61 | 49 12 27 62 | 0 0 0 63 | 0 0 0 64 | 52 19 31 65 | 0 0 0 66 | 0 0 0 67 | 55 24 21 68 | 0 0 0 69 | 57 7 31 70 | 58 19 35 71 | 0 0 0 72 | 60 11 34 73 | 0 0 0 74 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | # -*- Autoconf -*- 2 | # Process this file with autoconf to produce a configure script. 3 | 4 | # AC_PREREQ(2.57) 5 | AC_INIT(TestU01, 1.2.3, lecuyer@iro.umontreal.ca) 6 | AC_CONFIG_SRCDIR([mylib/num.c]) 7 | AM_INIT_AUTOMAKE 8 | AC_CONFIG_HEADER([include/config.h]) 9 | AC_CONFIG_HEADER([include/gdefconf.h]) 10 | 11 | AC_CANONICAL_HOST 12 | 13 | # Checks for programs. 14 | AC_PROG_CC 15 | AC_PROG_CPP 16 | AC_PROG_INSTALL 17 | AC_PROG_LN_S 18 | AC_PROG_MAKE_SET 19 | AC_PROG_LIBTOOL 20 | AC_CHECK_PROG(have_mathematica,math, yes, no) 21 | if test "x$have_mathematica" = "xyes" ; then 22 | AC_DEFINE([HAVE_MATHEMATICA], 1, [Define when Mathematica is installed]) 23 | fi 24 | 25 | # Checks for libraries. 26 | AC_CHECK_LIBM 27 | 28 | # Checks for header files. 29 | AC_HEADER_STDC 30 | AC_CHECK_HEADERS([sys/utsname.h unistd.h windows.h gmp.h stdint.h]) 31 | 32 | # Checks for typedefs, structures, and compiler characteristics. 33 | AC_C_CONST 34 | AC_TYPE_SIZE_T 35 | AC_C_BIGENDIAN 36 | AC_CHECK_TYPES([long long, uint32_t, uint8_t]) 37 | 38 | # Checks for library functions. 39 | # AC_FUNC_MALLOC 40 | # AC_FUNC_REALLOC 41 | LIBS="$LIBM $LIBS" 42 | AC_CHECK_FUNCS([random erf lgamma log1p]) 43 | 44 | AC_CONFIG_FILES([Makefile 45 | include/Makefile mylib/Makefile probdist/Makefile 46 | testu01/Makefile examples/Makefile doc/Makefile param/Makefile]) 47 | AC_SUBST([LIBM]) 48 | AC_OUTPUT 49 | -------------------------------------------------------------------------------- /testu01/TestU01.h: -------------------------------------------------------------------------------- 1 | #ifndef TESTU01_H 2 | #define TESTU01_H 3 | 4 | #include "bbattery.h" 5 | #include "fcho.h" 6 | #include "fcong.h" 7 | #include "ffam.h" 8 | #include "ffsr.h" 9 | #include "fknuth.h" 10 | #include "fmarsa.h" 11 | #include "fmultin.h" 12 | #include "fnpair.h" 13 | #include "fres.h" 14 | #include "fspectral.h" 15 | #include "fstring.h" 16 | #include "ftab.h" 17 | #include "fvaria.h" 18 | #include "fwalk.h" 19 | #include "scatter.h" 20 | #include "scomp.h" 21 | #include "sentrop.h" 22 | #include "sknuth.h" 23 | #include "smarsa.h" 24 | #include "smultin.h" 25 | #include "snpair.h" 26 | #include "sres.h" 27 | #include "sspacings.h" 28 | #include "sspectral.h" 29 | #include "sstring.h" 30 | #include "svaria.h" 31 | #include "swalk.h" 32 | #include "swrite.h" 33 | #include "uautomata.h" 34 | #include "ubrent.h" 35 | #include "ucarry.h" 36 | #include "ucrypto.h" 37 | #include "rijndael-alg-fst.h" 38 | #include "tu01_sha1.h" 39 | #include "ucubic.h" 40 | #include "udeng.h" 41 | #include "ufile.h" 42 | #include "ugfsr.h" 43 | #include "ugranger.h" 44 | #include "uinv.h" 45 | #include "uknuth.h" 46 | #include "ulcg.h" 47 | #include "ulec.h" 48 | #include "umarsa.h" 49 | #include "umrg.h" 50 | #include "unif01.h" 51 | #include "unumrec.h" 52 | #include "uquad.h" 53 | #include "usoft.h" 54 | #include "utaus.h" 55 | #include "utezuka.h" 56 | #include "utouzin.h" 57 | #include "uvaria.h" 58 | #include "uweyl.h" 59 | #include "uwu.h" 60 | #include "uxorshift.h" 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /testu01/fspectral.tex: -------------------------------------------------------------------------------- 1 | \defmodule {fspectral} 2 | 3 | This module applies spectral tests from the module {\tt sspectral} 4 | to a family of generators of different sizes. 5 | 6 | \bigskip 7 | \hrule 8 | \code\hide 9 | /* fspectral.h for ANSI C */ 10 | #ifndef FSPECTRAL_H 11 | #define FSPECTRAL_H 12 | \endhide 13 | #include "ffam.h" 14 | #include "fres.h" 15 | #include "fcho.h" 16 | 17 | 18 | extern long fspectral_MaxN; 19 | \endcode 20 | \tab 21 | Upper bound on $N$. 22 | When $N$ exceeds its limit value, the tests are not done. 23 | Default value: $N = 2^{22}$. 24 | \endtab 25 | 26 | 27 | 28 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 29 | \guisec{The tests} 30 | 31 | \code 32 | void fspectral_Fourier3 (ffam_Fam *fam, fres_Cont *res, fcho_Cho *cho, 33 | int k, int r, int s, 34 | int Nr, int j1, int j2, int jstep); 35 | \endcode 36 | \tab 37 | This function calls the test {\tt sspectral\_Fourier3} with parameters 38 | $N$, {\tt k}, {\tt r}, and {\tt s} for sample size $N$ chosen by 39 | $N = {}$ {\tt cho->Choose(param, i, j)}, 40 | for the first {\tt Nr} generators of family {\tt fam}, for $j$ going from 41 | {\tt j1} to {\tt j2} by steps of {\tt jstep}. The parameters in {\tt param} 42 | were set at the creation of {\tt cho} and $i$ is the lsize of the 43 | generator being tested. 44 | When $N$ exceeds {\tt fspectral\_MaxN}, the test is not done. 45 | \endtab 46 | 47 | \code 48 | \hide 49 | #endif 50 | \endhide 51 | \endcode 52 | -------------------------------------------------------------------------------- /mylib/num.h: -------------------------------------------------------------------------------- 1 | 2 | /* num.h for ANSI C */ 3 | 4 | #ifndef NUM_H 5 | #define NUM_H 6 | 7 | #include "gdef.h" 8 | 9 | 10 | #define num_Pi 3.14159265358979323846 11 | 12 | 13 | #define num_ebase 2.7182818284590452354 14 | 15 | 16 | #define num_Rac2 1.41421356237309504880 17 | 18 | 19 | #define num_1Rac2 0.70710678118654752440 20 | 21 | 22 | #define num_Ln2 0.69314718055994530941 23 | 24 | 25 | #define num_1Ln2 1.44269504088896340737 26 | 27 | 28 | #define num_MaxIntDouble 9007199254740992.0 29 | 30 | 31 | #define num_MaxTwoExp 64 32 | 33 | 34 | extern double num_TwoExp[]; 35 | 36 | 37 | #define num_MAXTENNEGPOW 16 38 | 39 | 40 | extern double num_TENNEGPOW[]; 41 | 42 | 43 | #define num_Log2(x) (num_1Ln2 * log(x)) 44 | 45 | 46 | 47 | long num_RoundL (double x); 48 | 49 | 50 | 51 | double num_RoundD (double x); 52 | 53 | 54 | 55 | int num_IsNumber (char S[]); 56 | 57 | 58 | 59 | void num_IntToStrBase (long k, long b, char S[]); 60 | 61 | 62 | 63 | void num_Uint2Uchar (unsigned char output[], unsigned int input[], int L); 64 | 65 | 66 | 67 | void num_WriteD (double x, int i, int j, int k); 68 | 69 | 70 | 71 | void num_WriteBits (unsigned long x, int k); 72 | 73 | 74 | 75 | long num_MultModL (long a, long s, long c, long m); 76 | 77 | 78 | 79 | double num_MultModD (double a, double s, double c, double m); 80 | 81 | 82 | 83 | long num_InvEuclid (long m, long z); 84 | 85 | 86 | 87 | unsigned long num_InvExpon (int E, unsigned long z); 88 | 89 | 90 | #endif 91 | 92 | 93 | -------------------------------------------------------------------------------- /param/CombCubLCG.par: -------------------------------------------------------------------------------- 1 | 2 | # Package: TestU01 3 | # File: CombCubLCG.par 4 | 5 | # Description: Parameter values for combined Cubic1 with LCG 6 | #----------------------------------------------------------------- 7 | 8 | # Give the name of the family first 9 | 10 | CombCubLCG 11 | 12 | 13 | # For each generator, the following parameters must be given in 14 | # the right order on the same line 15 | # h m1 a1 m2 a2 16 | # where h is (very close to) the base-2 logarithm of the period length, 17 | # m1, a1 are the modulus and the multiplier of the LCG generator, 18 | # m2, a2 are the modulus and the multiplier of the Cubic1 generator. 19 | 20 | #h m1 a1 m2 a2 21 | 22 | 19 1021 65 491 277 23 | 20 1021 65 1013 31 24 | 21 2039 995 1013 31 25 | 22 2039 995 2027 349 26 | 23 4093 209 2027 349 27 | 24 4093 209 4079 3757 28 | 25 8191 884 4079 3757 29 | 26 8191 884 8111 2257 30 | 27 16381 572 8111 2257 31 | 28 16381 572 16319 3013 32 | 29 32749 219 16319 3013 33 | 30 32749 219 32687 4535 34 | 31 65521 17364 32687 4535 35 | 32 65521 17364 65447 27076 36 | 33 131071 43165 65447 27076 37 | 34 131071 43165 130859 48249 38 | 35 262139 92717 130859 48249 39 | 36 262139 92717 262103 173782 40 | -------------------------------------------------------------------------------- /examples/xoshiro128plusplus.c: -------------------------------------------------------------------------------- 1 | /* Written in 2019 by David Blackman and Sebastiano Vigna (vigna@acm.org) 2 | 3 | To the extent possible under law, the author has dedicated all copyright 4 | and related and neighboring rights to this software to the public domain 5 | worldwide. This software is distributed without any warranty. 6 | 7 | See . 8 | 9 | Original source is available at: 10 | 11 | https://prng.di.unimi.it/ 12 | 13 | Modified by Benson Muite in 2022 for use with TestU01 14 | 15 | Jump functions removed */ 16 | #include 17 | 18 | /* This is xoshiro128++ 1.0, one of our 32-bit all-purpose, rock-solid 19 | generators. It has excellent speed, a state size (128 bits) that is 20 | large enough for mild parallelism, and it passes all tests we are aware 21 | of. 22 | 23 | For generating just single-precision (i.e., 32-bit) floating-point 24 | numbers, xoshiro128+ is even faster. 25 | 26 | The state must be seeded so that it is not everywhere zero. */ 27 | 28 | 29 | static inline uint32_t rotl(const uint32_t x, int k) { 30 | return (x << k) | (x >> (32 - k)); 31 | } 32 | 33 | static uint32_t s[4] = {53, 30301, 71423, 49323}; 34 | 35 | uint32_t xoshiro128plusplus(void) { 36 | const uint32_t result = rotl(s[0] + s[3], 7) + s[0]; 37 | 38 | const uint32_t t = s[1] << 9; 39 | 40 | s[2] ^= s[0]; 41 | s[3] ^= s[1]; 42 | s[1] ^= s[2]; 43 | s[0] ^= s[3]; 44 | 45 | s[2] ^= t; 46 | 47 | s[3] = rotl(s[3], 11); 48 | 49 | return result; 50 | } 51 | 52 | -------------------------------------------------------------------------------- /param/InvImpl.par: -------------------------------------------------------------------------------- 1 | # Package: TestU01 2 | # File: InvImpl.par 3 | # Generator: uinv_CreateInvImpl 4 | 5 | # Description: Parameter values for the InvImpl generators. 6 | #----------------------------------------------------------------- 7 | 8 | # Give the name of the family first 9 | 10 | InvImpl 11 | 12 | 13 | # For each generator, the following parameters must be given in 14 | # the right order on the same line 15 | # h m a1 a2 16 | # where h is (very close to) the base-2 logarithm of m, m is the modulus, 17 | # a1 is the additive constant and a2 is the multiplier. 18 | 19 | 20 | 10 1021 730 663 21 | 11 2039 1805 1930 22 | 12 4093 1172 770 23 | 13 8191 4837 7660 24 | 14 16381 13073 1997 25 | 15 32749 9343 6439 26 | 16 65521 35907 30770 27 | 17 131071 55544 90795 28 | 18 262139 21830 162959 29 | 19 524287 396733 446660 30 | 20 1048573 633537 57143 31 | 21 2097143 132547 1642238 32 | 22 4194301 173405 3471693 33 | 23 8388593 1439561 1830242 34 | 24 16777213 10355898 1875483 35 | 25 33554393 23321560 483332 36 | 26 67108859 59310754 15280366 37 | 27 134217689 16626702 26032456 38 | 28 268435399 31958755 240379154 39 | 29 536870909 6284080 4697886 40 | 30 1073741789 5796676 1069420043 41 | -------------------------------------------------------------------------------- /examples/my16807.c: -------------------------------------------------------------------------------- 1 | #include "my16807.h" 2 | #include "unif01.h" 3 | #include "util.h" 4 | #include "addstr.h" 5 | #include 6 | 7 | typedef struct { double S; } My16807_state; 8 | 9 | static double My16807_U01 (void *par, void *sta) 10 | { 11 | My16807_state *state = sta; 12 | long k; 13 | state->S *= 16807.0; 14 | k = state->S / 2147483647.0; 15 | state->S -= k * 2147483647.0; 16 | return (state->S * 4.656612875245797E-10); 17 | } 18 | 19 | static unsigned long My16807_Bits (void *par, void *sta) 20 | { 21 | return (unsigned long) (My16807_U01 (par, sta) * 4294967296.0); 22 | } 23 | 24 | static void WrMy16807 (void *sta) 25 | { 26 | My16807_state *state = sta; 27 | printf (" S = %.0f\n", state->S); 28 | } 29 | 30 | unif01_Gen *CreateMy16807 (int s) 31 | { 32 | unif01_Gen *gen; 33 | My16807_state *state; 34 | size_t leng; 35 | char name[60]; 36 | 37 | gen = util_Malloc (sizeof (unif01_Gen)); 38 | gen->state = state = util_Malloc (sizeof (My16807_state)); 39 | state->S = s; 40 | gen->param = NULL; 41 | gen->Write = WrMy16807; 42 | gen->GetU01 = My16807_U01; 43 | gen->GetBits = My16807_Bits; 44 | 45 | strcpy (name, "My LCG implementation for a = 16807:"); 46 | addstr_Int (name, " s = ", s); 47 | leng = strlen (name); 48 | gen->name = util_Calloc (leng + 1, sizeof (char)); 49 | strncpy (gen->name, name, leng); 50 | return gen; 51 | } 52 | 53 | void DeleteMy16807 (unif01_Gen * gen) 54 | { 55 | gen->state = util_Free (gen->state); 56 | gen->name = util_Free (gen->name); 57 | util_Free (gen); 58 | } 59 | -------------------------------------------------------------------------------- /examples/birth1.res: -------------------------------------------------------------------------------- 1 | *********************************************************** 2 | HOST = 3 | 4 | ulcg_CreateLCG: m = 2147483647, a = 397204094, c = 0, s = 12345 5 | 6 | 7 | smarsa_BirthdaySpacings test: 8 | ----------------------------------------------- 9 | N = 1, n = 1000, r = 0, d = 10000, t = 2, p = 1 10 | 11 | 12 | Number of cells = d^t = 100000000 13 | Lambda = Poisson mean = 2.5000 14 | 15 | 16 | ---------------------------------------------------- 17 | Total expected number = N*Lambda : 2.50 18 | Total observed number : 6 19 | p-value of test : 0.04 20 | 21 | 22 | ----------------------------------------------- 23 | CPU time used : 00:00:00.00 24 | 25 | Generator state: 26 | s = 1858647048 27 | 28 | 29 | 30 | 31 | *********************************************************** 32 | HOST = 33 | 34 | ulcg_CreateLCG: m = 2147483647, a = 397204094, c = 0, s = 12345 35 | 36 | 37 | smarsa_BirthdaySpacings test: 38 | ----------------------------------------------- 39 | N = 1, n = 10000, r = 0, d = 1000000, t = 2, p = 1 40 | 41 | 42 | Number of cells = d^t = 1000000000000 43 | Lambda = Poisson mean = 0.2500 44 | 45 | 46 | ---------------------------------------------------- 47 | Total expected number = N*Lambda : 0.25 48 | Total observed number : 44 49 | p-value of test : 9.5e-82 ***** 50 | 51 | 52 | ----------------------------------------------- 53 | CPU time used : 00:00:00.00 54 | 55 | Generator state: 56 | s = 731506484 57 | -------------------------------------------------------------------------------- /testu01/uquad.tex: -------------------------------------------------------------------------------- 1 | \defmodule {uquad} 2 | 3 | This module implements generators based on quadratic recurrences 4 | modulo $m$, of the form 5 | \eq 6 | x_{n+1} = (a x_n^2 + b x_n + c) \mod m, \eqlabel{quad} 7 | \endeq 8 | with output $u_n = x_n/m$ at step $n$. 9 | See, e.g., \cite{rEIC87a,rEIC97d,rEMM97a,rKNU98a} 10 | for analyses of such generators. 11 | 12 | 13 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 14 | \bigskip 15 | \hrule 16 | \code 17 | \hide 18 | /* uquad.h for ANSI C */ 19 | #ifndef UQUAD_H 20 | #define UQUAD_H 21 | \endhide 22 | #include "unif01.h" 23 | 24 | 25 | unif01_Gen * uquad_CreateQuadratic (long m, long a, long b, long c, long s); 26 | \endcode 27 | \tab Initializes a generator based on recurrence (\ref{quad}), 28 | with initial state $x_0 = s$. 29 | \index{Generator!quadratic}% 30 | Depending on the values of the parameters, various implementations 31 | of different speeds are used. In general, this generator 32 | is slow. Restrictions: $a$, $b$, $c$ and $s$ non 33 | negative and less than $m$. 34 | \endtab 35 | \code 36 | 37 | 38 | unif01_Gen * uquad_CreateQuadratic2 (int e, unsigned long a, 39 | unsigned long b, unsigned long c, unsigned long s); 40 | \endcode 41 | \tab Similar to {\tt uquad\_CreateQuadratic}, but with $m=2^e$. 42 | Restrictions: $a$, $b$, $c$ and $s$ non negative and 43 | less than $2^e$; $e \le 32$ for 32-bit machines, 44 | and $e \le 64$ for 64-bit machines. 45 | \endtab 46 | 47 | 48 | \guisec{Clean-up functions} 49 | \code 50 | 51 | void uquad_DeleteGen (unif01_Gen *gen); 52 | \endcode 53 | \tab \DelGen 54 | \endtab 55 | \code 56 | \hide 57 | #endif 58 | \endhide 59 | \endcode 60 | -------------------------------------------------------------------------------- /doc/myarticle.sty: -------------------------------------------------------------------------------- 1 | % LATEX ARTICLE DOCUMENT STYLE 2 | % Modifications et ajout de macros. Pierre L'Ecuyer. 3 | 4 | \topmargin=-0.5in\oddsidemargin=0pt\topskip=\baselineskip 5 | \headsep=0pt\headheight=0.5in 6 | \renewcommand{\topfraction}{.90} 7 | \renewcommand{\bottomfraction}{.80} 8 | \renewcommand{\textfraction}{.10} 9 | \textwidth=6.5 true in\textheight=8.9 true in 10 | \tolerance=500 \parskip=.1in plus .1in minus .04in 11 | 12 | \catcode`\@=11 13 | %\def\thesection {\arabic{section}.} 14 | %\def\thesubsection {\thesection\arabic{subsection}.} 15 | %\def\thesubsubsection {\thesubsection\arabic{subsubsection}.} 16 | %\def\theparagraph {\thesubsubsection\arabic{paragraph}.} 17 | %\def\thesubparagraph {\theparagraph\arabic{subparagraph}.} 18 | %\def\@thmcounter#1{\noexpand\arabic{#1}.} 19 | 20 | \def\fps@figure {hbtp} 21 | \def\fps@table {hbtp} 22 | 23 | \def\thebibliography#1{\section*{References\markboth 24 | {REFERENCES}{REFERENCES}}\list 25 | {[\arabic{enumi}]}{\settowidth\labelwidth{[#1]}\leftmargin\labelwidth 26 | \advance\leftmargin\labelsep\usecounter{enumi}}} 27 | \def\@citex[#1]#2{\if@filesw\immediate\write\@auxout{\string\citation{#2}}\fi 28 | \def\@citea{}\@cite{\@for\@citeb:=#2\do 29 | {\@citea\def\@citea{, }\@ifundefined 30 | {b@\@citeb}{{\bf ?}\@warning 31 | {Citation `\@citeb' on page \thepage \space undefined}}% 32 | \hbox{\csname b@\@citeb\endcsname}}}{#1}} 33 | 34 | \def\abstract{\if@twocolumn \section*{Abstract} 35 | \else \small 36 | \begin{center}{\bf ABSTRACT\vspace{-.5em}\vspace{0pt}}\end{center} 37 | \quotation\fi} 38 | 39 | \def\inc#1{\@partswtrue\edef\@partlist{#1}} 40 | \catcode`\@=12 41 | 42 | \input ../doc/lmac.tex 43 | 44 | 45 | -------------------------------------------------------------------------------- /testu01/uwu.tex: -------------------------------------------------------------------------------- 1 | \defmodule {uwu} 2 | 3 | This module collects some generators from Pei-Chi Wu. 4 | \index{Generator!Wu} 5 | 6 | 7 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 8 | \bigskip 9 | \hrule 10 | \code\hide 11 | /* uwu.h for ANSI C */ 12 | 13 | #ifndef UWU_H 14 | #define UWU_H 15 | \endhide 16 | #include "gdef.h" 17 | #include "unif01.h" 18 | 19 | 20 | #ifdef USE_LONGLONG 21 | unif01_Gen * uwu_CreateLCGWu61a (longlong s); 22 | \endcode 23 | \tab Implements a LCG proposed by Wu \cite{rWU97a}, 24 | with $m= 2^{61}-1$, $a = 2^{30} - 2^{19}$, $c=0$. 25 | Uses a fast implementation with shifts rather than 26 | multiplications. 27 | It uses 64-bits integers. % which must be available. 28 | \endtab 29 | \code 30 | 31 | 32 | unif01_Gen * uwu_CreateLCGWu61b (longlong s); 33 | \endcode 34 | \tab Similar to {\tt uwu\_CreateLCGWu61a}, 35 | but with $a = 2^{42} - 2^{31}$. 36 | \endtab 37 | \code 38 | #endif 39 | \endcode 40 | 41 | 42 | 43 | \guisec{Clean-up functions} 44 | 45 | \code 46 | 47 | 48 | void uwu_DeleteGen (unif01_Gen *gen); 49 | \endcode 50 | \tab Frees the dynamic memory used by any generator of this module 51 | that does not have an explicit {\tt Delete} function. 52 | This function should be called to clean up a generator object 53 | when it is no longer in use. 54 | \endtab 55 | \code 56 | 57 | \hide 58 | #endif 59 | \endhide 60 | \endcode 61 | 62 | 63 | \bigskip 64 | \hrule 65 | \bigskip 66 | 67 | { 68 | See also 69 | \bigskip 70 | 71 | \setlength{\partopsep}{0pt} 72 | \setlength{\parskip}{0pt} 73 | \setlength{\topsep}{0pt} 74 | \setlength{\itemsep}{0pt} 75 | 76 | \begin{itemize} 77 | \item {\tt ulcg\_CreateLCGWu2} 78 | \end{itemize} 79 | } 80 | -------------------------------------------------------------------------------- /param/CombCubic2.par: -------------------------------------------------------------------------------- 1 | # Package: TestU01 2 | # File: CombCubic2.par 3 | 4 | # Description: Parameter values for the CombCubic2 generators 5 | #----------------------------------------------------------------- 6 | 7 | # Give the name of the family first 8 | 9 | CombCubic2 10 | 11 | 12 | # For each generator, the following parameters must be given in 13 | # the right order on the same line 14 | # h m1 m2 a1 a2 15 | # where h is (very close to) the base-2 logarithm of the period length, 16 | # m1 and m2 are the moduli, a1 and a2 are the multipliers. 17 | 18 | 19 | 12 59 47 15 7 20 | 13 101 59 61 15 21 | 14 101 83 61 9 22 | 15 251 101 135 61 23 | 16 251 233 135 61 24 | 17 503 251 445 135 25 | 18 503 491 445 277 26 | 19 1019 503 437 445 27 | 20 1019 1013 437 31 28 | 21 2039 1019 243 437 29 | 22 2039 2027 243 349 30 | 23 4091 2039 494 243 31 | 24 4091 4079 494 3757 32 | 25 8147 4091 2410 494 33 | 26 8147 8111 2410 2257 34 | 27 16361 8147 5595 2410 35 | 28 16361 16319 5595 3013 36 | 29 32693 16361 1190 5595 37 | 30 32693 32687 1190 4535 38 | 31 65519 32693 512 1190 39 | 32 65519 65447 512 27076 40 | 33 131063 65519 110230 512 41 | 34 131063 130859 110230 48249 42 | 35 262133 131063 168686 110230 43 | 36 262133 262103 168686 173782 44 | -------------------------------------------------------------------------------- /testu01/utezuka.tex: -------------------------------------------------------------------------------- 1 | \defmodule {utezuka} 2 | 3 | This module collects some generators designed by S.~Tezuka. 4 | 5 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 6 | \bigskip 7 | \hrule 8 | \code 9 | \hide 10 | /* utezuka.h for ANSI C */ 11 | 12 | #ifndef UTEZUKA_H 13 | #define UTEZUKA_H 14 | \endhide 15 | #include "unif01.h" 16 | 17 | 18 | unif01_Gen * utezuka_CreateTezLec91 (unsigned int Y1, unsigned int Y2); 19 | \endcode 20 | \tab Implements a combined Tausworthe generator constructed 21 | by Tezuka and L'Ecuyer \cite{rTEZ91b}, and whose implementation 22 | is given in their paper. 23 | \index{Generator!Tezuka}% 24 | The initial values {\tt Y1} and {\tt Y2} must be positive and 25 | less than $2^{31}$ and $2^{29}$ respectively. 26 | \endtab 27 | \code 28 | 29 | 30 | unif01_Gen * utezuka_CreateTez95 (unsigned int Y1, unsigned int Y2, 31 | unsigned int Y3); 32 | \endcode 33 | \tab Implements the combined generator proposed in 34 | Figure A.1 of \cite{rTEZ95a}, page 194. 35 | The initial values {\tt Y1, Y2, Y3} must be positive and 36 | less than $2^{28}$, $2^{29}$ and $2^{31}$ 37 | respectively. 38 | \endtab 39 | \code 40 | 41 | 42 | unif01_Gen * utezuka_CreateTezMRG95 (unsigned int Y1[5], 43 | unsigned int Y2[7]); 44 | \endcode 45 | \tab Implements the combined generator proposed in 46 | Figure A.2 of \cite{rTEZ95a}, page 195. 47 | The initial values of the array elements of {\tt Y1} and {\tt Y2} 48 | must be positive and 49 | less than $2^{31}$ and $2^{29}$ respectively. 50 | \endtab 51 | 52 | 53 | 54 | \guisec{Clean-up functions} 55 | 56 | \code 57 | 58 | void utezuka_DeleteGen (unif01_Gen *gen); 59 | \endcode 60 | \tab \DelGen 61 | \endtab 62 | \code 63 | 64 | \hide 65 | #endif 66 | \endhide 67 | \endcode 68 | -------------------------------------------------------------------------------- /include/makedef: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | rm -f Makefile.def 4 | 5 | echo 'docdir = ${prefix}/share/TestU01/doc' >> Makefile.def 6 | echo 'MYLIB = ${top_srcdir}/mylib' >> Makefile.def 7 | echo 'PROBDIST = ${top_srcdir}/probdist' >> Makefile.def 8 | echo 'TESTU01 = ${top_srcdir}/testu01' >> Makefile.def 9 | echo '' >> Makefile.def 10 | 11 | MYLIBMODULES='gdef addstr bitset chrono mystr num num2 tables util' 12 | 13 | PROBDISTMODULES='fmass fdist fbar finv gofs gofw statcoll wdist' 14 | 15 | TESTU01MODULES='unif01 ulcg umrg ucarry utaus ugfsr 16 | uinv uquad ucubic ulec utezuka umarsa 17 | uweyl uknuth uwu unumrec uvaria usoft 18 | ugranger ucrypto ufile udeng utouzin uautomata 19 | uxorshift ubrent rijndael-alg-fst tu01_sha1 20 | scatter swrite sres smultin sknuth smarsa 21 | sstring svaria snpair swalk sentrop sspectral 22 | scomp sspacings vectorsF2 bbattery 23 | ffam fcong ffsr ftab fres fcho 24 | fmultin fmarsa fknuth fwalk fstring fspectral 25 | fvaria fnpair' 26 | 27 | function writevar() { 28 | HEADERS="" 29 | TEX="" 30 | SOURCES="" 31 | for mod in $1; do 32 | HEADERS="$HEADERS ${mod}.h" 33 | SOURCES="$SOURCES ${mod}.c" 34 | TEX="$TEX \$($2)/${mod}.tex" 35 | done 36 | echo "$2HEADERS =$HEADERS" >> Makefile.def 37 | echo "$2SOURCES =$SOURCES" >> Makefile.def 38 | echo "$2TEX =$TEX" >> Makefile.def 39 | echo '' >> Makefile.def 40 | unset HEADERS 41 | unset TEX 42 | unset SOURCES 43 | } 44 | 45 | writevar "$MYLIBMODULES" 'MYLIB' 46 | writevar "$PROBDISTMODULES" "PROBDIST" 47 | writevar "$TESTU01MODULES" "TESTU01" 48 | 49 | unset writevar 50 | unset MYLIBMODULES 51 | unset PROBDISTMODULES 52 | unset TESTU01MODULES 53 | -------------------------------------------------------------------------------- /testu01/udeng.tex: -------------------------------------------------------------------------------- 1 | \defmodule {udeng} 2 | 3 | This module collects some generators from Lih-Yuan Deng and his 4 | collaborators.\index{Generator!Deng}% 5 | 6 | 7 | 8 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 9 | \bigskip 10 | \hrule 11 | \code\hide 12 | /* udeng.h for ANSI C */ 13 | 14 | #ifndef UDENG_H 15 | #define UDENG_H 16 | \endhide 17 | #include "unif01.h" 18 | \endcode 19 | \code 20 | 21 | 22 | unif01_Gen * udeng_CreateDL00a (unsigned long m, unsigned long b, int k, 23 | unsigned long S[]); 24 | \endcode 25 | \tab Creates a multiple recursive generator proposed by Deng 26 | and Lin \cite{rDEN00a} in the form: 27 | $$ 28 | x_i\ =\ ((m-1)x_{i-1} + b x_{i-k}) \mod m\ =\ 29 | (-x_{i-1} + b x_{i-k}) \mod m. 30 | $$ 31 | The generator returns $u_i = x_i/m$. The initial state 32 | $(x_{-1},\dots,\?x_{-k})$ is in {\tt S[0..(k-1)]}. 33 | Restriction: $k \le 128$. 34 | \endtab 35 | \code 36 | 37 | 38 | unif01_Gen * udeng_CreateDX02a (unsigned long m, unsigned long b, int k, 39 | unsigned long S[]); 40 | \endcode 41 | \tab Creates a multiple recursive generator proposed by Deng 42 | and Xu \cite{rDEN02a} in the form: 43 | $$ 44 | x_i \ =\ b(x_{i-1} + x_{i-k}) \mod m. 45 | $$ 46 | The generator returns $u_i = x_i/m$. The initial state 47 | $(x_{-1},\dots,\?x_{-k})$ is in {\tt S[0..(k-1)]}. 48 | Restriction: $k \le 128$. 49 | \endtab 50 | 51 | 52 | 53 | 54 | 55 | \guisec{Clean-up functions} 56 | 57 | \code 58 | 59 | 60 | void udeng_DeleteGen (unif01_Gen * gen); 61 | \endcode 62 | \tab Frees the dynamic memory used by any generator of this module 63 | that does not have an explicit {\tt Delete} function. 64 | This function should be called when a generator 65 | is no longer in use. 66 | \endtab 67 | 68 | \code 69 | \hide 70 | #endif 71 | \endhide 72 | \endcode 73 | -------------------------------------------------------------------------------- /param/LCGBad2.par: -------------------------------------------------------------------------------- 1 | # Package: TestU01 2 | # File: LCGBad2.par 3 | 4 | # Description: Parameter values for the bad2 (with respect to the spectral 5 | # test in 2 dimensions) LCG. The figure of merit S_2 in dimension 2 is 6 | # approximately 0.05. 7 | #----------------------------------------------------------------- 8 | 9 | # Give the name of the family first 10 | 11 | LCGBad2 12 | 13 | 14 | # For each generator, the following parameters must be given in 15 | # the right order on the same line 16 | # h m a 17 | # where h is (very close to) the base-2 logarithm of m, m is the modulus, 18 | # and a is the multiplier, the constant c is 0. The multiplier a has been 19 | # chosen in such a way that a*m < 2^{53}. Thus we use the floating-point 20 | # version of the LCG as it is often faster than the integer version. 21 | 22 | 10 1021 127 23 | 11 2039 1359 24 | 12 4093 5 25 | 13 8191 2341 26 | 14 16381 2731 27 | 15 32749 10 28 | 16 65521 17 29 | 17 131071 68985 30 | 18 262139 203883 31 | 19 524287 458756 32 | 20 1048573 213598 33 | 21 2097143 202947 34 | 22 4194301 4079911 35 | 23 8388593 2696339 36 | 24 16777213 486293 37 | 25 33554393 5431467 38 | 26 67108859 42038579 39 | 27 134217689 24990322 40 | 28 268435399 31842465 41 | 29 536870909 8903330 42 | 30 1073741789 3930720 43 | 31 2147483647 868723 44 | 45 | 32 4294967291 1123161 46 | 33 8589934583 1026767 47 | 34 17179869143 10045 48 | 35 34359738337 10052 49 | 36 68719476731 102254510 50 | 37 137438953447 87666368 51 | 38 274877906899 1045020214 52 | 39 549755813881 809807353 53 | 40 1099511627689 87666376 54 | -------------------------------------------------------------------------------- /testu01/title.tex: -------------------------------------------------------------------------------- 1 | \begin {titlepage} 2 | 3 | \null 4 | \begin {flushright} \it This version: \today \end {flushright} 5 | 6 | \vfill 7 | \begin{center} 8 | {\Large\bf TestU01} \\ \ \\ 9 | {\large\bf A Software Library in ANSI C \\[6pt] 10 | for Empirical Testing of Random Number Generators}\\ 11 | \vfill 12 | {\bf User's guide, 13 | \ifdetailed detailed version \else compact version \fi } 14 | \vfill 15 | Pierre L'Ecuyer and Richard Simard \\[10pt] 16 | D\'epartement d'Informatique et de Recherche Op\'erationnelle \\ 17 | Universit\'e de Montr\'eal \\ 18 | \end{center} 19 | \vfill 20 | 21 | This document describes the software library {\em TestU01}, 22 | implemented in the ANSI C language, 23 | and offering a collection of utilities for the (empirical) 24 | statistical testing of uniform random number generators (RNG). 25 | 26 | The library implements several types of generators in 27 | generic form, as well as many specific generators proposed in 28 | the literature or found in widely-used software. 29 | It provides general implementations of the classical statistical tests 30 | for random number generators, as well as several others proposed in the 31 | literature, and some original ones. 32 | These tests can be applied to the generators predefined in the library 33 | and to user-defined generators. 34 | Specific tests suites for either sequences of uniform random numbers 35 | in $[0,1]$ or bit sequences are also available. 36 | Basic tools for plotting vectors of points produced by generators 37 | are provided as well. 38 | 39 | Additional software permits one to perform 40 | systematic studies of the interaction between a specific test 41 | and the structure of the point sets produced by a given family of RNGs. 42 | That is, for a given kind of test and a given class of RNGs, 43 | to determine how large should be the sample size of the test, 44 | as a function of the generator's period length, 45 | before the generator starts to fail the test systematically. 46 | 47 | \vfill 48 | \end{titlepage} 49 | 50 | -------------------------------------------------------------------------------- /param/LFSR2.par: -------------------------------------------------------------------------------- 1 | # Package: TestU01 2 | # File: LFSR2.par 3 | 4 | # Description: Parameter values for the LFSR2 generators. 5 | #----------------------------------------------------------------- 6 | 7 | # Give the name of the family first 8 | 9 | LFSR2 10 | 11 | 12 | # For each generator, the following parameters must be given in 13 | # the right order on three lines 14 | # LSize 15 | # k1 q1 s1 16 | # k2 q2 s2 17 | # where the parameters are the same as in utaus_CreateCombTaus2. 18 | 19 | # The following parameters are the results of exhaustive searches. 20 | # All are ME-CF, except where mentioned. 21 | 22 | 23 | 10 24 | 7 1 2 25 | 3 1 1 26 | 27 | 11 28 | 6 1 1 29 | 5 2 2 30 | 31 | 12 32 | 7 1 5 # Not ME 33 | 5 2 1 34 | 35 | 13 36 | 7 1 3 37 | 6 1 4 38 | 39 | 14 40 | 9 4 3 41 | 5 2 2 42 | 43 | 15 44 | 11 2 6 45 | 4 1 1 46 | 47 | 16 48 | 11 2 3 49 | 5 2 2 50 | 51 | 17 52 | 10 3 5 53 | 7 3 3 54 | 55 | 18 56 | 11 2 5 57 | 7 1 2 58 | 59 | 19 60 | 10 3 4 61 | 9 4 2 62 | 63 | 20 64 | 11 2 8 # Not ME 65 | 9 4 4 66 | 67 | 21 68 | 11 2 3 69 | 10 3 4 70 | 71 | 22 72 | 15 4 8 73 | 7 1 6 74 | 75 | 23 76 | 17 3 10 77 | 6 1 1 78 | 79 | 24 80 | 17 3 7 81 | 7 1 5 # Not ME 82 | 83 | 25 84 | 18 7 5 85 | 7 1 4 86 | 87 | 26 88 | 15 7 4 89 | 11 2 7 90 | 91 | 27 92 | 17 5 10 93 | 10 3 2 94 | 95 | 28 96 | 17 3 11 # Not ME 97 | 11 2 8 98 | 99 | 29 100 | 18 7 10 101 | 11 2 6 102 | 103 | 30 104 | 21 2 12 # Not ME 105 | 9 4 5 106 | 107 | 31 108 | 20 3 8 # Only ME, not CF 109 | 11 2 6 110 | 111 | 32 112 | 17 3 12 113 | 15 4 6 114 | 115 | 33 116 | 23 5 10 # Only ME, not CF 117 | 10 3 4 118 | 119 | 34 120 | 23 5 8 121 | 11 2 7 122 | 123 | 35 124 | 18 7 11 125 | 17 5 8 126 | 127 | 36 128 | 25 7 14 129 | 11 2 5 130 | -------------------------------------------------------------------------------- /examples/fcoll.res2.tex: -------------------------------------------------------------------------------- 1 | 2 | 3 | \begin {table} 4 | \centering 5 | \caption {The $p$-values of the collision test for the good LCGs, 6 | for $t=2$ and $k\approx 2^i$.} 7 | \label {tab:coll11} 8 | \smallskip 9 | Total CPU time: 00:00:06.69\\[4pt] 10 | 11 | \begin {tabular}{|c|@{\extracolsep{10pt}}ccccc|} 12 | % \multicolumn{6}{l}{\makebox[0pt][l]{fmultin\_Serial1: Collision test, p-value for discrete statistic}}\\ 13 | \hline 14 | LSize & $ j= 1 $ & $ j= 2 $ & $ j= 3 $ & $ j= 4 $ & $ j= 5$ \\ 15 | \hline 16 | 10 & & & --1.0e--5\phantom{0} & --1.1e--12 & \eps \\ 17 | 11 & & --2.5e--4 & --6.3e--9\phantom{0} & \epsm & 1.1e--6 \\ 18 | 12 & & & --1.1e--4\phantom{0} & \epsm & \epsm \\ 19 | 13 & & & --9.0e--5\phantom{0} & --6.0e--14 & \epsm \\ 20 | 14 & & & --1.5e--5\phantom{0} & --9.4e--15 & \epsm \\ 21 | 15 & & --2.9e--3 & --9.0e--8\phantom{0} & \epsm & \epsm \\ 22 | 16 & & --3.2e--4 & --3.5e--9\phantom{0} & \epsm & \epsm \\ 23 | 17 & & --3.0e--3 & --1.6e--5\phantom{0} & \epsm & \epsm \\ 24 | 18 & & & --6.6e--4\phantom{0} & \epsm & \epsm \\ 25 | 19 & & --3.0e--3 & --7.0e--11 & \epsm & \epsm \\ 26 | 20 & & --3.3e--4 & --6.0e--10 & \epsm & \epsm \\ 27 | 21 & & --3.0e--3 & --4.7e--5\phantom{0} & \epsm & \epsm \\ 28 | 22 & & & --2.9e--4\phantom{0} & --7.1e--12 & \epsm \\ 29 | 23 & & --3.3e--4 & --4.1e--9\phantom{0} & \epsm & \epsm \\ 30 | 24 & & --3.3e--4 & --4.1e--13 & \epsm & \epsm \\ 31 | 25 & & & --4.5e--7\phantom{0} & \epsm & \epsm \\ 32 | 26 & & --3.0e--3 & --1.1e--7\phantom{0} & \epsm & \epsm \\ 33 | 27 & & --3.0e--3 & --1.1e--7\phantom{0} & \epsm & \epsm \\ 34 | 28 & & & --2.8e--3\phantom{0} & \epsm & \epsm \\ 35 | 29 & & --3.4e--4 & --1.3e--14 & \epsm & \epsm \\ 36 | 30 & & & --5.6e--6\phantom{0} & \epsm & \epsm \\ 37 | \hline 38 | \end {tabular} \\ 39 | \medskip 40 | 41 | \end {table} 42 | -------------------------------------------------------------------------------- /mylib/mystr.tex: -------------------------------------------------------------------------------- 1 | \defmodule {mystr} 2 | 3 | This module offers some tools for the manipulation of 4 | character strings. 5 | 6 | \bigskip\hrule 7 | \code\iffalse 8 | /* mystr.h for ANSI C */ 9 | 10 | #ifndef MYSTR_H 11 | #define MYSTR_H 12 | \fi 13 | 14 | void mystr_Delete (char S[], unsigned int index, unsigned int len); 15 | \endcode 16 | \tab Deletes {\tt len} characters from S, starting at position 17 | {\tt index}. 18 | \endtab 19 | \code 20 | 21 | 22 | void mystr_Insert (char Res[], char Source[], unsigned int Pos); 23 | \endcode 24 | \tab Inserts the string {\tt Source} into {\tt Res}, 25 | starting at position {\tt Pos}. 26 | \endtab 27 | \code 28 | 29 | 30 | void mystr_ItemS (char R[], char S[], const char T[], unsigned int N); 31 | \endcode 32 | \tab Returns in R the N-th substring of S (counting from 0). 33 | Substrings are delimited by any character from the set T. 34 | \endtab 35 | \code 36 | 37 | 38 | int mystr_Match (char Source[], char Pattern[]); 39 | \endcode 40 | \tab Returns {\tt 1} if the string {\tt Source} matches the 41 | string {\tt Pattern}, and {\tt 0} otherwise. 42 | The characters ``?'' and ``*'' are recognized as wild characters in the 43 | string {\tt Pattern}. 44 | \endtab 45 | \code 46 | 47 | 48 | void mystr_Slice (char R[], char S[], unsigned int P, unsigned int L); 49 | \endcode 50 | \tab Returns in {\tt R} the substring in {\tt S} beginning at 51 | position {\tt P} and of length {\tt L}. 52 | \endtab 53 | \code 54 | 55 | 56 | void mystr_Subst (char Source[], char OldPattern[], char NewPattern[]); 57 | \endcode 58 | \tab Searches for the string {\tt OldPattern} in the string {\tt Source}, 59 | and replaces its first occurence with {\tt NewPattern}. 60 | \endtab 61 | \code 62 | 63 | 64 | void mystr_Position (char Substring[], char Source[], unsigned int at, 65 | unsigned int * pos, int * found); 66 | \endcode 67 | \tab Searches for the string {\tt Substring} in the string {\tt Source}, 68 | starting at position {\tt at}, and returns the position of its first 69 | occurence in {\tt pos}. 70 | \endtab 71 | \code 72 | \iffalse 73 | 74 | #endif 75 | \fi\endcode 76 | -------------------------------------------------------------------------------- /examples/fbirth.res2.tex: -------------------------------------------------------------------------------- 1 | 2 | \begin {table} 3 | \centering 4 | \caption {The right $p$-values $P[Y \ge y]$ of the BirthdaySpacings test 5 | for the LCGPow2s.} 6 | \label {tab:birth.res2} 7 | \smallskip 8 | Total CPU time: 00:00:00.07\\[4pt] 9 | 10 | \begin {tabular}{|c|@{\extracolsep{10pt}}ccccc|} 11 | \hline 12 | LSize & $ j= 1 $ & $ j= 2 $ & $ j= 3 $ & $ j= 4 $ & $ j= 5$ \\ 13 | \hline 14 | 10 & --- & 3.8e--3\phantom{0} & 3.7e--62\phantom{0} & 4.9e--223 & --- \\ 15 | 11 & --- & 1.1e--5\phantom{0} & 5.2e--69\phantom{0} & 2.2e--257 & \eps \\ 16 | 12 & & 1.1e--7\phantom{0} & 1.4e--55\phantom{0} & \eps & \eps \\ 17 | 13 & & 1.0e--8\phantom{0} & 1.3e--65\phantom{0} & \eps & \eps \\ 18 | 14 & & 1.1e--7\phantom{0} & 5.3e--76\phantom{0} & \eps & \eps \\ 19 | 15 & & 1.1e--6\phantom{0} & 3.0e--74\phantom{0} & \eps & \eps \\ 20 | 16 & & 3.7e--3\phantom{0} & 7.4e--85\phantom{0} & \eps & \eps \\ 21 | 17 & & 8.3e--5\phantom{0} & 3.2e--101 & \eps & \eps \\ 22 | 18 & & 1.1e--7\phantom{0} & 8.5e--107 & \eps & \eps \\ 23 | 19 & & 6.4e--11 & 4.2e--118 & \eps & \eps \\ 24 | 20 & & 8.3e--5\phantom{0} & 6.1e--105 & \eps & \eps \\ 25 | 21 & & 3.7e--3\phantom{0} & 8.3e--107 & \eps & \eps \\ 26 | 22 & & 1.0e--5\phantom{0} & 3.3e--116 & \eps & \eps \\ 27 | 23 & & 6.4e--11 & 4.2e--118 & \eps & \eps \\ 28 | 24 & & 1.9e--14 & 2.7e--81\phantom{0} & \eps & \eps \\ 29 | 25 & & 1.1e--6\phantom{0} & 3.9e--163 & \eps & \eps \\ 30 | 26 & & 1.1e--7\phantom{0} & 4.2e--118 & \eps & \eps \\ 31 | 27 & & 1.0e--8\phantom{0} & 2.3e--137 & \eps & \eps \\ 32 | 28 & & 1.0e--5\phantom{0} & 9.4e--126 & \eps & \eps \\ 33 | 29 & & 8.3e--10 & 2.3e--137 & \eps & \eps \\ 34 | 30 & & 1.9e--14 & 5.2e--120 & \eps & \eps \\ 35 | \hline 36 | \end {tabular} \\ 37 | \medskip 38 | \end {table} 39 | -------------------------------------------------------------------------------- /param/LFSR3.par: -------------------------------------------------------------------------------- 1 | # Package: TestU01 2 | # File: LFSR3.par 3 | 4 | # Description: Parameter values for the LFSR3 generators. 5 | #----------------------------------------------------------------- 6 | 7 | # Give the name of the family first 8 | 9 | LFSR3 10 | 11 | 12 | # For each generator, the following parameters must be given in 13 | # the right order on four lines 14 | # LSize 15 | # k1 q1 s1 16 | # k2 q2 s2 17 | # k3 q3 s3 18 | # where the parameters are the same as in utaus_CreateCombTaus3. 19 | 20 | # The following parameters are the results of exhaustive searches. 21 | # All are ME-CF, except where mentioned. 22 | 23 | 24 | 14 25 | 7 3 3 26 | 4 1 2 27 | 3 1 2 28 | 29 | 15 30 | 7 1 2 # Not ME: Somme des ecarts = 1 31 | 5 2 3 32 | 3 1 1 33 | 34 | 16 35 | 7 1 3 # Not ME: Somme des ecarts = 1 36 | 5 2 3 37 | 4 1 2 38 | 39 | 17 40 | 7 1 1 41 | 6 1 5 42 | 4 1 2 43 | 44 | 18 45 | 7 1 5 46 | 6 1 1 47 | 5 2 3 48 | 49 | 19 50 | 11 2 4 51 | 5 2 2 52 | 3 1 2 53 | 54 | 20 55 | 9 4 3 # ME but not CF. 56 | 7 1 5 57 | 4 1 1 58 | 59 | 21 60 | 9 4 3 61 | 7 1 5 62 | 5 2 1 63 | 64 | 22 65 | 11 2 8 66 | 6 1 4 67 | 5 2 3 68 | 69 | 23 70 | 11 2 2 71 | 7 1 4 72 | 5 2 3 73 | 74 | 24 75 | 11 2 7 # ME but not CF 76 | 7 1 2 77 | 6 1 5 78 | 79 | 25 80 | 11 2 3 # Not ME. Somme des ecarts = 1 81 | 9 4 1 82 | 5 2 2 83 | 84 | 26 85 | 10 3 2 86 | 9 4 3 87 | 7 3 1 88 | 89 | 27 90 | 11 2 2 91 | 9 4 3 92 | 7 3 4 93 | 94 | 28 95 | 11 2 4 96 | 10 3 7 97 | 7 3 3 98 | 99 | 29 100 | 17 3 4 101 | 7 1 2 102 | 5 2 3 103 | 104 | 30 105 | 11 2 3 # Not ME. Somme des ecarts = 2 106 | 10 3 5 107 | 9 4 2 108 | 109 | 31 110 | 17 3 7 111 | 9 4 5 112 | 5 2 2 113 | 114 | 32 115 | 15 1 8 # ME but not CF. 116 | 11 2 3 117 | 6 1 1 118 | 119 | 33 120 | 17 3 9 121 | 9 4 5 122 | 7 3 2 123 | 124 | 34 125 | 17 3 4 126 | 10 3 2 127 | 7 1 3 128 | 129 | 35 130 | 17 3 4 131 | 11 2 6 132 | 7 1 5 133 | 134 | 36 135 | 17 5 8 136 | 10 3 5 137 | 9 4 1 138 | -------------------------------------------------------------------------------- /mkinstalldirs: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # mkinstalldirs --- make directory hierarchy 3 | # Author: Noah Friedman 4 | # Created: 1993-05-16 5 | # Public domain 6 | 7 | errstatus=0 8 | dirmode="" 9 | 10 | usage="\ 11 | Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..." 12 | 13 | # process command line arguments 14 | while test $# -gt 0 ; do 15 | case "${1}" in 16 | -h | --help | --h* ) # -h for help 17 | echo "${usage}" 1>&2; exit 0 ;; 18 | -m ) # -m PERM arg 19 | shift 20 | test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; } 21 | dirmode="${1}" 22 | shift ;; 23 | -- ) shift; break ;; # stop option processing 24 | -* ) echo "${usage}" 1>&2; exit 1 ;; # unknown option 25 | * ) break ;; # first non-opt arg 26 | esac 27 | done 28 | 29 | for file 30 | do 31 | if test -d "$file"; then 32 | shift 33 | else 34 | break 35 | fi 36 | done 37 | 38 | case $# in 39 | 0) exit 0 ;; 40 | esac 41 | 42 | case $dirmode in 43 | '') 44 | if mkdir -p -- . 2>/dev/null; then 45 | echo "mkdir -p -- $*" 46 | exec mkdir -p -- "$@" 47 | fi ;; 48 | *) 49 | if mkdir -m "$dirmode" -p -- . 2>/dev/null; then 50 | echo "mkdir -m $dirmode -p -- $*" 51 | exec mkdir -m "$dirmode" -p -- "$@" 52 | fi ;; 53 | esac 54 | 55 | for file 56 | do 57 | set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` 58 | shift 59 | 60 | pathcomp= 61 | for d 62 | do 63 | pathcomp="$pathcomp$d" 64 | case "$pathcomp" in 65 | -* ) pathcomp=./$pathcomp ;; 66 | esac 67 | 68 | if test ! -d "$pathcomp"; then 69 | echo "mkdir $pathcomp" 70 | 71 | mkdir "$pathcomp" || lasterr=$? 72 | 73 | if test ! -d "$pathcomp"; then 74 | errstatus=$lasterr 75 | else 76 | if test ! -z "$dirmode"; then 77 | echo "chmod $dirmode $pathcomp" 78 | 79 | lasterr="" 80 | chmod "$dirmode" "$pathcomp" || lasterr=$? 81 | 82 | if test ! -z "$lasterr"; then 83 | errstatus=$lasterr 84 | fi 85 | fi 86 | fi 87 | fi 88 | 89 | pathcomp="$pathcomp/" 90 | done 91 | done 92 | 93 | exit $errstatus 94 | 95 | # Local Variables: 96 | # mode: shell-script 97 | # sh-indentation: 3 98 | # End: 99 | # mkinstalldirs ends here 100 | -------------------------------------------------------------------------------- /testu01/rijndael-alg-fst.tex: -------------------------------------------------------------------------------- 1 | \code 2 | /* Remarks for TestU01: 3 | * The only changes I have made in the authors' code below is to rename the 4 | * types u8, u32. I have also removed 3 unused defined constants. 5 | * (R. Simard for TestU01) 6 | * 7 | *===========================================================================*/ 8 | 9 | /** 10 | * rijndael-alg-fst.h 11 | * 12 | * @version 3.0 (December 2000) 13 | * 14 | * Optimised ANSI C code for the Rijndael cipher (now AES) 15 | * 16 | * @author Vincent Rijmen 17 | * @author Antoon Bosselaers 18 | * @author Paulo Barreto 19 | * 20 | * This code is hereby placed in the public domain. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS 23 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 24 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE 26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 29 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 30 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 31 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 32 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | #ifndef __RIJNDAEL_ALG_FST_H 35 | #define __RIJNDAEL_ALG_FST_H 36 | #include "gdef.h" 37 | 38 | 39 | int rijndaelKeySetupEnc(uint32_t rk[/*4*(Nr + 1)*/], const uint8_t cipherKey[], int keyBits); 40 | int rijndaelKeySetupDec(uint32_t rk[/*4*(Nr + 1)*/], const uint8_t cipherKey[], int keyBits); 41 | void rijndaelEncrypt(const uint32_t rk[/*4*(Nr + 1)*/], int Nr, const uint8_t pt[16], uint8_t ct[16]); 42 | void rijndaelDecrypt(const uint32_t rk[/*4*(Nr + 1)*/], int Nr, const uint8_t ct[16], uint8_t pt[16]); 43 | 44 | #ifdef INTERMEDIATE_VALUE_KAT 45 | void rijndaelEncryptRound(const uint32_t rk[/*4*(Nr + 1)*/], int Nr, uint8_t block[16], int rounds); 46 | void rijndaelDecryptRound(const uint32_t rk[/*4*(Nr + 1)*/], int Nr, uint8_t block[16], int rounds); 47 | #endif /* INTERMEDIATE_VALUE_KAT */ 48 | 49 | #endif /* __RIJNDAEL_ALG_FST_H */ 50 | \endcode 51 | -------------------------------------------------------------------------------- /testu01/uweyl.tex: -------------------------------------------------------------------------------- 1 | \defmodule{uweyl} 2 | 3 | This module implements simple and combined generators based on 4 | Weyl sequences, proposed by Holian et al.\ \cite{rHOL94a}. 5 | \index{Generator!Weyl} 6 | 7 | 8 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 9 | \bigskip 10 | \hrule 11 | \code 12 | \hide 13 | #ifndef UWEYL_H 14 | #define UWEYL_H 15 | /* uweyl.h for ANSI C */ 16 | \endhide 17 | #include "unif01.h" 18 | 19 | 20 | unif01_Gen * uweyl_CreateWeyl (double alpha, long n0); 21 | \endcode 22 | \tab Implements a generator defined by the 23 | Weyl sequence: 24 | \eq 25 | u_n = n \alpha \mod 1 = (u_{n-1} + \alpha) \mod 1, 26 | \endeq 27 | where $\alpha = $ {\tt alpha} is a real number in the interval $(0,1)$. 28 | The initial value of $n$ is {\tt n0}. 29 | In theory, if $\alpha$ is irrationnal, this sequence is asymptotically 30 | equidistributed over (0,1) \cite {rWEY16a}. 31 | However, this is not true for the present 32 | %% \hrichard{remplacer par for any computer? Non} 33 | implementation, because 34 | $\alpha$ is represented only with finite precision. 35 | The implementation is only a rough approximation, 36 | valid when $n$ is not too large. 37 | Some possible values for $\alpha$ are: 38 | \begin {eqnarray*} 39 | \sqrt{2} \mod 1 &=& 0.414213562373095 \\ 40 | \sqrt{3} \mod 1 &=& 0.732050807568877 \\ 41 | \pi \mod 1 &=& 0.141592653589793 \\ 42 | e \mod 1 &=& 0.718281828459045 \\ 43 | \gamma &=& 0.577215664901533 \\ 44 | \end {eqnarray*} 45 | \endtab 46 | \code 47 | 48 | unif01_Gen * uweyl_CreateNWeyl (double alpha, long n0); 49 | \endcode 50 | \tab Implements a nested Weyl generator, as suggested in \cite{rHOL94a}, 51 | defined by 52 | \eq 53 | u_n = (n\, (n\alpha \mod 1)) \mod 1, 54 | \endeq 55 | where {\tt alpha} $= \alpha \in (0,1)$. 56 | The initial value of $n$ is {\tt n0}. 57 | \endtab 58 | \code 59 | 60 | 61 | unif01_Gen * uweyl_CreateSNWeyl (long m, double alpha, long n0); 62 | \endcode 63 | \tab Implements a nested Weyl generator with 64 | ``shuffling'', proposed in \cite{rHOL94a}, and defined by 65 | \begin {eqnarray*} 66 | \nu_n = m\, (n\, (n \alpha \mod 1) \mod 1) + 1/2, 67 | \qquad u_n = (\nu_n\, (\nu_n \alpha \mod 1)) \mod 1, 68 | \end {eqnarray*} 69 | where $m$ is a large positive integer and {\tt alpha} $=\alpha \in (0,1)$. 70 | The initial value of $n$ is {\tt n0}. 71 | \endtab 72 | 73 | 74 | 75 | \guisec{Clean-up functions} 76 | \code 77 | 78 | void uweyl_DeleteGen (unif01_Gen *gen); 79 | \endcode 80 | \tab \DelGen 81 | \endtab 82 | \code 83 | \hide 84 | #endif 85 | \endhide 86 | \endcode 87 | -------------------------------------------------------------------------------- /param/MRG2.par: -------------------------------------------------------------------------------- 1 | # Package: TestU01 2 | # File: MRG2.par 3 | 4 | # Description: Parameter values for the MRG of order 2. They have a good 5 | # lattice structure up to dimension 8 (at least), with a prime 6 | # modulus $m$ just below $2^{i/2}$ and period length $m^2-1$. 7 | 8 | #----------------------------------------------------------------- 9 | 10 | # Give the name of the family first 11 | 12 | MRG2 13 | 14 | # For each generator, the following parameters must be given in 15 | # the right order on the same line 16 | # h m a0 a1 17 | # where h is the lsize, m is the modulus, a0 and a1 are the multipliers. 18 | # 19 | 20 | 20 1021 730 663 21 | 21 1447 196 -533 22 | 22 2039 1805 1930 23 | 23 2887 2665 -1633 24 | 24 4093 1172 770 25 | 25 5791 496 -3921 26 | 26 8191 4837 7660 27 | 27 11579 5452 -3612 28 | 28 16381 13073 1997 29 | 29 23167 2502 -6323 30 | 30 32749 9343 6439 31 | 31 46337 18036 -46220 32 | 32 65521 35907 30770 33 | 33 92681 62875 -68441 34 | 34 131071 55544 90795 35 | 35 185363 122015 -54479 36 | 36 262139 21830 162959 37 | 37 370723 158214 -171270 38 | 38 524287 396733 446660 39 | 39 741431 528783 -723184 40 | 40 1048573 633537 57143 41 | 41 1482907 456124 -1294947 42 | 42 2097143 132547 1642238 43 | 43 2965819 2675288 -804847 44 | 44 4194301 173405 3471693 45 | 45 5931641 936277 -163136 46 | 46 8388593 1439561 1830242 47 | 47 11863279 11265990 -7978568 48 | 48 16777213 10355898 1875483 49 | 49 23726561 14681237 -21097402 50 | 50 33554393 23321560 483332 51 | 51 47453111 36472661 -1279605 52 | 52 67108859 59310754 15280366 53 | 53 94906249 59517650 -92194958 54 | 54 134217689 16626702 26032456 55 | 55 189812507 43186395 -45884916 56 | 56 268435399 31958755 -28056245 57 | 57 379625047 8207583 -9894783 58 | 58 536870909 6284080 4697886 59 | 59 759250111 11568066 -8989107 60 | 60 1073741789 5796676 -4321746 61 | -------------------------------------------------------------------------------- /param/LCGGood.par: -------------------------------------------------------------------------------- 1 | # Package: TestU01 2 | # File: LCGGood.par 3 | 4 | # Description: Parameter values for the good (with respect to the spectral 5 | # test in up to dimension 8) LCG (Linear Congruential Generators). 6 | # The values are taken from L'Ecuyer's article latrules \cite{rLEC99c}. 7 | #----------------------------------------------------------------- 8 | 9 | # Give the name of the family first 10 | 11 | LCGGood 12 | 13 | 14 | # For each generator, the following parameters must be given in 15 | # the right order on the same line 16 | # h m a 17 | # where h is (very close to) the base-2 logarithm of m, m is the modulus, 18 | # and a is the multiplier, the constant c is 0. The multiplier a has been 19 | # chosen in such a way that a*m < 2^{53}. Thus we use the floating-point 20 | # version of the LCG as it is often faster than the integer version. 21 | 22 | 10 1021 65 23 | 11 2039 995 24 | 12 4093 209 25 | 13 8191 884 26 | 14 16381 572 27 | 15 32749 219 28 | 16 65521 17364 29 | 17 131071 43165 30 | 18 262139 92717 31 | 19 524287 283741 32 | 20 1048573 380985 33 | 21 2097143 360889 34 | 22 4194301 914334 35 | 23 8388593 653276 36 | 24 16777213 6423135 37 | 25 33554393 25907312 38 | 26 67108859 26590841 39 | 27 134217689 45576512 40 | 28 268435399 31792125 41 | 29 536870909 16538103 42 | 30 1073741789 5122456 43 | 31 2147483647 1389796 44 | 45 | 32 4294967291 1588635695 46 | 33 8589934583 7425194315 47 | 34 17179869143 5295517759 48 | 35 34359738337 3124199165 49 | 36 68719476731 49865143810 50 | 37 137438953447 76886758244 51 | 38 274877906899 17838542566 52 | 39 549755813881 61992693052 53 | 40 1099511627689 1038914804222 54 | 41 2199023255531 1013262675629 55 | 42 4398046511093 2214813540776 56 | 43 8796093022151 4114249742626 57 | 44 17592186044399 6307617245999 58 | 45 35184372088777 25933916233908 59 | 46 70368744177643 63975993200055 60 | 47 140737488355213 102306498730560 61 | 48 281474976710597 49235258628958 62 | 49 562949953421231 265609885904224 63 | 50 1125899906842597 1087141320185010 64 | 51 2251799813685119 349044191547257 65 | 52 4503599627370449 4359287924442956 66 | 53 9007199254740881 2333175048965096 67 | 54 18014398509481951 17554612001638734 68 | 55 36028797018963913 33266544676670489 69 | 56 72057594037927931 39159994680362565 70 | 57 144115188075855859 75953708294752990 71 | 58 288230376151711717 252847049180516155 72 | 59 576460752303423433 346764851511064641 73 | 60 1152921504606846883 561860773102413563 74 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TestU01-2009 2 | This is the 2009 version of TestU01, a software library, implemented in the ANSI C language, and offering a collection of utilities for the empirical statistical testing of uniform random number generators. This 32-bit version is still the current official version, although a 64-bit version with many improvements is currently under development and may become available in late 2022. 3 | 4 | The library implements several types of random number generators in generic form, as well as many specific generators proposed in the literature or found in widely-used software. It provides general implementations of the classical statistical tests for random number generators, as well as several others proposed in the literature, and some original ones. These tests can be applied to the generators predefined in the library and to user-defined generators. Specific tests suites for either sequences of uniform random numbers in [0,1] or bit sequences are also available. Basic tools for plotting vectors of points produced by generators are provided as well. 5 | 6 | Additional software permits one to perform systematic studies of the interaction between a specific test and the structure of the point sets produced by a given family of random number generators. That is, for a given kind of test and a given class of random number generators, to determine how large should be the sample size of the test, as a function of the generator's period length, before the generator starts to fail the test systematically. 7 | 8 | The documentation with a description of the functions in TestU01 is available in the user's guide below. 9 | 10 | ## TestU01-1.2.3 11 | This version was created on 18 August 2009. 12 | 13 | - Licence and [copyright](http://simul.iro.umontreal.ca/testu01/copyright.html). 14 | - The installation uses configure. 15 | - [Binaries for Cygwin under MS Windows](http://simul.iro.umontreal.ca/testu01/bin-cygwin.zip) 16 | - [Binaries for MinGW under MS Windows](http://simul.iro.umontreal.ca/testu01/bin-mingw.zip) 17 | - [Installation](http://simul.iro.umontreal.ca/testu01/install.html) 18 | - [User's guide](http://simul.iro.umontreal.ca/testu01/guideshorttestu01.pdf) (pdf) 19 | - [Paper](http://portal.acm.org/citation.cfm?doid=1268776.1268777) (pdf) describing TestU01 with results from our test suites applied on several popular generators: P. L'Ecuyer and R. Simard, TestU01: A C Library for Empirical Testing of Random Number Generators ACM Transactions on Mathematical Software, Vol. 33, article 22, 2007. 20 | ERRATUM: The period of generator Brent-xor4096s in Table I should be 2^4128 and not 2^131072. 21 | 22 | ## Contact us 23 | To submit a bug or a comment, send an e-mail to: 24 | [simul@iro.umontreal.ca](simul@iro.umontreal.ca) 25 | or create a pull request. 26 | -------------------------------------------------------------------------------- /mylib/addstr.tex: -------------------------------------------------------------------------------- 1 | \defmodule {addstr} 2 | 3 | The functions described here are convenient tools for constructing 4 | character strings that contain a series of numeric parameters, 5 | with their values. 6 | For example, suppose one wishes to put 7 | ``{\tt LCG with m = 101, a = 12, s = 1}'' in the string {\tt str}, 8 | where the actual 9 | numbers 101, 12, and 1 must be taken as the values of {\tt long} 10 | integer variables {\tt m}, {\tt a}, and {\tt s}. 11 | This can be achieved by the instructions: 12 | \vcode 13 | 14 | strcpy (str, "LCG with "); 15 | addstr\_Long (str, " m = ", m); 16 | addstr\_Long (str, ", a = ", m); 17 | addstr\_Long (str, ", s = ", s); 18 | \endvcode 19 | 20 | Each function {\tt addstr\_... (char *to, const char *add, ...)} 21 | first appends the string {\tt add} to the string {\tt to}, then 22 | appends to it a character string representation of the number 23 | (or array of numbers) specified by its last parameter. 24 | In the case of an array of numbers (e.g., {\tt addstr\_ArrayLong}), 25 | the parameter {\tt high} specifies the size of the array, and the 26 | elements {\tt [0..high-1]} are added to {\tt str}. 27 | The {\tt ...LONG} versions are for 64-bit integers. 28 | In all cases, the string {\tt to} should be large enough to accomodate 29 | what is appended to it. 30 | 31 | 32 | %%%%%%%%%%%%% 33 | \bigskip\hrule 34 | \code\hide 35 | /* addstr.h for ANSI C */ 36 | #ifndef ADDSTR_H 37 | #define ADDSTR_H 38 | \endhide 39 | #include "gdef.h" 40 | \endcode 41 | 42 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 43 | \guisec{Prototypes} 44 | \code 45 | 46 | void addstr_Int (char *to, const char *add, int n); 47 | 48 | void addstr_Uint (char *to, const char *add, unsigned int n); 49 | 50 | void addstr_Long (char *to, const char *add, long n); 51 | 52 | void addstr_Ulong (char *to, const char *add, unsigned long n); 53 | 54 | void addstr_Double (char *to, const char *add, double x); 55 | 56 | void addstr_Char (char *to, const char *add, char c); 57 | 58 | void addstr_Bool (char *to, const char *add, int b); 59 | \endcode 60 | \code 61 | 62 | #ifdef USE_LONGLONG 63 | void addstr_LONG (char *to, const char *add, longlong n); 64 | 65 | void addstr_ULONG (char *to, const char *add, ulonglong n); 66 | #endif 67 | \endcode 68 | \code 69 | 70 | void addstr_ArrayInt (char *to, const char *add, int high, int []); 71 | 72 | void addstr_ArrayUint (char *to, const char *add, int high, 73 | unsigned int []); 74 | 75 | void addstr_ArrayLong (char *to, const char *add, int high, long []); 76 | 77 | void addstr_ArrayUlong (char *to, const char *add, int high, 78 | unsigned long []); 79 | 80 | void addstr_ArrayDouble (char *to, const char *add, int high, double []); 81 | 82 | \hide 83 | #endif 84 | \endhide 85 | \endcode 86 | 87 | -------------------------------------------------------------------------------- /param/MRG3.par: -------------------------------------------------------------------------------- 1 | # Package: TestU01 2 | # File: MRG3.par 3 | 4 | # Description: Parameter values for the MRG of order 3. They have a good 5 | # lattice structure up to dimension 8 (at least), with a prime 6 | # modulus $m$ just below $2^{i/3}$ and period length $m^3-1$. 7 | 8 | #----------------------------------------------------------------- 9 | 10 | # Give the name of the family first 11 | 12 | MRG3 13 | 14 | # For each generator, the following parameters must be given in 15 | # the right order on the same line 16 | # h m a0 a1 a2 17 | # where h is the lsize, m is the modulus, a0, a1 and a2 are the multipliers. 18 | # 19 | 20 | 30 911 389 411 665 21 | 31 1289 118 343 506 22 | 32 1621 1112 1473 893 23 | 33 1973 735 877 1555 24 | 34 2579 1859 2079 1374 25 | 35 3229 388 2309 2274 26 | 36 3989 1473 1706 3224 27 | 37 5153 2755 1910 3847 28 | 38 6491 2767 615 391 29 | 39 8093 960 5934 5674 30 | 40 10289 4891 7950 8949 31 | 41 13001 9418 10485 6858 32 | 42 16301 5841 6920 12989 33 | 43 20639 15308 3754 3083 34 | 44 25997 5008 7778 23683 35 | 45 32693 11732 13966 26162 36 | 46 41231 10313 33193 13927 37 | 47 51971 13974 39132 30073 38 | 48 65381 14014 39120 30143 39 | 49 82529 1923 56024 7737 40 | 50 103913 40506 59922 68233 41 | 51 130859 46750 71933 62870 42 | 52 164249 83533 83931 6878 43 | 53 208001 44249 162798 116315 44 | 54 262139 112352 202967 95663 45 | 55 329993 44242 261100 181889 46 | 56 415787 293866 214663 214943 47 | 57 524201 177871 399571 161193 48 | 58 660509 109762 457713 345692 49 | 59 832121 109792 556037 411401 50 | 60 1048517 374459 825588 325032 51 | 52 | 63 2096993 767709 1644815 652699 53 | 54 | 66 4194023 1521371 3315922 1275263 55 | 56 | 69 8388371 2995924 6691008 2520492 57 | 58 | 72 16776623 6010556 13375750 5010812 59 | 60 | 75 33554393 12039895 26777810 9991554 61 | 62 | 78 67108721 24065767 53614836 19985837 63 | 64 | 81 134217467 12039879 26777852 9991570 65 | 66 | 84 268434827 6010521 13375757 5010878 67 | 68 | 87 536870267 2995942 6691051 2520445 69 | 70 | 90 1073740163 1521397 3315999 1275337 71 | -------------------------------------------------------------------------------- /include/config.h.in: -------------------------------------------------------------------------------- 1 | /* include/config.h.in. Generated from configure.ac by autoheader. */ 2 | 3 | /* Define to 1 if you have the header file. */ 4 | #undef HAVE_DLFCN_H 5 | 6 | /* Define to 1 if you have the `erf' function. */ 7 | #undef HAVE_ERF 8 | 9 | /* Define to 1 if you have the header file. */ 10 | #undef HAVE_GMP_H 11 | 12 | /* Define to 1 if you have the header file. */ 13 | #undef HAVE_INTTYPES_H 14 | 15 | /* Define to 1 if you have the `lgamma' function. */ 16 | #undef HAVE_LGAMMA 17 | 18 | /* Define to 1 if you have the `log1p' function. */ 19 | #undef HAVE_LOG1P 20 | 21 | /* Define to 1 if the system has the type `long long'. */ 22 | #undef HAVE_LONG_LONG 23 | 24 | /* Define when Mathematica is installed */ 25 | #undef HAVE_MATHEMATICA 26 | 27 | /* Define to 1 if you have the header file. */ 28 | #undef HAVE_MEMORY_H 29 | 30 | /* Define to 1 if you have the `random' function. */ 31 | #undef HAVE_RANDOM 32 | 33 | /* Define to 1 if you have the header file. */ 34 | #undef HAVE_STDINT_H 35 | 36 | /* Define to 1 if you have the header file. */ 37 | #undef HAVE_STDLIB_H 38 | 39 | /* Define to 1 if you have the header file. */ 40 | #undef HAVE_STRINGS_H 41 | 42 | /* Define to 1 if you have the header file. */ 43 | #undef HAVE_STRING_H 44 | 45 | /* Define to 1 if you have the header file. */ 46 | #undef HAVE_SYS_STAT_H 47 | 48 | /* Define to 1 if you have the header file. */ 49 | #undef HAVE_SYS_TYPES_H 50 | 51 | /* Define to 1 if you have the header file. */ 52 | #undef HAVE_SYS_UTSNAME_H 53 | 54 | /* Define to 1 if the system has the type `uint32_t'. */ 55 | #undef HAVE_UINT32_T 56 | 57 | /* Define to 1 if the system has the type `uint8_t'. */ 58 | #undef HAVE_UINT8_T 59 | 60 | /* Define to 1 if you have the header file. */ 61 | #undef HAVE_UNISTD_H 62 | 63 | /* Define to 1 if you have the header file. */ 64 | #undef HAVE_WINDOWS_H 65 | 66 | /* Name of package */ 67 | #undef PACKAGE 68 | 69 | /* Define to the address where bug reports for this package should be sent. */ 70 | #undef PACKAGE_BUGREPORT 71 | 72 | /* Define to the full name of this package. */ 73 | #undef PACKAGE_NAME 74 | 75 | /* Define to the full name and version of this package. */ 76 | #undef PACKAGE_STRING 77 | 78 | /* Define to the one symbol short name of this package. */ 79 | #undef PACKAGE_TARNAME 80 | 81 | /* Define to the version of this package. */ 82 | #undef PACKAGE_VERSION 83 | 84 | /* Define to 1 if you have the ANSI C header files. */ 85 | #undef STDC_HEADERS 86 | 87 | /* Version number of package */ 88 | #undef VERSION 89 | 90 | /* Define to 1 if your processor stores words with the most significant byte 91 | first (like Motorola and SPARC, unlike Intel and VAX). */ 92 | #undef WORDS_BIGENDIAN 93 | 94 | /* Define to empty if `const' does not conform to ANSI C. */ 95 | #undef const 96 | 97 | /* Define to `unsigned int' if does not define. */ 98 | #undef size_t 99 | -------------------------------------------------------------------------------- /param/CombL2.par: -------------------------------------------------------------------------------- 1 | # Package: TestU01 2 | # File: CombL2.par 3 | 4 | # Description: Parameter values for the combined LCG with 2 components, 5 | # with a good lattice structure up to dimension 8 (at least). 6 | # The components have distinct prime moduli $m_1$ and $m_2$ 7 | # just below $2^{i/2}$ and the period length is $(m_1-1)(m_2-1)/2$. 8 | # The parameters are chosen to get an excellent value of $M_8$. 9 | #----------------------------------------------------------------- 10 | 11 | # Give the name of the family first 12 | 13 | CombL2 14 | 15 | # For each generator, the following parameters must be given in 16 | # the right order on the same line 17 | # h m1 m2 a1 a2 18 | # where h is the lsize, m1, m2 are the moduli, a1, a2 are the multipliers. 19 | # 20 | 21 | 20 1021 887 299 58 22 | 21 1447 1319 302 740 23 | 22 2039 1907 1190 1747 24 | 23 2887 2819 1991 1689 25 | 24 4093 3947 3701 2946 26 | 25 5791 5639 4007 1110 27 | 26 8191 8039 6033 1412 28 | 27 11579 11423 3469 2224 29 | 28 16381 16223 6943 12052 30 | 29 23167 22943 4458 4768 31 | 30 32749 32603 18484 950 32 | 31 46337 46199 30090 10453 33 | 32 65521 65267 56196 33186 34 | 33 92681 92459 50055 66698 35 | 34 131071 130787 58124 62535 36 | 35 185363 184727 62927 83951 37 | 36 262139 260879 129990 170664 38 | 37 370723 370247 56917 232398 39 | 38 524287 524099 522098 331871 40 | 39 741431 741227 359345 704623 41 | 40 1048573 1048343 67392 885376 42 | 41 1482907 1482263 582455 110266 43 | 42 2097143 2096867 253485 143041 44 | 43 2965819 2965199 2363072 1638245 45 | 44 4194301 4194167 1521356 960675 46 | 45 5931641 5931203 4757768 4554230 47 | 46 8388593 8388287 3767245 4994015 48 | 47 11863279 11863067 3569116 4215227 49 | 48 16777213 16776899 4697850 1826207 50 | 49 23726561 23726063 4264547 8442320 51 | 50 33554393 33553799 23321542 21257326 52 | 51 47453111 47452739 5332562 5283321 53 | 52 67108859 67108187 29916087 15280258 54 | 53 94906249 94905947 34027224 7087788 55 | 54 134217689 134217323 53614808 88545877 56 | 55 189812507 189812303 1367845 28309514 57 | 56 268435399 268435019 9991564 160052200 58 | 57 379625047 379624607 1410469 2962498 59 | 58 536870909 536870723 13375702 535692996 60 | 59 759250111 759250007 4449060 10486370 61 | 60 1073741789 1073740439 3138382 931003446 62 | -------------------------------------------------------------------------------- /param/CombWH2.par: -------------------------------------------------------------------------------- 1 | # Package: TestU01 2 | # File: CombWH2.par 3 | 4 | # Description: Parameter values for the combined LCG with 2 components, 5 | # with a good lattice structure up to dimension 8 (at least). 6 | # The components have distinct prime moduli $m_1$ and $m_2$ 7 | # just below $2^{i/2}$ and the period length is $(m_1-1)(m_2-1)/2$. 8 | # The parameters are chosen to get an excellent value of $M_8$. 9 | #----------------------------------------------------------------- 10 | 11 | # Give the name of the family first 12 | 13 | CombWH2 14 | 15 | # For each generator, the following parameters must be given in 16 | # the right order on the same line 17 | # h m1 m2 a1 a2 18 | # where h is the lsize, m1, m2 are the moduli, a1, a2 are the multipliers. 19 | # 20 | 21 | 20 1021 887 299 58 22 | 21 1447 1319 302 740 23 | 22 2039 1907 1190 1747 24 | 23 2887 2819 1991 1689 25 | 24 4093 3947 3701 2946 26 | 25 5791 5639 4007 1110 27 | 26 8191 8039 6033 1412 28 | 27 11579 11423 3469 2224 29 | 28 16381 16223 6943 12052 30 | 29 23167 22943 4458 4768 31 | 30 32749 32603 18484 950 32 | 31 46337 46199 30090 10453 33 | 32 65521 65267 56196 33186 34 | 33 92681 92459 50055 66698 35 | 34 131071 130787 58124 62535 36 | 35 185363 184727 62927 83951 37 | 36 262139 260879 129990 170664 38 | 37 370723 370247 56917 232398 39 | 38 524287 524099 522098 331871 40 | 39 741431 741227 359345 704623 41 | 40 1048573 1048343 67392 885376 42 | 41 1482907 1482263 582455 110266 43 | 42 2097143 2096867 253485 143041 44 | 43 2965819 2965199 2363072 1638245 45 | 44 4194301 4194167 1521356 960675 46 | 45 5931641 5931203 4757768 4554230 47 | 46 8388593 8388287 3767245 4994015 48 | 47 11863279 11863067 3569116 4215227 49 | 48 16777213 16776899 4697850 1826207 50 | 49 23726561 23726063 4264547 8442320 51 | 50 33554393 33553799 23321542 21257326 52 | 51 47453111 47452739 5332562 5283321 53 | 52 67108859 67108187 29916087 15280258 54 | 53 94906249 94905947 34027224 7087788 55 | 54 134217689 134217323 53614808 88545877 56 | 55 189812507 189812303 1367845 28309514 57 | 56 268435399 268435019 9991564 160052200 58 | 57 379625047 379624607 1410469 2962498 59 | 58 536870909 536870723 13375702 535692996 60 | 59 759250111 759250007 4449060 10486370 61 | 60 1073741789 1073740439 3138382 931003446 62 | -------------------------------------------------------------------------------- /examples/fbirth.res1.tex: -------------------------------------------------------------------------------- 1 | \begin {table} 2 | \centering 3 | \caption {Birthday spacings test: Expected and 4 | observed number of collisions for each $i$ and $j$.} 5 | \label {tab:birth.res1} 6 | \smallskip 7 | %%%%%%%%%%%%%%%%%%%%% 8 | \begin {tabular}{|c|@{\extracolsep{10pt}}rr|rr|rr|rr|rr|} 9 | \hline 10 | LSize& \multicolumn{2}{c|}{$ j=1 $} & \multicolumn{2}{c|}{$ j=2 $} & \multicolumn{2}{c|}{$ j=3 $} & \multicolumn{2}{c|}{$ j=4 $} & \multicolumn{2}{c|}{$ j=5 $} \\ 11 | \hline 12 | 10 & --- & --- & 1.01 & 5 & 1.00 & 48 & 1.00 & 131 & --- & --- \\ 13 | 11 & --- & --- & 1.01 & 8 & 1.00 & 52 & 1.00 & 147 & 1.00 & 377 \\ 14 | 12 & 1.01 & 0 & 1.00 & 10 & 1.00 & 44 & 1.00 & 204 & 1.00 & 447 \\ 15 | 13 & 1.01 & 0 & 1.00 & 11 & 1.00 & 50 & 1.00 & 196 & 1.00 & 579 \\ 16 | 14 & 1.01 & 0 & 1.00 & 10 & 1.00 & 56 & 1.00 & 247 & 1.00 & 662 \\ 17 | 15 & 1.00 & 2 & 1.00 & 9 & 1.00 & 55 & 1.00 & 258 & 1.00 & 911 \\ 18 | 16 & 1.00 & 1 & 1.00 & 5 & 1.00 & 61 & 1.00 & 316 & 1.00 & 958 \\ 19 | 17 & 1.00 & 0 & 1.00 & 7 & 1.00 & 70 & 1.00 & 365 & 1.00 & 1172 \\ 20 | 18 & 1.00 & 1 & 1.00 & 10 & 1.00 & 73 & 1.00 & 385 & 1.00 & 1374 \\ 21 | 19 & 1.00 & 4 & 1.00 & 13 & 1.00 & 79 & 1.00 & 414 & 1.00 & 1600 \\ 22 | 20 & 1.00 & 0 & 1.00 & 7 & 1.00 & 72 & 1.00 & 449 & 1.00 & 1895 \\ 23 | 21 & 1.00 & 1 & 1.00 & 5 & 1.00 & 73 & 1.00 & 509 & 1.00 & 2176 \\ 24 | 22 & 1.00 & 4 & 1.00 & 8 & 1.00 & 78 & 1.00 & 505 & 1.00 & 2472 \\ 25 | 23 & 1.00 & 3 & 1.00 & 13 & 1.00 & 79 & 1.00 & 522 & 1.00 & 2797 \\ 26 | 24 & 1.00 & 1 & 1.00 & 16 & 1.00 & 59 & 1.00 & 580 & 1.00 & 3092 \\ 27 | 25 & 1.00 & 2 & 1.00 & 9 & 1.00 & 102 & 1.00 & 588 & 1.00 & 3392 \\ 28 | 26 & 1.00 & 0 & 1.00 & 10 & 1.00 & 79 & 1.00 & 629 & 1.00 & 3709 \\ 29 | 27 & 1.00 & 2 & 1.00 & 11 & 1.00 & 89 & 1.00 & 636 & 1.00 & 3915 \\ 30 | 28 & 1.00 & 1 & 1.00 & 8 & 1.00 & 83 & 1.00 & 691 & 1.00 & 4097 \\ 31 | 29 & 1.00 & 2 & 1.00 & 12 & 1.00 & 89 & 1.00 & 650 & 1.00 & 4500 \\ 32 | 30 & 1.00 & 3 & 1.00 & 16 & 1.00 & 80 & 1.00 & 649 & 1.00 & 4551 \\ 33 | \hline 34 | \end {tabular} \\ 35 | \medskip 36 | 37 | \end {table} 38 | -------------------------------------------------------------------------------- /mylib/gdef.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************\ 2 | * 3 | * Package: MyLib 4 | * File: gdef.c 5 | * Environment: ANSI C 6 | * 7 | * Copyright (c) 2002 Pierre L'Ecuyer, DIRO, Université de Montréal. 8 | * e-mail: lecuyer@iro.umontreal.ca 9 | * All rights reserved. 10 | * 11 | * This software is provided under the Apache 2 License. 12 | * 13 | * In scientific publications which used this software, a reference to it 14 | * would be appreciated. 15 | * 16 | \*************************************************************************/ 17 | 18 | #ifdef HAVE_CONFIG_H 19 | #include "config.h" 20 | #endif 21 | 22 | #include "gdef.h" 23 | #ifdef HAVE_WINDOWS_H 24 | #include 25 | #endif 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | #ifdef HAVE_SYS_UTSNAME_H 32 | #include 33 | 34 | #else 35 | #ifdef HAVE_UNISTD_H 36 | #include 37 | #endif 38 | 39 | #endif 40 | 41 | 42 | 43 | void gdef_GetHostName (char machine[], int n) 44 | { 45 | int j; 46 | #ifdef HAVE_SYS_UTSNAME_H 47 | struct utsname Z; 48 | #else 49 | char *name; 50 | #endif 51 | 52 | if (n <= 0 || machine == NULL) 53 | return; 54 | machine[0] = '\0'; 55 | 56 | #ifdef HAVE_SYS_UTSNAME_H 57 | if (uname(&Z) != -1) { 58 | strncpy (machine, Z.nodename, (size_t) n); 59 | j = strlen (machine); 60 | if (n - j > 2) 61 | strncat (machine, ", ", (size_t) 2); 62 | j = strlen (machine); 63 | if (n - j > 0) 64 | strncat (machine, Z.sysname, (size_t) (n - j)); 65 | machine[n - 1] = '\0'; 66 | return; 67 | } 68 | 69 | #else 70 | #ifdef HAVE_UNISTD_H 71 | gethostname (machine, (size_t) n); 72 | machine[n - 1] = '\0'; 73 | return; 74 | 75 | #else 76 | name = getenv ("HOST"); 77 | if (name != NULL) { 78 | strncpy (machine, name, (size_t) n); 79 | j = strlen (machine); 80 | machine[n - 1] = '\0'; 81 | if (j < n - 3) { 82 | machine[j++] = ','; 83 | machine[j++] = ' '; 84 | } 85 | } 86 | name = getenv ("OSTYPE"); 87 | if (name != NULL) { 88 | if ((int) strlen (name) < n - j) 89 | strncat (machine, name, (size_t) n - j); 90 | machine[n - 1] = '\0'; 91 | } 92 | 93 | #endif 94 | #endif 95 | } 96 | 97 | 98 | /*------------------------------------------------------------------------*/ 99 | #define MAXBYTES 255 100 | 101 | void gdef_WriteHostName (void) 102 | { 103 | char machine[1 + MAXBYTES] = {'\0'}; 104 | gdef_GetHostName (machine, MAXBYTES); 105 | printf ("%s\n", machine); 106 | } 107 | 108 | #if 0 109 | int main() 110 | { 111 | struct utsname name; 112 | 113 | if (uname(&name) != -1) 114 | printf(" %s\n", name.nodename); 115 | else { 116 | fprintf(stderr, "Can't find system name\n"); 117 | return 1; 118 | } 119 | gdef_GetHostName (0, MAXBYTES); 120 | gdef_WriteHostName (); 121 | return 0; 122 | } 123 | #endif 124 | -------------------------------------------------------------------------------- /examples/fcoll.res1.tex: -------------------------------------------------------------------------------- 1 | 2 | 3 | \begin {table} 4 | \centering 5 | \caption {Expected number of 6 | collisions and observed number of collisions.} 7 | \label {tab:coll1} 8 | \smallskip 9 | 10 | %%%%%%%%%%%%%%%%%%%%% 11 | \begin {tabular}{|c|@{\extracolsep{10pt}}rr|rr|rr|rr|rr|} 12 | %% \multicolumn{11}{l}{\makebox[0pt][l]{fmultin\_Serial1: Collision test, Expected numbers---fmultin\_Serial1: Collision test, Observed numbers}}\\ 13 | \hline 14 | LSize& \multicolumn{2}{c|}{$ j=1 $} & \multicolumn{2}{c|}{$ j=2 $} & \multicolumn{2}{c|}{$ j=3 $} & \multicolumn{2}{c|}{$ j=4 $} & \multicolumn{2}{c|}{$ j=5 $} \\ 15 | \hline 16 | 10 & 1.93 & 2 & 7.62 & 2 & 29.39 & 11 & 108.94 & 58 & 376.52 & 570 \\ 17 | 11 & 1.95 & 1 & 7.81 & 0 & 30.44 & 6 & 115.16 & 17 & 413.38 & 474 \\ 18 | 12 & 1.96 & 0 & 7.81 & 2 & 30.65 & 13 & 117.87 & 44 & 436.20 & 216 \\ 19 | 13 & 2.00 & 0 & 7.95 & 2 & 31.37 & 13 & 121.97 & 55 & 461.02 & 211 \\ 20 | 14 & 1.98 & 1 & 7.90 & 5 & 31.31 & 11 & 122.77 & 52 & 471.77 & 191 \\ 21 | 15 & 1.99 & 1 & 7.93 & 1 & 31.51 & 7 & 124.27 & 41 & 483.04 & 132 \\ 22 | 16 & 1.99 & 1 & 7.95 & 0 & 31.65 & 5 & 125.35 & 20 & 491.26 & 75 \\ 23 | 17 & 1.99 & 0 & 7.97 & 1 & 31.75 & 11 & 126.11 & 23 & 497.29 & 101 \\ 24 | 18 & 2.00 & 0 & 7.98 & 4 & 31.83 & 15 & 126.66 & 45 & 501.47 & 214 \\ 25 | 19 & 2.00 & 0 & 7.98 & 1 & 31.88 & 3 & 127.07 & 19 & 504.60 & 61 \\ 26 | 20 & 2.00 & 0 & 7.99 & 0 & 31.91 & 4 & 127.33 & 14 & 506.69 & 74 \\ 27 | 21 & 2.00 & 0 & 7.99 & 1 & 31.94 & 12 & 127.55 & 48 & 508.33 & 178 \\ 28 | 22 & 2.00 & 0 & 7.99 & 3 & 31.96 & 14 & 127.66 & 59 & 509.34 & 220 \\ 29 | 23 & 2.00 & 0 & 8.00 & 0 & 31.97 & 5 & 127.78 & 16 & 510.21 & 45 \\ 30 | 24 & 2.00 & 0 & 8.00 & 0 & 31.98 & 1 & 127.83 & 15 & 510.67 & 37 \\ 31 | 25 & 2.00 & 1 & 8.00 & 4 & 31.99 & 8 & 127.91 & 44 & 511.16 & 142 \\ 32 | 26 & 2.00 & 2 & 8.00 & 1 & 31.99 & 7 & 127.92 & 24 & 511.33 & 71 \\ 33 | 27 & 2.00 & 1 & 8.00 & 1 & 31.99 & 7 & 127.94 & 38 & 511.55 & 152 \\ 34 | 28 & 2.00 & 0 & 8.00 & 3 & 31.99 & 17 & 127.96 & 41 & 511.67 & 193 \\ 35 | 29 & 2.00 & 1 & 8.00 & 0 & 32.00 & 0 & 127.98 & 8 & 511.78 & 25 \\ 36 | 30 & 2.00 & 0 & 8.00 & 3 & 32.00 & 10 & 127.98 & 29 & 511.83 & 189 \\ 37 | \hline 38 | \end {tabular} \\ 39 | \medskip 40 | \end {table} 41 | -------------------------------------------------------------------------------- /probdist/wdist.tex: -------------------------------------------------------------------------------- 1 | \defmodule {wdist} 2 | 3 | This module provides wrappers functions that are needed 4 | because the parameter of type {\tt wdist\_CFUNC} in {\tt gofw\_ActiveTests1} 5 | and in {\tt gofs\_ContUnifTransform}, for example, is not type-compatible 6 | with the distribution functions provided in {\tt fdist}, since the different 7 | distributions take a different number of arguments. 8 | \hpierre {This looks like a faulty design. 9 | Could we make it compatible? Otherwise, perhaps we should put the 10 | wrappers in {\tt fdist}. In C++, we could do that and give them the 11 | same names as the functions already in {\tt fdist} (using overloading).} 12 | 13 | 14 | %%%%%%%%%%%%%%%%%%%%%%%% 15 | \bigskip\hrule 16 | \code\hide 17 | /* wdist.h for ANSI C */ 18 | #ifndef WDIST_H 19 | #define WDIST_H 20 | \endhide 21 | #include "fmass.h" 22 | \endcode 23 | 24 | 25 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 26 | \guisec{Types} 27 | 28 | \code 29 | 30 | typedef double (*wdist_CFUNC) (double [], double); 31 | \endcode 32 | \tab A generic {\em continuous\/} distribution function with an 33 | arbitrary number of parameters given in the first argument. 34 | The second argument is the point $x$ at which the function is evaluated. 35 | \ifdetailed %%%% 36 | This type is used, among other things, to compute goodness-of-fit 37 | test statistics for arbitrary distributions (see module {\tt gofs} and 38 | {\tt gofw}). 39 | \fi %%% detailed 40 | \endtab 41 | \code 42 | 43 | 44 | typedef double (*wdist_DFUNC) (fmass_INFO, long); 45 | \endcode 46 | \tab A generic {\em discrete\/} distribution function over the set of 47 | integers. 48 | The first argument contains the parameters of the function and 49 | possibly precomputed tables of values of the function. 50 | The second argument is the point $x$ at which the function is evaluated. 51 | \hrichard {Devrait probablement \^etre \'elimin\'e. Utilis\'e 1 fois dans 52 | smultin, mais pourrait \^etre contourn\'e.} 53 | \hpierre {Je pr\'ef\`ere conserver. } 54 | \endtab 55 | 56 | 57 | 58 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 59 | \guisec{Wrap-up functions} 60 | 61 | \code 62 | 63 | double wdist_Normal (double Par[], double x); 64 | \endcode 65 | \tab 66 | Wrapper function for the {standard normal} distribution, needed 67 | for compatibility with the type {\tt wdist\_CFUNC} used as a parameter 68 | in certain functions such as {\tt gofw\_ActiveTests1}, etc. 69 | Returns $\Phi(x)$, where $\Phi$ is the standard normal distribution 70 | function, with mean 0 and variance 1. 71 | {\tt Par} is unused. 72 | \endtab 73 | \code 74 | 75 | 76 | double wdist_ChiSquare (double Par[], double x); 77 | \endcode 78 | \tab 79 | Wrapper function for the {chi-square} distribution, similar to 80 | {\tt wdist\_Normal}. 81 | Returns $P[X \le x]$, where $X$ has the chi-square distribution 82 | with $k$ degrees of freedom. The value of $k$ must be in {\tt Par[0]}. 83 | \endtab 84 | \code 85 | 86 | 87 | double wdist_Unif (double Par[], double x); 88 | \endcode 89 | \tab 90 | Wrapper function for the {uniform} distribution. 91 | Returns $x$. {\tt Par} is unused. 92 | \endtab 93 | \code 94 | \hide 95 | #endif 96 | \endhide 97 | \endcode 98 | -------------------------------------------------------------------------------- /testu01/fspectral.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************\ 2 | * 3 | * Package: TestU01 4 | * File: fspectral.c 5 | * Environment: ANSI C 6 | * 7 | * Copyright (c) 2002 Pierre L'Ecuyer, DIRO, Université de Montréal. 8 | * e-mail: lecuyer@iro.umontreal.ca 9 | * All rights reserved. 10 | * 11 | * This software is provided under the Apache 2 License. 12 | * 13 | * In scientific publications which used this software, a reference to it 14 | * would be appreciated. 15 | * 16 | \*************************************************************************/ 17 | 18 | 19 | #include "fspectral.h" 20 | #include "ffam.h" 21 | #include "fres.h" 22 | #include "fcho.h" 23 | #include "ftab.h" 24 | #include "sspectral.h" 25 | 26 | #include "num.h" 27 | 28 | long fspectral_Maxn = 4194304; 29 | 30 | 31 | 32 | 33 | /*------------------------------- Functions ------------------------------*/ 34 | 35 | 36 | static void PrintHead (char *name, ffam_Fam *fam, void *par1, 37 | int Nr, int j1, int j2, int jstep) 38 | { 39 | int *Par = par1; 40 | 41 | printf 42 | ("\n\n================================================================\n"); 43 | printf ("Family: %s\n\n", fam->name); 44 | printf ("Test: %s\n", name); 45 | printf (" k = %d, r = %d, s = %d", Par[0], Par[1], Par[2]); 46 | printf ("\n Nr = %d, j1 = %d, j2 = %d, jstep = %d\n\n", 47 | Nr, j1, j2, jstep); 48 | } 49 | 50 | 51 | /*=========================================================================*/ 52 | 53 | static void TabFourier3 (ffam_Fam *fam, void *res1, void *cho, 54 | void *par1, int i, int j, int irow, int icol) 55 | { 56 | int r, s, k; 57 | long N; 58 | int *Par = par1; 59 | fres_Cont *fres = res1; 60 | sspectral_Res *sres; 61 | 62 | k = Par[0]; 63 | r = Par[1]; 64 | s = Par[2]; 65 | 66 | N = fcho_ChooseParamL (cho, (long) num_TwoExp[k], fspectral_Maxn, i, j); 67 | if (N < 0) 68 | return; 69 | s = fcho_Chooses (r, s, fam->Resol[irow]); 70 | if (s <= 0) 71 | return; 72 | 73 | 74 | sres = sspectral_CreateRes (); 75 | sspectral_Fourier3 (fam->Gen[irow], sres, N, k, r, s); 76 | fres_FillTableEntryC (fres, sres->Bas->pVal2, N, irow, icol); 77 | sspectral_DeleteRes (sres); 78 | } 79 | 80 | 81 | /*========================================================================*/ 82 | 83 | void fspectral_Fourier3 (ffam_Fam *fam, fres_Cont *res, fcho_Cho *cho, 84 | int k, int r, int s, 85 | int Nr, int j1, int j2, int jstep) 86 | { 87 | int Par[3]; 88 | lebool localRes; 89 | 90 | Par[0] = k; 91 | Par[1] = r; 92 | Par[2] = s; 93 | if (res == NULL) { 94 | localRes = TRUE; 95 | res = fres_CreateCont (); 96 | } else 97 | localRes = FALSE; 98 | 99 | PrintHead ("fspectral_Fourier3", fam, Par, Nr, j1, j2, jstep); 100 | fres_InitCont (fam, res, 2, Nr, j1, j2, jstep, "fspectral_Fourier3"); 101 | ftab_MakeTables (fam, res, cho, Par, TabFourier3, Nr, j1, j2, jstep); 102 | fres_PrintCont (res); 103 | if (localRes) 104 | fres_DeleteCont (res); 105 | } 106 | -------------------------------------------------------------------------------- /include/Makefile.def: -------------------------------------------------------------------------------- 1 | docdir = ${prefix}/share/TestU01/doc 2 | MYLIB = ${top_srcdir}/mylib 3 | PROBDIST = ${top_srcdir}/probdist 4 | TESTU01 = ${top_srcdir}/testu01 5 | 6 | MYLIBHEADERS = gdef.h addstr.h bitset.h chrono.h mystr.h num.h num2.h tables.h util.h 7 | MYLIBSOURCES = gdef.c addstr.c bitset.c chrono.c mystr.c num.c num2.c tables.c util.c 8 | MYLIBTEX = $(MYLIB)/gdef.tex $(MYLIB)/addstr.tex $(MYLIB)/bitset.tex $(MYLIB)/chrono.tex $(MYLIB)/mystr.tex $(MYLIB)/num.tex $(MYLIB)/num2.tex $(MYLIB)/tables.tex $(MYLIB)/util.tex 9 | 10 | PROBDISTHEADERS = fmass.h fdist.h fbar.h finv.h gofs.h gofw.h statcoll.h wdist.h 11 | PROBDISTSOURCES = fmass.c fdist.c fbar.c finv.c gofs.c gofw.c statcoll.c wdist.c 12 | PROBDISTTEX = $(PROBDIST)/fmass.tex $(PROBDIST)/fdist.tex $(PROBDIST)/fbar.tex $(PROBDIST)/finv.tex $(PROBDIST)/gofs.tex $(PROBDIST)/gofw.tex $(PROBDIST)/statcoll.tex $(PROBDIST)/wdist.tex 13 | 14 | TESTU01HEADERS = unif01.h ulcg.h umrg.h ucarry.h utaus.h ugfsr.h uinv.h uquad.h ucubic.h ulec.h utezuka.h umarsa.h uweyl.h uknuth.h uwu.h unumrec.h uvaria.h usoft.h ugranger.h ucrypto.h ufile.h udeng.h utouzin.h uautomata.h uxorshift.h ubrent.h rijndael-alg-fst.h tu01_sha1.h scatter.h swrite.h sres.h smultin.h sknuth.h smarsa.h sstring.h svaria.h snpair.h swalk.h sentrop.h sspectral.h scomp.h sspacings.h vectorsF2.h bbattery.h ffam.h fcong.h ffsr.h ftab.h fres.h fcho.h fmultin.h fmarsa.h fknuth.h fwalk.h fstring.h fspectral.h fvaria.h fnpair.h 15 | TESTU01SOURCES = unif01.c ulcg.c umrg.c ucarry.c utaus.c ugfsr.c uinv.c uquad.c ucubic.c ulec.c utezuka.c umarsa.c uweyl.c uknuth.c uwu.c unumrec.c uvaria.c usoft.c ugranger.c ucrypto.c ufile.c udeng.c utouzin.c uautomata.c uxorshift.c ubrent.c rijndael-alg-fst.c tu01_sha1.c scatter.c swrite.c sres.c smultin.c sknuth.c smarsa.c sstring.c svaria.c snpair.c swalk.c sentrop.c sspectral.c scomp.c sspacings.c vectorsF2.c bbattery.c ffam.c fcong.c ffsr.c ftab.c fres.c fcho.c fmultin.c fmarsa.c fknuth.c fwalk.c fstring.c fspectral.c fvaria.c fnpair.c 16 | TESTU01TEX = $(TESTU01)/unif01.tex $(TESTU01)/ulcg.tex $(TESTU01)/umrg.tex $(TESTU01)/ucarry.tex $(TESTU01)/utaus.tex $(TESTU01)/ugfsr.tex $(TESTU01)/uinv.tex $(TESTU01)/uquad.tex $(TESTU01)/ucubic.tex $(TESTU01)/ulec.tex $(TESTU01)/utezuka.tex $(TESTU01)/umarsa.tex $(TESTU01)/uweyl.tex $(TESTU01)/uknuth.tex $(TESTU01)/uwu.tex $(TESTU01)/unumrec.tex $(TESTU01)/uvaria.tex $(TESTU01)/usoft.tex $(TESTU01)/ugranger.tex $(TESTU01)/ucrypto.tex $(TESTU01)/ufile.tex $(TESTU01)/udeng.tex $(TESTU01)/utouzin.tex $(TESTU01)/uautomata.tex $(TESTU01)/uxorshift.tex $(TESTU01)/ubrent.tex $(TESTU01)/rijndael-alg-fst.tex $(TESTU01)/tu01_sha1.tex $(TESTU01)/scatter.tex $(TESTU01)/swrite.tex $(TESTU01)/sres.tex $(TESTU01)/smultin.tex $(TESTU01)/sknuth.tex $(TESTU01)/smarsa.tex $(TESTU01)/sstring.tex $(TESTU01)/svaria.tex $(TESTU01)/snpair.tex $(TESTU01)/swalk.tex $(TESTU01)/sentrop.tex $(TESTU01)/sspectral.tex $(TESTU01)/scomp.tex $(TESTU01)/sspacings.tex $(TESTU01)/vectorsF2.tex $(TESTU01)/bbattery.tex $(TESTU01)/ffam.tex $(TESTU01)/fcong.tex $(TESTU01)/ffsr.tex $(TESTU01)/ftab.tex $(TESTU01)/fres.tex $(TESTU01)/fcho.tex $(TESTU01)/fmultin.tex $(TESTU01)/fmarsa.tex $(TESTU01)/fknuth.tex $(TESTU01)/fwalk.tex $(TESTU01)/fstring.tex $(TESTU01)/fspectral.tex $(TESTU01)/fvaria.tex $(TESTU01)/fnpair.tex 17 | 18 | -------------------------------------------------------------------------------- /testu01/ufile.tex: -------------------------------------------------------------------------------- 1 | \defmodule {ufile} 2 | 3 | This module allows the implementation of generators in the form of numbers 4 | read directly from an arbitrary file. No more than one generator of each 5 | type in this module can be in use at any given time. 6 | 7 | 8 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 9 | \bigskip 10 | \hrule 11 | \code\hide 12 | /* ufile.h for ANSI C */ 13 | #ifndef UFILE_H 14 | #define UFILE_H 15 | \endhide 16 | #include "unif01.h" 17 | 18 | 19 | unif01_Gen * ufile_CreateReadText (char *fname, long nbuf); 20 | \endcode 21 | \tab Reads numbers (assumed to be in text format) from input file 22 | \texttt{fname}. \index{Generator!read from file}% 23 | The numbers must be floating-point numbers in [0, 1), separated by 24 | whitespace characters. Numbers in the file can be grouped in any way: 25 | there may be blank lines, some lines may contain many numbers, others 26 | only one. The file must contain only valid real numbers, nothing else. 27 | The numbers are read in batches of {\tt nbuf} at a time and kept in an array 28 | (if {\tt nbuf} is very large, a smaller but still large array will be used 29 | instead). 30 | \endtab 31 | \code 32 | 33 | 34 | void ufile_InitReadText (void); 35 | \endcode 36 | \tab Reinitializes the generator obtained from {\tt ufile\_CreateReadText} 37 | to the beginning of the file. 38 | \endtab 39 | \code 40 | 41 | 42 | unif01_Gen * ufile_CreateReadBin (char *fname, long nbuf); 43 | \endcode 44 | \tab Reads numbers from input file \texttt{fname}. This file is assumed 45 | to be in binary format. The numbers are read in batches of {\tt 4 nbuf} 46 | \texttt{unsigned char}'s at a time, transformed into {\tt nbuf} unsigned 47 | 32-bit integers and kept in an array (if {\tt nbuf} is very large, a 48 | smaller but still large array will be used instead). 49 | This function is used in order to test (random) 50 | bit sequences kept in a file. 51 | \endtab 52 | \code 53 | 54 | 55 | void ufile_InitReadBin (void); 56 | \endcode 57 | \tab Reinitializes the generator obtained from {\tt ufile\_CreateReadBin} 58 | to the beginning of the file. 59 | \endtab 60 | 61 | 62 | %%%%%%%%%%%%%%%%%%%%%%%%%%% 63 | \guisec{Clean-up functions} 64 | \code 65 | 66 | void ufile_DeleteReadText (unif01_Gen *); 67 | \endcode 68 | \tab Closes the file and frees the dynamic memory allocated by 69 | \texttt{ufile\_CreateReadText}. 70 | \endtab 71 | \code 72 | 73 | 74 | void ufile_DeleteReadBin (unif01_Gen *); 75 | \endcode 76 | \tab Closes the file and frees the dynamic memory allocated by 77 | \texttt{ufile\_CreateReadBin}. 78 | \endtab 79 | 80 | 81 | %%%%%%%%%%%%%%%%%%%%%%%%%%% 82 | \guisec{Useful functions} 83 | \code 84 | 85 | void ufile_Gen2Bin (unif01_Gen *gen, char *fname, double n, int r, int s); 86 | \endcode 87 | \tab Creates the file {\tt fname} containing $n$ random bits using the 88 | output of generator {\tt gen}. From each random number 89 | returned by {\tt gen}, the $r$ most significant bits will be dropped 90 | and the $s$ following bits will be written to the file until $n$ bits 91 | have been written. Restriction: $s \in \{ 8, 16, 24, 32 \}$. 92 | \endtab 93 | 94 | \code 95 | \hide 96 | #endif 97 | \endhide 98 | \endcode 99 | -------------------------------------------------------------------------------- /param/LCGWu2.par: -------------------------------------------------------------------------------- 1 | # Package: TestU01 2 | # File: LCGWu2.par 3 | 4 | # Description: Parameter values for the LCG of type Wu2. They have a good 5 | # lattice structure but with the restriction that the multiplier is a sum 6 | # or a difference of two powers of 2, as suggested by P. C. Wu \cite{rWU97a}. 7 | #----------------------------------------------------------------- 8 | 9 | # Give the name of the family first 10 | 11 | LCGWu2 12 | 13 | # For each generator, the following parameters must be given in 14 | # the right order on the same line 15 | # h m a 16 | # where h is (very close to) the base-2 logarithm of m, m is the modulus, 17 | # and a is the multiplier, the constant c is 0. The multiplier a has been 18 | # chosen in such a way that a*m < 2^{53}. Thus we use the floating-point 19 | # version of the LCG as it is often faster than the integer version. 20 | # The binary representation of a is given in a comment on the same line 21 | 22 | 10 1021 65 # 1000001 23 | 11 2039 -72 # -1001000 24 | 12 4093 960 # 1111000000 25 | 13 8191 504 # 111111000 26 | 14 16381 96 # 1100000 27 | 15 32749 8256 # 10000001000000 28 | 16 65521 8256 # 10000001000000 29 | 17 131071 -320 # -101000000 30 | 18 262139 384 # 110000000 31 | 19 524287 -3968 # -111110000000 32 | 20 1048573 15360 # 11110000000000 33 | 21 2097143 -2032 # -11111110000 34 | 22 4194301 67584 # 10000100000000000 35 | 23 8388593 2096640 # 111111111111000000000 36 | 24 16777213 1044480 # 11111111000000000000 37 | 25 33554393 8256 # 10000001000000 38 | 26 67108859 -16512 # -100000010000000 39 | 27 134217689 16842752 # 1000000010000000000000000 40 | 28 268435399 264192 # 1000000100000000000 41 | 29 536870909 32640 # 111111110000000 42 | 30 1073741789 40960 # 1010000000000000 43 | 31 2147483647 -67584 # -10000100000000000 44 | 45 | 32 4294967291 130560 # 11111111000000000 46 | 33 8589934583 4194336 # 10000000000000000100000 47 | # 34 17179869143 -2097136 # -111111111111111110000 48 | 34 17179869143 132096 # 100000010000000000 49 | 35 34359738337 1073745920 # 1000000000000000001000000000000 50 | # 36 68719476731 -17039360 # -1000001000000000000000000 51 | 36 68719476731 16744448 # 111111111000000000000000 52 | # 37 137438953447 -8590458880 # -1000000000000010000000000000000000 53 | 37 137438953447 8388576 # 11111111111111111100000 54 | # 38 274877906899 -491520 # -1111000000000000000 55 | 38 274877906899 17178820608 # 1111111111111100000000000000000000 56 | 39 549755813881 8590458880 # 1000000000000010000000000000000000 57 | 40 1099511627689 8650752 # 100001000000000000000000 58 | -------------------------------------------------------------------------------- /mylib/tcode.tex: -------------------------------------------------------------------------------- 1 | \defmodule{tcode} 2 | 3 | \iffalse 4 | Le programme {\tt tcode} permet de produire du code compilable 5 | \`a partir d'une documentation destin\'ee \`a TEX ou LATEX. 6 | Il produit un fichier {\tt FOut} destin\'e \`a un compilateur tel que Modula-2 7 | (ou autre), \`a partir d'un fichier {\tt FIn} re\c cu \`a l'entr\'ee. 8 | Les noms de ces deux fichiers sont donn\'es par l'usager, avec l'extension, 9 | lors de l'appel du programme. 10 | N'appara\^\i tront dans le second fichier que les parties se trouvant entre 11 | les d\'elimiteurs {\tt\bs{code}} et {\tt\bs{endcode}}. 12 | Toutes les autres commandes TEX et LATEX, m\^eme \`a l'int\'erieur de ces 13 | d\'elimiteurs, seront aussi enlev\'ees. 14 | L'appel se fait sous la forme: 15 | \fi 16 | 17 | 18 | Program {\tt tcode} makes compilable code from a \TeX\ or \LaTeX\ document. It 19 | creates a file {\tt FOut} for a compiler like cc (or any other), starting 20 | from a file {\tt FIn}. The names of these two files must be given by the user, 21 | with appropriate extension, when calling the program. 22 | The two file names (with the extension) must be different. 23 | 24 | Only the text included between the {\tt\bs{code}} and 25 | {\tt\bs{endcode}} delimiters will appear in the second file. Only the following 26 | \LaTeX\ commands can appear between {\tt\bs{code}} and {\tt\bs{endcode}}: 27 | 28 | \begin{verse} 29 | {\tt\bs{hide}}, {\tt\bs{endhide}}, {\tt\bs{iffalse}}, {\tt\bs{fi}}, 30 | {\tt\bs{smallcode}}, {\tt\bs{smallc}}. 31 | \end{verse} 32 | 33 | Everything else between 34 | {\tt\bs{code}} and {\tt\bs{endcode}} must be legal code in the 35 | output file, apart from two exceptions: the \TeX\ command 36 | {\tt\bs{def}\bs{code}}, defining {\tt\bs{code}} will not start a region 37 | of valid code, nor will {\tt\bs{code}} appearing on a line after a 38 | \TeX\ comment character {\tt\%}. 39 | 40 | If one wants code to appear in the compilable file, but 41 | be invisible in the {\tt dvi} file obtained from processing the {\tt tex} 42 | file with \LaTeX, one should put this code between the delimiters 43 | {\tt\bs{hide}} and {\tt\bs{endhide}}, or between the delimiters 44 | {\tt\bs{iffalse}} and {\tt\bs{fi}}. 45 | 46 | The program is called by: 47 | 48 | \begin {center}\tt 49 | tcode \ $\langle$FIn$\rangle$ \ $\langle$FOut$\rangle$ 50 | \end {center} 51 | 52 | \iffalse 53 | Les deux noms de fichiers (avec l'extension) doivent \^etre diff\'erents. 54 | Par exemple, si le fichier destin\'e \`a \LaTeX\ est {\tt chrono.tex} et 55 | que l'on veut en extraire le code compilable et placer ce dernier dans 56 | {\tt chrono.h} (module de d\'efinition), on utilisera la commande: 57 | \fi 58 | 59 | \paragraph{Examples:} 60 | If one wants 61 | to extract the {\it C} code from the \LaTeX\ file {\tt chrono.tex}, 62 | and place it in 63 | the header file {\tt chrono.h}, the following 64 | command should be used: 65 | 66 | \begin {center}\tt 67 | tcode \ chrono.tex \ chrono.h 68 | \end {center} 69 | 70 | To extract {\it Java} code from the \LaTeX\ file {\tt Event.tex}, 71 | and place it in the file {\tt Event.java}, one must use: 72 | 73 | \begin {center}\tt 74 | tcode \ Event.tex \ Event.java 75 | \end {center} 76 | % 77 | %To extract the {\it Modula-2} DEFINITION module from the \LaTeX\ file 78 | % {\tt BIN.tex}, 79 | %and place it in the file {\tt BIN.def}, one must use: 80 | % 81 | %\begin {center}\tt 82 | % tcode \ BIN.tex \ BIN.def 83 | %\end {center} 84 | % -------------------------------------------------------------------------------- /testu01/uknuth.tex: -------------------------------------------------------------------------------- 1 | \defmodule {uknuth} 2 | 3 | This module collects generators proposed by Donald E. Knuth. 4 | Knuth's code can be found at 5 | \url{http://www-cs-faculty.stanford.edu/~knuth/programs.html}. 6 | %% We have copied Knuth's code almost verbatim but were forced 7 | % to make small changes to make it compatible with this software, 8 | % and thus we have changed the names of 9 | % his generators as required by Knuth in his original documentation. 10 | Since there are global variables in this module, no more than 11 | one generator of each type in this module can be in use at any given 12 | time. \index{Generator!Knuth} 13 | 14 | 15 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 | \bigskip 17 | \hrule 18 | \code 19 | \hide 20 | /* uknuth.h for ANSI C */ 21 | 22 | #ifndef UKNUTH_H 23 | #define UKNUTH_H 24 | \endhide 25 | #include "unif01.h" 26 | 27 | 28 | unif01_Gen * uknuth_CreateRan_array1 (long s, long A[100]); 29 | \endcode 30 | \tab Implements the generator {\tt ran\_array} in its first version as 31 | appeared on Knuth's web site in 2000. It is 32 | \index{Generator!ran\_array}% 33 | based on the lagged Fibonacci sequence with 34 | subtraction \cite{rKNU98a}, modified via L\"uscher's method. 35 | It generates 1009 numbers from the recurrence 36 | $$ 37 | X_j = (X_{j-100} - X_{j-37}) \bmod 2^{30} 38 | $$ 39 | out of which only the first 100 are used and the 40 | next 909 are discarded, and this process is repeated. 41 | The generator returns $U_j = X_j/2^{30}$. 42 | Gives 30 bits of precision. 43 | 44 | If the seed $s \ge 0$, then Knuth's initialization procedure 45 | is performed: it shifts and transforms the bits of $s$ in order to get 46 | the 100 numbers that make up the initial state; in that case, 47 | array {\tt A} is unused. 48 | If $s < 0$, then the initial state is taken from the array 49 | {\tt A[0..99]}. This could be convenient for restarting the 50 | generator from a previously saved state. 51 | Restrictions: $s \le 1073741821$. 52 | \endtab 53 | \code 54 | 55 | 56 | unif01_Gen * uknuth_CreateRan_array2 (long s, long A[100]); 57 | \endcode 58 | \tab 59 | This implements the new version of {\tt ran\_array} with a new 60 | initialization procedure as appeared on Knuth's web site in 2002. 61 | \endtab 62 | \code 63 | 64 | 65 | unif01_Gen * uknuth_CreateRanf_array1 (long s, double B[100]); 66 | \endcode 67 | \tab Similar generator to {\tt ran\_array1} above, but 68 | where the recurrence is 69 | $$ 70 | U_j = (U_{j-100} + U_{j-37}) \bmod 1 71 | $$ 72 | and is implemented directly in floating-point arithmetic. 73 | This implements the first version of Knuth's 74 | {\tt ranf\_array} as it 75 | \index{Generator!ranf\_array}% 76 | appeared on his web site in 2000. Array {\tt B} contains 77 | numbers in [0, 1). 78 | \endtab 79 | \code 80 | 81 | 82 | unif01_Gen * uknuth_CreateRanf_array2 (long s, double B[100]); 83 | \endcode 84 | \tab This implements the new version of {\tt ranf\_array} as it 85 | appeared on Knuth's web site in 2002. 86 | \endtab 87 | 88 | 89 | \guisec{Clean-up functions} 90 | \code 91 | 92 | void uknuth_DeleteRan_array1 (unif01_Gen *gen); 93 | void uknuth_DeleteRan_array2 (unif01_Gen *gen); 94 | void uknuth_DeleteRanf_array1 (unif01_Gen *gen); 95 | void uknuth_DeleteRanf_array2 (unif01_Gen *gen); 96 | \endcode 97 | \tab Frees the dynamic memory used by the generators of this module, 98 | and allocated by the corresponding {\tt Create} function. 99 | \endtab 100 | \code 101 | 102 | \hide 103 | #endif 104 | \endhide 105 | \endcode 106 | -------------------------------------------------------------------------------- /param/TausLCG2.par: -------------------------------------------------------------------------------- 1 | # Package: TestU01 2 | # File: TausLCG2.par 3 | 4 | # Description: Parameter values for combined CombTaus2 with LCG 5 | # Each member of the family calls generator ulec_CreateCombTausLCG21. 6 | #----------------------------------------------------------------- 7 | 8 | # Give the name of the family first 9 | 10 | TausLCG2 11 | 12 | # For each generator, the following parameters must be given in 13 | # the right order on three lines 14 | # LSize 15 | # k1 q1 s1 k2 q2 s2 16 | # m a 17 | # where LSize is (very close to) the base-2 logarithm of the period length, 18 | # k1, q1, s1 are the parameters of the first Taus component, and 19 | # k2, q2, s2 are the parameters of the second Taus component in the 20 | # CombTaus2 generator 21 | # m, a are the modulus and the multiplier of the LCG generator. 22 | 23 | 20 24 | 7 1 2 3 1 1 25 | 1021 65 26 | 27 | 21 28 | 7 1 2 3 1 1 29 | 2039 995 30 | 31 | 22 32 | 6 1 1 5 2 2 33 | 2039 995 34 | 35 | 23 36 | 6 1 1 5 2 2 37 | 4093 209 38 | 39 | 24 40 | 7 1 5 5 2 1 41 | 4093 209 42 | 43 | 25 44 | 7 1 5 5 2 1 45 | 8191 884 46 | 47 | 26 48 | 7 1 3 6 1 4 49 | 8191 884 50 | 51 | 27 52 | 7 1 3 6 1 4 53 | 16381 572 54 | 55 | 28 56 | 9 4 3 5 2 2 57 | 16381 572 58 | 59 | 29 60 | 9 4 3 5 2 2 61 | 32749 219 62 | 63 | 30 64 | 11 2 6 4 1 1 65 | 32749 219 66 | 67 | 31 68 | 11 2 6 4 1 1 69 | 65521 17364 70 | 71 | 32 72 | 11 2 3 5 2 2 73 | 65521 17364 74 | 75 | 33 76 | 11 2 3 5 2 2 77 | 131071 43165 78 | 79 | 34 80 | 10 3 5 7 3 3 81 | 131071 43165 82 | 83 | 35 84 | 10 3 5 7 3 3 85 | 262139 92717 86 | 87 | 36 88 | 11 2 5 7 1 2 89 | 262139 92717 90 | 91 | 37 92 | 11 2 5 7 1 2 93 | 524287 283741 94 | 95 | 38 96 | 10 3 4 9 4 2 97 | 524287 283741 98 | 99 | 39 100 | 10 3 4 9 4 2 101 | 1048573 380985 102 | 103 | 40 104 | 11 2 8 9 4 4 105 | 1048573 380985 106 | 107 | 41 108 | 11 2 8 9 4 4 109 | 2097143 360889 110 | 111 | 42 112 | 11 2 3 10 3 4 113 | 2097143 360889 114 | 115 | 43 116 | 11 2 3 10 3 4 117 | 4194301 914334 118 | 119 | 44 120 | 15 4 8 7 1 6 121 | 4194301 914334 122 | 123 | 45 124 | 15 4 8 7 1 6 125 | 8388593 653276 126 | 127 | 46 128 | 17 3 10 6 1 1 129 | 8388593 653276 130 | 131 | 47 132 | 17 3 10 6 1 1 133 | 16777213 6423135 134 | 135 | 48 136 | 17 3 7 7 1 5 137 | 16777213 6423135 138 | 139 | 49 140 | 17 3 7 7 1 5 141 | 33554393 25907312 142 | 143 | 50 144 | 18 7 5 7 1 4 145 | 33554393 25907312 146 | 147 | 51 148 | 18 7 5 7 1 4 149 | 67108859 26590841 150 | 151 | 52 152 | 15 7 4 11 2 7 153 | 67108859 26590841 154 | 155 | 53 156 | 15 7 4 11 2 7 157 | 134217689 45576512 158 | 159 | 54 160 | 17 5 10 10 3 2 161 | 134217689 45576512 162 | 163 | 55 164 | 17 5 10 10 3 2 165 | 268435399 31792125 166 | 167 | 56 168 | 17 3 11 11 2 8 169 | 268435399 31792125 170 | 171 | 57 172 | 17 3 11 11 2 8 173 | 536870909 16538103 174 | 175 | 58 176 | 18 7 10 11 2 6 177 | 536870909 16538103 178 | 179 | 59 180 | 18 7 10 11 2 6 181 | 1073741789 5122456 182 | 183 | 60 184 | 21 2 12 9 4 5 185 | 1073741789 5122456 186 | 187 | 61 188 | 21 2 12 9 4 5 189 | 2147483647 1389796 190 | 191 | 62 192 | 20 3 8 11 2 6 193 | 2147483647 1389796 194 | -------------------------------------------------------------------------------- /mylib/annexea.tex: -------------------------------------------------------------------------------- 1 | 2 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 3 | 4 | \section{Obsolete identifiers} 5 | 6 | The following identifiers from older versions of {\tt MyLib} 7 | have been eliminated or replaced. 8 | 9 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 10 | 11 | 12 | 13 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 14 | 15 | \subsection{util} 16 | 17 | \begin{itemize} 18 | 19 | \item {\tt util\_Free} 20 | 21 | the prototype has changed. 22 | 23 | \end{itemize} 24 | 25 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 26 | 27 | 28 | \subsection{num} 29 | 30 | \begin{itemize} 31 | 32 | \item {\tt num\_MaxLongInt} 33 | 34 | use {\tt INT\_MAX} from $<${\tt limits.h}$>$ 35 | 36 | \item {\tt num\_MaxLongIntLR} 37 | 38 | use {\tt INT\_MAX from} $<${\tt limits.h}$>$ 39 | 40 | \item {\tt num\_LgMaxLongInt1} 41 | 42 | Eliminated. 43 | 44 | \item {\tt num\_InvLn2} 45 | 46 | Eliminated. 47 | 48 | \item {\tt num\_MaxIntLongReal} 49 | 50 | is now called {\tt num\_MaxIntDouble}. 51 | 52 | \item {\tt num\_MaxLongReal} 53 | 54 | use {\tt DBL\_MAX} from $<${\tt float.h}$>$ 55 | 56 | \item {\tt num\_MantDig} 57 | 58 | use {\tt DBL\_MANT\_DIG} from $<${\tt float.h}$>$ 59 | 60 | \item {\tt num\_hLR} 61 | 62 | use {\tt DBL\_EPSILON/2} from $<${\tt float.h}$>$ 63 | 64 | \item {\tt num\_chLR} 65 | 66 | use {\tt 1 - DBL\_EPSILON/2} from $<${\tt float.h}$>$ 67 | 68 | \item {\tt num\_jLR} 69 | 70 | use {\tt 0.75*DBL\_EPSILON} from $<${\tt float.h}$>$ 71 | 72 | 73 | \item {\tt num\_SCeilLR (x)} 74 | 75 | use {\tt nextafter (x, 1.0)} from $<${\tt math.h}$>$ 76 | 77 | \item {\tt num\_Lg} 78 | 79 | use {\tt log2} from $<${\tt math.h}$>$ 80 | 81 | \item {\tt num\_ModLR} 82 | 83 | use {\tt fmod} from $<${\tt math.h}$>$ 84 | 85 | \item {\tt num\_TruncLR} 86 | 87 | use {\tt modf} from $<${\tt math.h}$>$ 88 | 89 | \item {\tt num\_RoundLR (x)} 90 | 91 | use {\tt floor (x + 0.5)} from $<${\tt math.h}$>$ 92 | 93 | \item {\tt num\_WriteLR} 94 | 95 | is now called {\tt num\_WriteD}. 96 | 97 | \item {\tt num\_MultModLI} 98 | 99 | is now called {\tt num\_MultModL} 100 | 101 | \item {\tt num\_MultModLR} 102 | 103 | is now called {\tt num\_MultModD} 104 | 105 | \end{itemize} 106 | 107 | 108 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 109 | 110 | \subsection{num2} 111 | 112 | \begin{itemize} 113 | 114 | \item {\tt num2\_Combinaison (s, n)} 115 | 116 | replaced by {\tt num2\_Combination (n, s)}. 117 | \end{itemize} 118 | 119 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 120 | 121 | \subsection{tables} 122 | 123 | \begin{itemize} 124 | 125 | \item {\tt tables\_TabLI} 126 | 127 | use {\tt long *} 128 | 129 | \item {\tt tables\_TabLR} 130 | 131 | use {\tt double *} 132 | 133 | \item {\tt tables\_TabUL, tables\_TabBit} 134 | 135 | use {\tt unsigned long *} 136 | 137 | 138 | \item {\tt tables\_MatLI} 139 | 140 | use {\tt long **} 141 | 142 | \item {\tt tables\_MatLR} 143 | 144 | use {\tt double **} 145 | 146 | \item {\tt tables\_MatUL, tables\_MatBit} 147 | 148 | use {\tt unsigned long **} 149 | 150 | \item {\tt tables\_CreateTab} 151 | 152 | use {\tt util\_Calloc} 153 | 154 | \item {\tt tables\_DeleteTab} 155 | 156 | use {\tt util\_Free} 157 | 158 | \item {\tt tables\_ResizeTab} 159 | 160 | use {\tt util\_Realloc} 161 | 162 | \item {\tt tables\_WriteTabLI} 163 | 164 | use {\tt tables\_WriteTabL} 165 | 166 | \item {\tt tables\_WriteTabLR } 167 | 168 | use {\tt tables\_WriteTabD} 169 | 170 | \item {\tt tables\_WriteMatrixLI} 171 | 172 | use {\tt tables\_WriteMatrixL} 173 | 174 | \item {\tt tables\_WriteMatrixLR} 175 | 176 | use {\tt tables\_WriteMatrixD} 177 | 178 | \item {\tt tables\_HachageMod} 179 | 180 | use {\tt tables\_HashPrime} 181 | 182 | \end{itemize} 183 | 184 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 185 | -------------------------------------------------------------------------------- /testu01/ucubic.tex: -------------------------------------------------------------------------------- 1 | \defmodule{ucubic} 2 | 3 | This module implements simple and combined cubic congruential 4 | generators, based on recurrences of the form 5 | \eq 6 | x_{n+1} = (a x_n^3 + b x_n^2 + c x_n + d) \mod m, \eqlabel{cubic} 7 | \endeq 8 | with output $u_n = x_n/m$ at step $n$. 9 | See, e.g., \cite{rEIC97a,rLEC98h}. 10 | 11 | Generators based on a linear congruential recurrence, but with 12 | a cubic output transformation, are also available 13 | (see {\tt ucubic\_CreateCubicOut}). 14 | 15 | 16 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 17 | \bigskip 18 | \hrule 19 | \code 20 | \hide 21 | /* ucubic.h for ANSI C */ 22 | #ifndef UCUBIC_H 23 | #define UCUBIC_H 24 | \endhide 25 | #include "unif01.h" 26 | 27 | 28 | unif01_Gen * ucubic_CreateCubic (long m, long a, long b, long c, long d, 29 | long s); 30 | \endcode 31 | \tab Initializes a generator of the form (\ref{cubic}), with 32 | initial state $x_0 = s$. 33 | \index{Generator!cubic}% 34 | Depending on the values of the parameters, various implementations 35 | of different speed are used. 36 | In general, this generator is rather slow. 37 | Restrictions: $a$, $b$, $c$, $d$, and $s$ non 38 | negative and less than $m$. 39 | \endtab 40 | \code 41 | 42 | 43 | unif01_Gen * ucubic_CreateCubicFloat (long m, long a, long b, long c, 44 | long d, long s); 45 | \endcode 46 | \tab A floating-point implementation of the same generator as in 47 | {\tt ucubic\_CreateCubic}. 48 | The implementation depends on the parameter values and is slower 49 | when $m(m-1) > 2^{53}$. 50 | The same restrictions as for {\tt ucubic\_CreateCubic} apply. 51 | Also assumes that a {\tt double} has at least 53 bits of precision. 52 | \endtab 53 | \code 54 | 55 | 56 | unif01_Gen * ucubic_CreateCubic1 (long m, long a, long s); 57 | \endcode 58 | \tab Implements a cubic generator which is a special case of 59 | (\ref{cubic}), with recurrence $x_{n+1} = (a x_n^3 + 1) \mod m$. 60 | The initial state is $x_0 = s$ and the $n$-th generated value 61 | is $u_n = x_n/m$. 62 | Restrictions: $a$ and $s$ non negative and less than $m$. 63 | \endtab 64 | \code 65 | 66 | 67 | unif01_Gen * ucubic_CreateCubic1Float (long m, long a, long s); 68 | \endcode 69 | \tab Floating-point implementation of the same generator as in 70 | {\tt ucubic\_CreateCubic1}. The implementation and restrictions are 71 | similar to those in {\tt ucubic\_CreateCubicFloat}. 72 | \endtab 73 | \code 74 | 75 | 76 | unif01_Gen * ucubic_CreateCombCubic2 (long m1, long m2, long a1, long a2, 77 | long s1, long s2); 78 | \endcode 79 | \tab Implements a generator that combines two cubic components 80 | of the same type as in the procedure {\tt ucubic\_CreateCubic1}. 81 | The output is 82 | $ u_n = (x_{1,n}/m_1 + x_{2,m}/m_2) \mod 1, $ 83 | where $x_{1,n}$ and $x_{2,n}$ are the states of the two components 84 | at step $n$. 85 | \endtab 86 | \code 87 | 88 | 89 | unif01_Gen * ucubic_CreateCubicOut (long m, long a, long c, long s); 90 | \endcode 91 | \tab Initializes a generator defined by the linear recurrence 92 | $x_{n+1} = (a x_n + c) \mod m$, with initial state $x_0 = s$, 93 | and with output $u_n = (x_n^3 \mod m) / m$. 94 | Restrictions: $a$, $c$ and $s$ non negative and less than $m$. 95 | \endtab 96 | \code 97 | 98 | 99 | unif01_Gen * ucubic_CreateCubicOutFloat (long m, long a, long c, long s); 100 | \endcode 101 | \tab A floating-point implementation of {\tt ucubic\_CreateCubicOut}. 102 | The implementation and restrictions are similar to those in 103 | {\tt ucubic\_CreateCubicFloat}. 104 | \endtab 105 | 106 | 107 | 108 | \guisec{Clean-up functions} 109 | \code 110 | 111 | void ucubic_DeleteGen (unif01_Gen *gen); 112 | \endcode 113 | \tab \DelGen 114 | \endtab 115 | \code 116 | \hide 117 | #endif 118 | \endhide 119 | \endcode 120 | -------------------------------------------------------------------------------- /testu01/bintro.tex: -------------------------------------------------------------------------------- 1 | \chapter{BATTERIES OF TESTS} 2 | 3 | This chapter describes predefined batteries of tests available 4 | in TestU01. 5 | % Some batteries are more suitable for generators returning uniform 6 | % floating-point numbers in the interval $[0, 1)$, 7 | % while others are more oriented towards random bit generators. 8 | Some batteries are fast and small, and may be used as a first step in 9 | detecting gross defects in generators or errors in their implementation. 10 | Other batteries are more stringent and take longer to run. 11 | % They can often detect flaws in low or medium quality RNGs. 12 | Special batteries are also available to test a stream of random bits 13 | taken from a file. 14 | % One has been designed specially for hardware random bit generators. 15 | 16 | 17 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 18 | \paragraph*{An example: The battery SmallCrush applied to a generator.} \ 19 | 20 | Figure~\ref{fig:bat1.c} shows how to apply a battery of tests to a 21 | generator. The function call to {\tt ulcg\_CreateLCG} creates and initializes the 22 | generator {\tt gen} to the linear congruential generator (LCG) with 23 | modulus $m$ = 2147483647, multiplier $a$ = 16807, additive constant $c=0$, 24 | and initial state $x_0 = 12345$. 25 | % This LCG is still widely used in commercial software. 26 | Then the small battery {\tt SmallCrush}, defined in module 27 | {\tt bbattery}, is applied on this generator. 28 | Figure~\ref{fig:bat1.res} shows a summary report of the results 29 | (assuming that 64-bits integers are available; otherwise, the results could 30 | be slightly different). 31 | Out of the 15 tests applied, the generator failed three with a $p$-value 32 | practically equal to 0, so it is clear that it failed this battery. 33 | It took 20.3 seconds to run this battery on a machine with a 34 | 2400 MHz Athlon processor running under Linux. 35 | 36 | 37 | \setbox0=\vbox {\hsize = 6.0in 38 | \smallc 39 | \verbatiminput{../examples/bat1.c} 40 | } 41 | 42 | \begin{figure}[hbt] \centering \myboxit{\box0} 43 | \caption{Applying the battery SmallCrush on a LCG generator.} 44 | \label{fig:bat1.c} 45 | \end{figure} 46 | 47 | 48 | \setbox1=\vbox {\hsize = 6.0in 49 | \smallc 50 | \verbatiminput{../examples/bat1.res} 51 | } 52 | 53 | \begin{figure}[ht] \centering \myboxit{\box1} 54 | \caption{Results of applying SmallCrush.} \label{fig:bat1.res} 55 | \end{figure} 56 | 57 | 58 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 59 | \paragraph*{Another example: The battery Rabbit applied to a binary file.} \ 60 | 61 | 62 | Figure~\ref{fig:bat2.c} shows how to apply the battery 63 | {\tt Rabbit} to a binary file (presumably, a file of random bits). 64 | The tests will use at most 1048576 ($=2^{20}$) bits from the 65 | binary file named {\tt vax.bin}. 66 | (Incidentally, these bits were obtained by taking the 32 most significant 67 | bits from each uniform number generated by 68 | the well-known LCG with parameters $m = 2^{32}$, $a = 69069$ and $c=1$. 69 | This was the random number generator used under VAX/VMS.) 70 | Since the variable {\tt swrite\_Basic} is set to {\tt FALSE}, 71 | no detailed output is written, only the summary report shown in 72 | Figure~\ref{fig:bat2.res} is printed after running the tests. 73 | Seven tests were failed with a $p$-value practically equal to 0 or 1. 74 | It is clear that the null hypothesis $\cH_0$ must be rejected for 75 | this bit stream. 76 | It took 1.9 seconds to run the entire battery on a machine with a 77 | 2400 MHz Athlon processor running under Linux. 78 | 79 | \setbox0=\vbox {\hsize = 6.0in 80 | \smallc 81 | \verbatiminput{../examples/bat2.c} 82 | } 83 | 84 | \begin{figure} \centering \myboxit{\box0} 85 | \caption{Applying the battery Rabbit on a file of random bits.} 86 | \label{fig:bat2.c} 87 | \end{figure} 88 | 89 | 90 | \setbox1=\vbox {\hsize = 6.0in 91 | \smallc 92 | \verbatiminput{../examples/bat2.res} 93 | } 94 | 95 | \begin{figure} \centering \myboxit{\box1} 96 | \caption{Results of applying Rabbit.} \label{fig:bat2.res} 97 | \end{figure} 98 | -------------------------------------------------------------------------------- /mylib/bitset.tex: -------------------------------------------------------------------------------- 1 | \defmodule {bitset} 2 | 3 | This module defines sets of bits and useful operations for such sets. 4 | Some of these operations are implemented as macros. 5 | 6 | \code\hide 7 | /* bitset.h for ANSI C */ 8 | #ifndef BITSET_H 9 | #define BITSET_H 10 | #include "gdef.h" 11 | \endhide\endcode 12 | 13 | 14 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 15 | \guisec{Constants} 16 | \code 17 | 18 | extern unsigned long bitset_maskUL[]; 19 | \endcode 20 | \tab {\tt bitset\_maskUL[j]} has bit $j$ set to 1 and all other bits set to 21 | 0. Bit 0 is the least significant bit. 22 | \endtab 23 | \code 24 | 25 | 26 | extern unsigned long bitset_MASK[]; 27 | \endcode 28 | \tab {\tt bitset\_MASK[j]} has all the first $j$ bits set to 1 and all other 29 | bits set to 0. Bit 0 is the least significant bit. 30 | \endtab 31 | 32 | 33 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 34 | \guisec{Types} 35 | \code 36 | 37 | typedef unsigned long bitset_BitSet; 38 | \endcode 39 | \tab Set of bits. Bits are numbered starting from 0 for the least 40 | significant bit. If bit $s$ is 1, then element $s$ is a member of 41 | the set, otherwise not. 42 | \endtab 43 | 44 | 45 | 46 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 47 | \guisec{Macros} 48 | 49 | \noindent 50 | {\tt bitset\_SetBit (S, b)}; 51 | 52 | \tab Sets bit {\tt b} in set {\tt S} to 1. 53 | \endtab 54 | \code 55 | \hide 56 | #define bitset_SetBit(S, b) ((S) |= (bitset_maskUL[b])) 57 | \endhide 58 | \endcode 59 | 60 | \noindent 61 | {\tt bitset\_ClearBit (S, b)}; 62 | 63 | \tab Sets bit {\tt b} in set {\tt S} to 0. 64 | \endtab 65 | \code 66 | \hide 67 | #define bitset_ClearBit(S, b) ((S) &= ~(bitset_maskUL[b])) 68 | \endhide 69 | \endcode 70 | 71 | \noindent 72 | {\tt bitset\_FlipBit (S, b)}; 73 | 74 | \tab Flips bit {\tt b} in set {\tt S}; thus, 75 | $0 \rightarrow 1$ and $1 \rightarrow 0$. 76 | \endtab 77 | \code 78 | \hide 79 | #define bitset_FlipBit(S, b) ((S) ^= (bitset_maskUL[b])) 80 | \endhide 81 | \endcode 82 | 83 | \noindent 84 | {\tt bitset\_TestBit (S, b)}; 85 | 86 | \tab Returns the value of bit {\tt b} in set {\tt S}. 87 | \endtab 88 | \code 89 | \hide 90 | #define bitset_TestBit(S, b) ((S) & (bitset_maskUL[b]) ? 1 : 0) 91 | \endhide 92 | \endcode 93 | 94 | \noindent 95 | {\tt bitset\_RotateLeft (S, t, r)}; 96 | 97 | \tab Rotates the {\tt t} bits of set {\tt S} by {\tt r} bits to the left. 98 | {\tt S} is considered as a {\tt t}-bit number kept 99 | in the least significant bits of the equivalent number {\tt S}. 100 | \endtab 101 | \code 102 | \hide 103 | #define bitset_RotateLeft(S, t, r) do { \ 104 | unsigned long v853 = (S) >> ((t) - (r)); \ 105 | (S) <<= (r); (S) |= v853; (S) &= bitset_MASK[t]; \ 106 | } while (0) 107 | \endhide 108 | \endcode 109 | 110 | \noindent 111 | {\tt bitset\_RotateRight (S, t, r)}; 112 | 113 | \tab Rotates the {\tt t} bits of set {\tt S} by {\tt r} bits to the right. 114 | {\tt S} is considered as a {\tt t}-bit number kept 115 | in the least significant bits of the equivalent number {\tt S}. 116 | \endtab 117 | \code 118 | \hide 119 | #define bitset_RotateRight(S, t, r) do { \ 120 | unsigned long v972 = (S) >> (r); \ 121 | (S) <<= ((t) - (r)); (S) |= v972; (S) &= bitset_MASK[t]; \ 122 | } while (0) 123 | \endhide 124 | \endcode 125 | 126 | 127 | 128 | 129 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 130 | \guisec{Prototypes} 131 | \code 132 | 133 | bitset_BitSet bitset_Reverse (bitset_BitSet Z, int s); 134 | \endcode 135 | \tab Reverses the {\tt s} least significant bits of {\tt Z} considered as a 136 | number. Thus, if {\tt s}${}=4$ and {\tt Z}${}=0011$, the returned value is $1100$. 137 | \endtab 138 | \code 139 | 140 | 141 | void bitset_WriteSet (char *desc, bitset_BitSet Z, int s); 142 | \endcode 143 | \tab 144 | Prints the string {\tt desc} (which may be empty), then writes the {\tt 145 | s} least significant bits of {\tt Z} considered as an unsigned binary number. 146 | This corresponds to the {\tt s} first elements of {\tt Z}. 147 | \endtab 148 | \code 149 | \hide 150 | #endif 151 | \endhide 152 | \endcode 153 | -------------------------------------------------------------------------------- /testu01/fwalk.tex: -------------------------------------------------------------------------------- 1 | \defmodule {fwalk} 2 | 3 | This module applies random-walk tests from the module {\tt swalk} 4 | to a family of generators of different sizes. 5 | 6 | \bigskip 7 | \hrule 8 | \code\hide 9 | /* fwalk.h for ANSI C */ 10 | #ifndef FWALK_H 11 | #define FWALK_H 12 | \endhide 13 | #include "ffam.h" 14 | #include "fres.h" 15 | #include "fcho.h" 16 | 17 | 18 | extern long fwalk_Maxn; 19 | extern long fwalk_MaxL; 20 | extern double fwalk_MinMu; 21 | \endcode 22 | \tab 23 | Upper bounds on $n$, $L$ and lower bound on Mu. 24 | When $n$, $L$ or Mu exceed their limit value, the tests are not done. 25 | Default values: $n = 2^{22}$, $L = 2^{22}$ and Mu ${} = 2^{-22}$. 26 | \endtab 27 | 28 | 29 | \ifdetailed %%%%%%%%%%%%%%% 30 | 31 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 32 | \guisec{Structure for test results} 33 | 34 | This structure is used to keep tables of results for the 35 | {\tt fwalk\_RWalk1} test. 36 | \code 37 | 38 | typedef struct { 39 | fres_Cont *H; 40 | fres_Cont *M; 41 | fres_Cont *J; 42 | fres_Cont *R; 43 | fres_Cont *C; 44 | } fwalk_Res1; 45 | \endcode 46 | \tab The five statistics {\tt H}, {\tt M}, {\tt J}, {\tt R}, and {\tt C} 47 | are defined in the documentation of module {\tt swalk}. 48 | \endtab 49 | \code 50 | 51 | 52 | fwalk_Res1 * fwalk_CreateRes1 (void); 53 | \endcode 54 | \tab 55 | Creates and returns a structure that will hold the results 56 | of a {\tt fwalk\_RWalk1} test. 57 | \endtab 58 | \code 59 | 60 | 61 | void fwalk_DeleteRes1 (fwalk_Res1 *res); 62 | \endcode 63 | \tab 64 | Frees the memory allocated by {\tt fwalk\_CreateRes1}. 65 | \endtab 66 | 67 | \fi %%%%%%%%%%%%%%%%%% 68 | 69 | 70 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 71 | \guisec{The tests} 72 | \code 73 | 74 | void fwalk_RWalk1 (ffam_Fam *fam, fwalk_Res1 *res, fcho_Cho2 *cho, 75 | long N, long n, int r, int s, long L, 76 | int Nr, int j1, int j2, int jstep); 77 | \endcode 78 | \tab This function calls the test {\tt swalk\_RandomWalk1} with 79 | parameters {\tt N}, {\tt n}, {\tt r}, {\tt s}, and {\tt L} for the 80 | first {\tt Nr} generators of family {\tt fam}, for $j$ going from 81 | {\tt j1} to {\tt j2} by steps of {\tt jstep}. Either or both of {\tt n} 82 | and {\tt L} can be varied as the sample size, by passing a negative value as 83 | argument of the function. One must then create the corresponding function 84 | {\tt cho->Chon} or {\tt cho->Chop2} before calling the test. 85 | One will have either {\tt n} = {\tt cho->Chon->Choose(param, i, j)}, 86 | or {\tt L} = {\tt cho->Chop2->Choose(param, i, j)} or both. A positive 87 | value for {\tt n} or {\tt L} will be used as is by the test. When {\tt n} 88 | exceeds {\tt fwalk\_Maxn} or {\tt L} exceeds {\tt fwalk\_MaxL}, 89 | the test is not run. 90 | \endtab 91 | \code 92 | 93 | 94 | void fwalk_VarGeoP1 (ffam_Fam *fam, fres_Cont *res, fcho_Cho2 *cho, 95 | long N, long n, int r, double Mu, 96 | int Nr, int j1, int j2, int jstep); 97 | \endcode 98 | \tab 99 | This function calls the test {\tt swalk\_VarGeoP} with 100 | parameters {\tt N, n, r, Mu} for the first {\tt Nr} generators of 101 | family {\tt fam}, for $j$ going from {\tt j1} to {\tt j2} by steps of 102 | {\tt jstep}. Either or both of $n$ and {\tt Mu} can be varied as 103 | the sample size, by passing a negative value as argument of the 104 | function. One must then create the corresponding function 105 | {\tt cho->Chon} or {\tt cho->Chop2} before calling the test. 106 | One will have either $n = {}$ {\tt cho->Chon->Choose(param, i, j)}, 107 | or {\tt Mu} = {\tt cho->Chop2->Choose(param, i, j)}. A positive value 108 | for $n$ or {\tt Mu} will be used as is by the test. When $n$ exceeds 109 | {\tt fwalk\_Maxn} or {\tt Mu} is less than {\tt fwalk\_MinMu}, 110 | the test is not done. 111 | \endtab 112 | \code 113 | 114 | 115 | void fwalk_VarGeoN1 (ffam_Fam *fam, fres_Cont *res, fcho_Cho2 *cho, 116 | long N, long n, int r, double Mu, 117 | int Nr, int j1, int j2, int jstep); 118 | \endcode 119 | \tab Similar to {\tt fwalk\_VarGeoP1} but with {\tt swalk\_VarGeoN}. 120 | \endtab 121 | 122 | \code 123 | \hide 124 | #endif 125 | \endhide 126 | \endcode 127 | -------------------------------------------------------------------------------- /testu01/ffsr.tex: -------------------------------------------------------------------------------- 1 | \defmodule {ffsr} 2 | 3 | This module operates in the same way as {\tt fcong} 4 | (see the introduction in module {\tt fcong}). 5 | It defines {\em linear feedback shift register\/} (LFSR) generators 6 | of different period lengths (or number of states) near powers of 2, 7 | and different kinds such as Tausworthe, GFSR, twisted GFSR (TGFSR), 8 | and their combinations. 9 | All these generators are based on linear recurrences modulo 2. 10 | \index{family of generators!shift-register}% 11 | 12 | 13 | \bigskip 14 | \hrule 15 | \code\hide 16 | /* ffsr.h for ANSI C */ 17 | #ifndef FFSR_H 18 | #define FFSR_H 19 | \endhide 20 | #include "ffam.h" 21 | \endcode 22 | 23 | 24 | 25 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 26 | \guisec{The families of generators} 27 | \code 28 | 29 | ffam_Fam * ffsr_CreateLFSR1 (char *fname, int i1, int i2, int istep); 30 | \endcode 31 | \tab 32 | Creates a family of simple LFSR (or Tausworthe) generators whose 33 | parameters are defined in file named {\tt fname}. By default, uses a 34 | predefined family of generators with primitive characteristic trinomial of 35 | degree $i$ (with period length $2^i-1$) and the best equidistribution 36 | properties within its class. 37 | Restrictions: $10 \le i1 \le i2 \le 60$. 38 | \endtab 39 | \code 40 | 41 | 42 | ffam_Fam * ffsr_CreateLFSR2 (char *fname, int i1, int i2, int istep); 43 | \endcode 44 | \tab Creates a family of combined LFSR generators with two components, whose 45 | parameters are defined in file named {\tt fname}. By default, uses a 46 | predefined family with each component 47 | based on a primitive characteristic trinomial. 48 | The combination generator has period length near $2^i-1$ and the best 49 | possible equidistribution within its class. 50 | Restrictions: $10 \le i1 \le i2 \le 36$. 51 | \endtab 52 | \code 53 | 54 | 55 | ffam_Fam * ffsr_CreateLFSR3 (char *fname, int i1, int i2, int istep); 56 | \endcode 57 | \tab 58 | Creates a family of combined LFSR generators with three components, whose 59 | parameters are defined in file named {\tt fname}. By default, uses a 60 | predefined family with each component 61 | based on a primitive characteristic trinomial. 62 | The combination generator has period length near $2^i-1$ and the best 63 | possible equidistribution within its class. 64 | Restrictions: $14 \le i1 \le i2 \le 36$. 65 | \endtab 66 | \code 67 | 68 | 69 | ffam_Fam * ffsr_CreateGFSR3 (char *fname, int i1, int i2, int istep); 70 | \endcode 71 | \tab 72 | Creates a family of generalized feedback shift register (GFSR) generators 73 | with primitive characteristic trinomial of degree $i$ 74 | (period length $2^i-1$) and good equidistribution. 75 | ***** NOT YET IMPLEMENTED. 76 | \endtab 77 | \code 78 | 79 | 80 | ffam_Fam * ffsr_CreateGFSR5 (char *fname, int i1, int i2, int istep); 81 | \endcode 82 | \tab 83 | Creates a family of generalized feedback shift register (GFSR) generators 84 | with primitive characteristic pentanomial of degree $i$ 85 | (period length $2^i-1$) and good equidistribution. 86 | ***** NOT YET IMPLEMENTED. 87 | \endtab 88 | \code 89 | 90 | 91 | ffam_Fam * ffsr_CreateTGFSR1 (char *fname, int i1, int i2, int istep); 92 | \endcode 93 | \tab 94 | Creates a family of twisted GFSR generators with primitive characteristic 95 | trinomial of degree $i$ 96 | (period length $2^i-1$) and good equidistribution. 97 | ***** NOT YET IMPLEMENTED. 98 | \endtab 99 | \code 100 | 101 | 102 | ffam_Fam * ffsr_CreateTausLCG2 (char *fname, int i1, int i2, int istep); 103 | \endcode 104 | \tab 105 | Creates a family of combined generators that adds the outputs of an LCG 106 | and an LFSR2, modulo 1, whose parameters are defined in file named 107 | {\tt fname}. Each generator is created by calling the function 108 | {\tt ulec\_CreateCombTausLCG21}. By default, uses a 109 | predefined family with generators having a period near $2^i$. 110 | Restrictions: $20 \le i1 \le i2 \le 62$. 111 | \endtab 112 | 113 | 114 | 115 | 116 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% 117 | \guisec{Clean-up functions} 118 | \code 119 | 120 | void ffsr_DeleteLFSR1 (ffam_Fam *fam); 121 | void ffsr_DeleteLFSR2 (ffam_Fam *fam); 122 | void ffsr_DeleteLFSR3 (ffam_Fam *fam); 123 | void ffsr_DeleteTausLCG2 (ffam_Fam *fam); 124 | \endcode 125 | \tab 126 | Frees the dynamic memory allocated to {\tt fam} by the corresponding 127 | {\tt Create} function. 128 | \endtab 129 | \code 130 | 131 | \hide 132 | #endif 133 | \endhide 134 | \endcode 135 | -------------------------------------------------------------------------------- /mylib/addstr.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************\ 2 | * 3 | * Package: MyLib 4 | * File: addstr.c 5 | * Environment: ANSI C 6 | * 7 | * Copyright (c) 2002 Pierre L'Ecuyer, DIRO, Université de Montréal. 8 | * e-mail: lecuyer@iro.umontreal.ca 9 | * All rights reserved. 10 | * 11 | * This software is provided under the Apache 2 License. 12 | * 13 | * In scientific publications which used this software, a reference to it 14 | * would be appreciated. 15 | * 16 | \*************************************************************************/ 17 | 18 | #include "addstr.h" 19 | 20 | #include 21 | #include 22 | 23 | 24 | #define LEN1 63 25 | 26 | 27 | 28 | /* ========================== functions ================================= */ 29 | 30 | void addstr_Long (char *to, const char *add, long n) 31 | { 32 | char str[LEN1 + 1]; 33 | strcat (to, add); 34 | sprintf (str, "%1ld", n); 35 | strcat (to, str); 36 | } 37 | 38 | void addstr_Uint (char *to, const char *add, unsigned int n) 39 | { 40 | char str[LEN1 + 1]; 41 | strcat (to, add); 42 | sprintf (str, "%1u", n); 43 | strcat (to, str); 44 | } 45 | 46 | void addstr_Int (char *to, const char *add, int n) 47 | { 48 | char str[LEN1 + 1]; 49 | strcat (to, add); 50 | sprintf (str, "%1d", n); 51 | strcat (to, str); 52 | } 53 | 54 | void addstr_Ulong (char *to, const char *add, unsigned long n) 55 | { 56 | char str[LEN1 + 1]; 57 | strcat (to, add); 58 | sprintf (str, "%1lu", n); 59 | strcat (to, str); 60 | } 61 | 62 | #ifdef USE_LONGLONG 63 | void addstr_LONG (char *to, const char *add, longlong n) 64 | { 65 | char str[LEN1 + 1]; 66 | strcat (to, add); 67 | sprintf (str, "%1" PRIdLEAST64, n); 68 | strcat (to, str); 69 | } 70 | 71 | void addstr_ULONG (char *to, const char *add, ulonglong n) 72 | { 73 | char str[LEN1 + 1]; 74 | strcat (to, add); 75 | sprintf (str, "%1" PRIuLEAST64, n); 76 | strcat (to, str); 77 | } 78 | #endif 79 | 80 | void addstr_Char (char *to, const char *add, char c) 81 | { 82 | char str[LEN1 + 1]; 83 | strcat (to, add); 84 | sprintf (str, "%c", c); 85 | strcat (to, str); 86 | } 87 | 88 | void addstr_Double (char *to, const char *add, double x) 89 | { 90 | char str[LEN1 + 1]; 91 | strcat (to, add); 92 | sprintf (str, "%.16G", x); 93 | strcat (to, str); 94 | } 95 | 96 | void addstr_Bool (char *to, const char *add, int b) 97 | { 98 | strcat (to, add); 99 | if (b) 100 | strcat (to, "TRUE"); 101 | else 102 | strcat (to, "FALSE"); 103 | } 104 | 105 | void addstr_ArrayLong (char *to, const char *add, int high, long val[]) 106 | { 107 | int j; 108 | strcat (to, add); 109 | addstr_Long (to, "(", val[0]); 110 | for (j = 1; (j < high) && (j < 5); j++) 111 | addstr_Long (to, ", ", val[j]); 112 | if (high > 5) 113 | strcat (to, ", ... )"); 114 | else 115 | strcat (to, ")"); 116 | } 117 | 118 | void addstr_ArrayUlong (char *to, const char *add, 119 | int high, unsigned long val[]) 120 | { 121 | int j; 122 | strcat (to, add); 123 | addstr_Ulong (to, "(", val[0]); 124 | for (j = 1; (j < high) && (j < 5); j++) 125 | addstr_Ulong (to, ", ", val[j]); 126 | if (high > 5) 127 | strcat (to, ", ... )"); 128 | else 129 | strcat (to, ")"); 130 | } 131 | 132 | void addstr_ArrayUint (char *to, const char *add, int high, 133 | unsigned int val[]) 134 | { 135 | int j; 136 | strcat (to, add); 137 | addstr_Uint (to, "(", val[0]); 138 | for (j = 1; (j < high) && (j < 5); j++) 139 | addstr_Uint (to, ", ", val[j]); 140 | if (high > 5) 141 | strcat (to, ", ... )"); 142 | else 143 | strcat (to, ")"); 144 | } 145 | 146 | void addstr_ArrayInt (char *to, const char *add, int high, int val[]) 147 | { 148 | int j; 149 | strcat (to, add); 150 | addstr_Int (to, "(", val[0]); 151 | for (j = 1; (j < high) && (j < 5); j++) 152 | addstr_Int (to, ", ", val[j]); 153 | if (high > 5) 154 | strcat (to, ", ... )"); 155 | else 156 | strcat (to, ")"); 157 | } 158 | 159 | void addstr_ArrayDouble (char *to, const char *add, 160 | int high, double val[]) 161 | { 162 | int j; 163 | strcat (to, add); 164 | addstr_Double (to, "(", val[0]); 165 | for (j = 1; (j < high) && (j < 5); j++) 166 | addstr_Double (to, ", ", val[j]); 167 | if (high > 5) 168 | strcat (to, ", ... )"); 169 | else 170 | strcat (to, ")"); 171 | } 172 | -------------------------------------------------------------------------------- /testu01/uvaria.tex: -------------------------------------------------------------------------------- 1 | \defmodule {uvaria} 2 | 3 | Implements various special generators proposed in the litterature. 4 | 5 | 6 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 7 | \bigskip 8 | \hrule 9 | \code 10 | \hide 11 | /* uvaria.h for ANSI C */ 12 | 13 | #ifndef UVARIA_H 14 | #define UVARIA_H 15 | \endhide 16 | #include "unif01.h" 17 | 18 | 19 | unif01_Gen * uvaria_CreateACORN (int k, double S[]); 20 | \endcode 21 | \tab Initializes a generator ACORN (Additive COngruential Random Number) 22 | \cite{rWIK89a} of order $k$ and 23 | \index{Generator!ACORN}% 24 | whose initial state is given by the vector {\tt S[0..(k-1)]}. 25 | \endtab 26 | \code 27 | 28 | 29 | unif01_Gen * uvaria_CreateCSD (long v, long s); 30 | \endcode 31 | \tab Implements the generator proposed by Sherif and 32 | \index{Generator!Sherif-Dear}% 33 | Dear in \cite{rSHE90a}. The initial state of the generator is given 34 | by {\tt v}. The generator uses a MLCG generator whose 35 | initial state is given by {\tt s}. Restrictions: 36 | {\tt $0 \le$ v $\le 9999$} and {\tt $0 <$ s $< 2^{31}-1$}. 37 | \endtab 38 | \code 39 | 40 | 41 | unif01_Gen * uvaria_CreateRanrotB (unsigned int seed); 42 | \endcode 43 | \tab 44 | This is a lagged-Fibonacci-type random number generator, but 45 | \index{Generator!RANROT}% 46 | with a rotation of bits, called RANROT, and proposed by 47 | Fog \cite{rFOG01a}. The variant programmed here is RANROT of type B. 48 | \hrichard {Voici ce que Agner Fog m'a r\'epondu: 49 | The theoretical description is on my website. 50 | The scientific journals will only publish code that is supported by 51 | theoretical proof, and my point is that such proof may not be possible for 52 | the best generators. } 53 | The algorithm is: 54 | $$ 55 | X_n = \left((X_{n-j}\ \mbox{rotl}\ r_1) + 56 | (X_{n-k}\ \mbox{rotl}\ r_2)\right) \mod 2^b 57 | $$ 58 | where rotl denotes a left rotation of the bits, 59 | each $X_n$ is an {\tt unsigned int}, 60 | and $b$ is the number of bits in an {\tt unsigned int}. 61 | The output value is $u_n = X_n/2^b$. 62 | The last $k$ values of $X$ are stored in a circular buffer 63 | (here of size 17, with $r_1 = 5$ and $r_2 = 3$). 64 | Information about RANROT generators can be found at 65 | \url{http://www.agner.org/random/}. 66 | 67 | % Restrictions: {\tt type = 'B'}. 68 | Since Fog's code is copied verbatim here, there are global 69 | variables in the implementation. Thus no more than 70 | one generator of that type can be in use at any given time. 71 | % Using two or more simultaneously will give meaningless results. 72 | \endtab 73 | \code 74 | 75 | 76 | unif01_Gen * uvaria_CreateRey97 (double a1, double a2, double b2, long n0); 77 | \endcode 78 | \tab Generator proposed by W.\ Rey \cite{rREY98a}. 79 | % , of Philips Research 80 | \index{Generator!Rey}% 81 | It uses the recurrence: 82 | \begin {eqnarray} 83 | z_i &=& a_1 \sin (b_1 (i+n_0)) \mod 1;\\ 84 | u_i &=& (a_2 + z_i) \sin (b_2 z) \mod 1, 85 | \end {eqnarray} 86 | where $b_1 = (\sqrt{5}-1) \pi/2$. 87 | According to the author, $a_1$, $a_2$ and $b_2$ should be chosen 88 | sufficiently large. 89 | \endtab 90 | \code 91 | 92 | 93 | unif01_Gen * uvaria_CreateTindo (long b, long Delta, int s, int k); 94 | \endcode 95 | \tab Initializes the parameters of the generator proposed 96 | \index{Generator!Tindo}% 97 | by Tindo in \cite{rTIN90a}, with $a_0 = b - {\tt Delta}$ and 98 | $a_1 = {\tt Delta} + 1$. Assumes that $0 < {\tt Delta} < b-1$ and 99 | $b < 2^{15} = 32768$. 100 | Restrictions: $1 \le k \le 32$, $1 \le s \le 32$. 101 | \endtab 102 | 103 | 104 | \guisec{Clean-up functions} 105 | \code 106 | 107 | void uvaria_DeleteACORN (unif01_Gen *gen); 108 | \endcode 109 | \tab Frees the dynamic memory used by the {\tt ACORN} 110 | generator and allocated by the corresponding {\tt Create} function 111 | above. 112 | \endtab 113 | \code 114 | 115 | 116 | void uvaria_DeleteRanrotB (unif01_Gen *gen); 117 | \endcode 118 | \tab Frees the dynamic memory used by the {\tt RanrotB} 119 | generator and allocated by the corresponding {\tt Create} function 120 | above. 121 | \endtab 122 | \code 123 | 124 | 125 | void uvaria_DeleteGen (unif01_Gen *gen); 126 | \endcode 127 | \tab Frees the dynamic memory used by any generator of this module 128 | that does not have an explicit {\tt Delete} function. 129 | This function should be called to clean up a generator object 130 | when it is no longer in use. 131 | \endtab 132 | 133 | \code 134 | \hide 135 | #endif 136 | \endhide 137 | \endcode 138 | -------------------------------------------------------------------------------- /mylib/num2.tex: -------------------------------------------------------------------------------- 1 | \defmodule {num2} 2 | 3 | This module provides procedures to compute a few numerical 4 | quantities such as factorials, combinations, Stirling numbers, 5 | Bessel functions, gamma functions, and so on. 6 | These functions are more esoteric than those provided by {\tt num}. 7 | 8 | \bigskip\hrule 9 | \code\hide 10 | /* num2.h for ANSI C */ 11 | 12 | #ifndef NUM2_H 13 | #define NUM2_H 14 | \endhide 15 | #include "gdef.h" 16 | #include 17 | \endcode 18 | 19 | %%%%%%%%%%%%%%%%%%%% 20 | \guisec{Prototypes} 21 | \code 22 | 23 | double num2_Factorial (int n); 24 | \endcode 25 | \tab The factorial function. Returns the value of $n!$ 26 | \endtab 27 | \code 28 | 29 | 30 | double num2_LnFactorial (int n); 31 | \endcode 32 | \tab Returns the value of $\ln (n!)$, the natural logarithm of the 33 | factorial of $n$. Gives at least 16 decimal digits of precision 34 | (relative error $< 0.5\times 10^{-15}$) 35 | \endtab 36 | \code 37 | 38 | 39 | double num2_Combination (int n, int s); 40 | \endcode 41 | \tab Returns the value of ${n \choose s}$, the number of different combinations 42 | of $s$ objects amongst $n$. % Uses an algorithm that prevents overflows 43 | % (when computing factorials), if possible. 44 | \endtab 45 | \code 46 | 47 | 48 | #ifdef HAVE_LGAMMA 49 | #define num2_LnGamma lgamma 50 | #else 51 | double num2_LnGamma (double x); 52 | #endif 53 | \endcode 54 | \tab Calculates the natural logarithm of the gamma function $\Gamma(x)$ 55 | at {\tt x}. Our {\tt num2\_LnGamma} gives 16 decimal digits 56 | of precision, but is implemented only for $x>0$. 57 | The function {\tt lgamma} is from the {\tt ISO C99} standard math library. 58 | \endtab 59 | \code 60 | 61 | 62 | double num2_Digamma (double x); 63 | \endcode 64 | \tab Returns the value of the logarithmic derivative of the Gamma function 65 | $\psi(x) = \Gamma'(x) / \Gamma(x)$. 66 | \endtab 67 | \code 68 | 69 | 70 | #ifdef HAVE_LOG1P 71 | #define num2_log1p log1p 72 | #else 73 | double num2_log1p (double x); 74 | #endif 75 | \endcode 76 | \tab Returns a value equivalent to {\tt log}$(1 + x)$ accurate also for small 77 | $x$. The function {\tt log1p} is from the {\tt ISO C99} standard math library. 78 | \endtab 79 | \code 80 | 81 | 82 | void num2_CalcMatStirling (double *** M, int m, int n); 83 | \endcode 84 | \tab Calculates the Stirling numbers of the second kind, 85 | \eq 86 | M[i,j] = \left\{\begin{array}{c}j \\ i\end{array}\right\} 87 | \quad \mbox { for $0\le i\le m$ and $0\le i\le j\le n$}. 88 | \label{Stirling2} 89 | \endeq 90 | See D. E. Knuth, {\em The Art of Computer Programming\/}, vol.~1, 91 | second ed., 1973, Section 1.2.6. 92 | The matrix $M$ is the transpose of Knuth's (1973). 93 | This procedure allocates memory for the 2-dimensionnal matrix $M$, 94 | and fills it with the values of Stirling numbers; 95 | the memory should be freed 96 | later with the function {\tt num2\_FreeMatStirling}. 97 | \endtab 98 | \code 99 | 100 | 101 | void num2_FreeMatStirling (double *** M, int m); 102 | \endcode 103 | \tab Frees the memory space used by the Stirling matrix created by calling 104 | {\tt num2\_CalcMatStirling}. The parameter {\tt m} 105 | must be the same as the {\tt m} in {\tt num2\_CalcMatStirling}. 106 | \endtab 107 | \code 108 | 109 | 110 | double num2_VolumeSphere (double p, int t); 111 | \endcode 112 | \tab Calculates the volume $V$ of a sphere of radius 1 in $t$ dimensions 113 | using the norm $L_p$, according to the formula 114 | $$ 115 | V = \frac{\left[2 \Gamma(1 + 1/p)\right]^t} 116 | {\Gamma\left(1 + t/p\right)}, \qquad p > 0, 117 | $$ 118 | where $\Gamma$ is the well-known gamma function. 119 | The case of the sup norm $L_\infty$ is 120 | obtained by choosing $p=0$. 121 | Restrictions: $p\ge 0$ and $t\ge 1$. 122 | \endtab 123 | \code 124 | 125 | 126 | double num2_EvalCheby (const double A[], int N, double x); 127 | \endcode 128 | \tab Evaluates a series of Chebyshev polynomials $T_j$, at point 129 | $x \in [-1, \;1]$, using the method of Clenshaw \cite{mCLE62a}, 130 | i.e. calculates and returns 131 | $$ 132 | y = \frac{A_0}2 + \sum_{j=1}^N A_j T_j(x). 133 | $$ 134 | \endtab 135 | \code 136 | 137 | 138 | double num2_BesselK025 (double x); 139 | \endcode 140 | \tab Returns the value of $K_{1/4}(x)$, where $K_{\nu}$ is the modified 141 | Bessel's 142 | function of the second kind. 143 | The relative error on the returned value is less than 144 | $0.5\times 10^{-6}$ for $x > 10^{-300}$. 145 | \endtab 146 | \code 147 | \hide 148 | 149 | #endif 150 | \endhide 151 | \endcode 152 | 153 | 154 | 155 | 156 | 157 | -------------------------------------------------------------------------------- /testu01/guidetestu01.tex: -------------------------------------------------------------------------------- 1 | % 2 | % User's guide for the software library TestU01 3 | % 4 | \documentclass[12pt]{report} 5 | \usepackage{url} 6 | \usepackage{makeidx} 7 | \usepackage{verbatim} 8 | \usepackage{supertabular} 9 | 10 | % The symbols for the complex, the real, the integers, the fields. 11 | \usepackage{amssymb} 12 | %% $\mathbb{C, R, N, Z, F}$ 13 | 14 | \input ../doc/myarticle.sty 15 | 16 | \def\myboxit#1{\vbox{\hrule height1pt 17 | \hbox{\vrule width1pt\kern10pt 18 | \vbox{\kern3pt#1\kern3pt 19 | }\kern10pt\vrule width1pt 20 | }\hrule height1pt }} 21 | 22 | \makeindex 23 | 24 | \def\To {\Rightarrow} 25 | \def\o {{(o)}} 26 | \newcommand\cH{\mathcal{H}} 27 | \def\bv {{\bf v}} 28 | \def\bx {{\bf x}} 29 | \def\bA {{\bf A}} 30 | \def\bI {{\bf I}} 31 | \def\bL {{\bf L}} 32 | \def\bR {{\bf R}} 33 | \def\tpose{^{\sf T}} 34 | 35 | \newcommand\guisec[1]{\vspace{20pt}% 36 | \noindent\hrulefill\hspace{10pt}{\bf #1}\hspace{10pt}\hrulefill% 37 | \nopagebreak\vspace{10pt}} 38 | 39 | \newcommand{\DelGen}{Frees the dynamic memory used by any generator 40 | returned by the {\tt Create} functions of this module. 41 | This function should be called to clean up any generator object of this 42 | module when it is no longer in use.} 43 | 44 | \newcommand{\resdef}{The parameter {\tt res} is usually set to the 45 | {\tt NULL} pointer. 46 | However, if one wants to examine or post-process the results after a 47 | test, then one must explicitly create a {\tt res} structure. 48 | \ifdetailed \else 49 | See the detailed version of this guide for the definition of the 50 | structures and the relevant instructions.\fi\bigskip} 51 | 52 | \newtheorem {theorem}{Theorem} 53 | \newtheorem {proposition}{Proposition} 54 | \newtheorem {lemma}{Lemma} 55 | \newtheorem {corollary}{Corollary} 56 | \newtheorem {assumption}{Assumption} 57 | \newtheorem {example}{Example} 58 | 59 | % \def\pierre#1 {\fbox {\footnote {\ }}\ \footnotetext { From Pierre: #1}} 60 | \def\richard#1 {\fbox {\footnote {\ }}\ \footnotetext { From Richard: #1}} 61 | \def\hpierre#1{} 62 | \def\hrichard#1{} 63 | \def\myurl{\url{http://www.iro.umontreal.ca/~lecuyer}} 64 | \def\mycode{\code} 65 | \def\myendcode{\endcode} 66 | 67 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 68 | % Switch to get a more/less detailed version of the user's guide. 69 | 70 | \newif\ifdetailed\detailedfalse 71 | \newenvironment{detailed}{\protect\ifdetailed }{\protect\fi } 72 | % \detailedtrue % For a more detailed user's guide. 73 | 74 | % \includeonly {bbattery} 75 | 76 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 77 | \begin {document} 78 | \include {title} 79 | 80 | \pagenumbering{roman} 81 | \include {copyright} 82 | \addcontentsline{toc}{chapter}{Copyright} 83 | \tableofcontents 84 | \clearpage 85 | 86 | \pagenumbering{arabic} 87 | 88 | \include {intro} 89 | \include {uintro} 90 | \include {unif01} 91 | \include {ulcg} 92 | \include {umrg} 93 | \include {ucarry} 94 | \include {utaus} 95 | \include {ugfsr} 96 | \include {uinv} 97 | \include {uquad} 98 | \include {ucubic} 99 | \include {uxorshift} 100 | \include {ubrent} 101 | \include {ulec} 102 | \include {utezuka} 103 | \include {umarsa} 104 | \include {uknuth} 105 | \include {utouzin} 106 | \include {ugranger} 107 | \include {uwu} 108 | \include {udeng} 109 | \include {uweyl} 110 | \include {unumrec} 111 | \include {uautomata} 112 | % \include {vectorsF2} 113 | \include {ucrypto} 114 | \include {usoft} 115 | \include {uvaria} 116 | \include {ufile} 117 | 118 | \include {sintro} 119 | \include {swrite} 120 | \ifdetailed 121 | \include {sres} 122 | \else 123 | \include {sresshort} 124 | \fi 125 | \include {smultin} 126 | \include {sentrop} 127 | \include {snpair} 128 | \include {sknuth} 129 | \include {smarsa} 130 | \include {svaria} 131 | \include {swalk} 132 | \include {scomp} 133 | \include {sspectral} 134 | \include {sstring} 135 | \include {sspacings} 136 | \include {scatter} 137 | 138 | \include {bintro} 139 | \include {bbattery} 140 | 141 | \include {fintro} 142 | \include {ffam} 143 | \include {fcong} 144 | \include {ffsr} 145 | \include {ftab} 146 | \ifdetailed 147 | \include {fres} 148 | \else 149 | \include {fresshort} 150 | \fi 151 | \include {fcho} 152 | 153 | \include {fmultin} 154 | % \include {fsentrop} 155 | \include {fnpair} 156 | \include {fknuth} 157 | \include {fmarsa} 158 | \include {fvaria} 159 | \include {fwalk} 160 | % \include {fcomp} 161 | \include {fspectral} 162 | \include {fstring} 163 | 164 | 165 | \bibliographystyle {plain} 166 | \addcontentsline{toc}{chapter}{BIBLIOGRAPHY} 167 | \bibliography{random,ift,simul,stat,prob,math} 168 | \clearpage 169 | \addcontentsline{toc}{chapter}{INDEX} 170 | \input{guidetestu01.ind} 171 | \end {document} 172 | -------------------------------------------------------------------------------- /mylib/util.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************\ 2 | * 3 | * Package: MyLib 4 | * File: util.c 5 | * Environment: ANSI C 6 | * 7 | * Copyright (c) 2002 Pierre L'Ecuyer, DIRO, Université de Montréal. 8 | * e-mail: lecuyer@iro.umontreal.ca 9 | * All rights reserved. 10 | * 11 | * This software is provided under the Apache 2 License. 12 | * 13 | * In scientific publications which used this software, a reference to it 14 | * would be appreciated. 15 | * 16 | \*************************************************************************/ 17 | 18 | #define _FILE_OFFSET_BITS 64 19 | 20 | #include "util.h" 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | 28 | #define MAXCAR 256 /* Max length of a line of data */ 29 | 30 | 31 | 32 | /************************************************************************/ 33 | 34 | FILE *util_Fopen (const char *path, const char *mode) 35 | { 36 | FILE *f; 37 | errno = 0; 38 | f = fopen (path, mode); 39 | if (f == NULL) { 40 | fprintf (stdout, "\nOpening of %s failed: %s\n\n", 41 | path, strerror (errno)); 42 | exit (EXIT_FAILURE); 43 | return NULL; /* to eliminate a warning from the compiler */ 44 | } else 45 | return f; 46 | } 47 | 48 | int util_Fclose (FILE * f) 49 | { 50 | int s; 51 | if (f == NULL) 52 | return 0; 53 | errno = 0; 54 | s = fclose (f); 55 | if (s != 0) 56 | fprintf (stdout, "\nClosing of file failed: %s\n\n", strerror (errno)); 57 | return s; 58 | } 59 | 60 | 61 | /************************************************************************/ 62 | 63 | void *util_Malloc (size_t size) 64 | { 65 | void *p; 66 | errno = 0; 67 | p = malloc (size); 68 | if (p == NULL) { 69 | fprintf (stdout, "\nmalloc failed: %s\n\n", strerror (errno)); 70 | exit (EXIT_FAILURE); 71 | return NULL; /* to eliminate a warning from the compiler */ 72 | } else 73 | return p; 74 | } 75 | 76 | void *util_Calloc (size_t count, size_t esize) 77 | { 78 | void *p; 79 | errno = 0; 80 | p = calloc (count, esize); 81 | if (p == NULL) { 82 | fprintf (stdout, "\ncalloc failed: %s\n\n", strerror (errno)); 83 | exit (EXIT_FAILURE); 84 | return NULL; /* to eliminate a warning from the compiler */ 85 | } else 86 | return p; 87 | } 88 | 89 | void *util_Realloc (void *ptr, size_t size) 90 | { 91 | void *p; 92 | errno = 0; 93 | p = realloc (ptr, size); 94 | if ((p == NULL) && (size != 0)) { 95 | fprintf (stdout, "\nrealloc failed: %s\n\n", strerror (errno)); 96 | exit (EXIT_FAILURE); 97 | return ptr; /* to eliminate a warning from the compiler */ 98 | } else 99 | return p; 100 | 101 | } 102 | 103 | void *util_Free (void *p) 104 | { 105 | if (p == NULL) 106 | return NULL; 107 | free (p); 108 | return NULL; 109 | } 110 | 111 | 112 | /************************************************************************/ 113 | 114 | void util_WriteBool (lebool b, int d) 115 | { 116 | if (b) 117 | printf ("%*s", d, "TRUE"); 118 | else 119 | printf ("%*s", d, "FALSE"); 120 | } 121 | 122 | 123 | void util_ReadBool (char S[], lebool *x) 124 | { 125 | int j; 126 | char B[6]; 127 | j = sscanf (S, " %6s", B); 128 | util_Assert (j > 0, "util_ReadBool: on reading lebool"); 129 | if (!strncmp (B, "TRUE", (size_t) 5)) 130 | *x = TRUE; 131 | else if (!strncmp (B, "FALSE", (size_t) 6)) 132 | *x = FALSE; 133 | else { 134 | util_Error ("util_ReadBool: lebool values must be TRUE or FALSE"); 135 | } 136 | } 137 | 138 | 139 | /************************************************************************/ 140 | 141 | int util_GetLine (FILE *infile, char *Line, char c) 142 | { 143 | size_t j; 144 | 145 | while (NULL != fgets (Line, MAXCAR, infile)) { /* Not EOF and no error */ 146 | /* Find first non-white character in Line */ 147 | j = strspn (Line, " \t\r\f\v"); 148 | /* Discard blank lines and lines whose first non-white character is c */ 149 | if (Line[j] == '\n' || Line[j] == c) 150 | continue; 151 | else { 152 | char *p; 153 | /* If the character c appears, delete the rest of the line*/ 154 | if ((p = strchr (Line, c))) 155 | *p = '\0'; 156 | 157 | else { 158 | /* Remove the \n char at the end of line */ 159 | j = strlen (Line); 160 | if (Line[j - 1] == '\n') 161 | Line[j - 1] = '\0'; 162 | } 163 | return 0; 164 | } 165 | } 166 | 167 | util_Fclose (infile); 168 | return -1; 169 | /* util_Error ("GetLine: an error has occurred on reading"); */ 170 | } 171 | -------------------------------------------------------------------------------- /mylib/bitset.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************\ 2 | * 3 | * Package: MyLib 4 | * File: bitset.c 5 | * Environment: ANSI C 6 | * 7 | * Copyright (c) 2002 Pierre L'Ecuyer, DIRO, Université de Montréal. 8 | * e-mail: lecuyer@iro.umontreal.ca 9 | * All rights reserved. 10 | * 11 | * This software is provided under the Apache 2 License. 12 | * 13 | * In scientific publications which used this software, a reference to it 14 | * would be appreciated. 15 | * 16 | \*************************************************************************/ 17 | 18 | 19 | #include "bitset.h" 20 | #include "util.h" 21 | #include 22 | #include 23 | #include 24 | 25 | 26 | unsigned long bitset_maskUL[] = { 27 | 1, 28 | 2, 29 | 4, 30 | 8, 31 | 16, 32 | 32, 33 | 64, 34 | 128, 35 | 256, 36 | 512, 37 | 1024, 38 | 2048, 39 | 4096, 40 | 8192, 41 | 16384, 42 | 32768, 43 | 65536, 44 | 131072, 45 | 262144, 46 | 524288, 47 | 1048576, 48 | 2097152, 49 | 4194304, 50 | 8388608, 51 | 16777216, 52 | 33554432, 53 | 67108864, 54 | 134217728, 55 | 268435456, 56 | 536870912, 57 | 1073741824, 58 | 2147483648UL 59 | #if ULONG_MAX > 4294967295UL 60 | , 61 | 4294967296, 62 | 8589934592, 63 | 17179869184, 64 | 34359738368, 65 | 68719476736, 66 | 137438953472, 67 | 274877906944, 68 | 549755813888, 69 | 1099511627776, 70 | 2199023255552, 71 | 4398046511104, 72 | 8796093022208, 73 | 17592186044416, 74 | 35184372088832, 75 | 70368744177664, 76 | 140737488355328, 77 | 281474976710656, 78 | 562949953421312, 79 | 1125899906842624, 80 | 2251799813685248, 81 | 4503599627370496, 82 | 9007199254740992, 83 | 18014398509481984, 84 | 36028797018963968, 85 | 72057594037927936, 86 | 144115188075855872, 87 | 288230376151711744, 88 | 576460752303423488, 89 | 1152921504606846976, 90 | 2305843009213693952, 91 | 4611686018427387904, 92 | 9223372036854775808UL 93 | #endif 94 | }; 95 | 96 | 97 | /*--------------------------------------------------------------------------*/ 98 | 99 | unsigned long bitset_MASK[] = { 100 | 0, 101 | 1, 102 | 3, 103 | 7, 104 | 15, 105 | 31, 106 | 63, 107 | 127, 108 | 255, 109 | 511, 110 | 1023, 111 | 2047, 112 | 4095, 113 | 8191, 114 | 16383, 115 | 32767, 116 | 65535, 117 | 131071, 118 | 262143, 119 | 524287, 120 | 1048575, 121 | 2097151, 122 | 4194303, 123 | 8388607, 124 | 16777215, 125 | 33554431, 126 | 67108863, 127 | 134217727, 128 | 268435455, 129 | 536870911, 130 | 1073741823, 131 | 2147483647, 132 | 4294967295UL 133 | #if ULONG_MAX > 4294967295UL 134 | , 135 | 8589934591, 136 | 17179869183, 137 | 34359738367, 138 | 68719476735, 139 | 137438953471, 140 | 274877906943, 141 | 549755813887, 142 | 1099511627775, 143 | 2199023255551, 144 | 4398046511103, 145 | 8796093022207, 146 | 17592186044415, 147 | 35184372088831, 148 | 70368744177663, 149 | 140737488355327, 150 | 281474976710655, 151 | 562949953421311, 152 | 1125899906842623, 153 | 2251799813685247, 154 | 4503599627370495, 155 | 9007199254740991, 156 | 18014398509481983, 157 | 36028797018963967, 158 | 72057594037927935, 159 | 144115188075855871, 160 | 288230376151711743, 161 | 576460752303423487, 162 | 1152921504606846975, 163 | 2305843009213693951, 164 | 4611686018427387903, 165 | 9223372036854775807, 166 | 18446744073709551615UL 167 | #endif 168 | }; 169 | 170 | /*--------------------------------------------------------------------------*/ 171 | 172 | 173 | void bitset_WriteSet (char *desc, bitset_BitSet S, int n) 174 | { 175 | int i; 176 | bitset_BitSet mask; 177 | 178 | util_Assert (n > 0, "bitset_WriteSet: s <= 0"); 179 | if ((unsigned) n > CHAR_BIT * sizeof (bitset_BitSet)) { 180 | n = CHAR_BIT * sizeof (bitset_BitSet); 181 | printf ("********** bitset_WriteSet: only %d bits in a BitSet\n\n", n); 182 | } 183 | if (desc != NULL && strlen (desc) > 0) 184 | printf ("%s", desc); 185 | mask = (bitset_BitSet) 1 << (n - 1); 186 | for (i = 0; i < n; i++) { 187 | if (S & mask) 188 | printf ("1"); 189 | else 190 | printf ("0"); 191 | mask >>= 1; 192 | } 193 | } 194 | 195 | 196 | /*--------------------------------------------------------------------------*/ 197 | 198 | bitset_BitSet bitset_Reverse (bitset_BitSet Z, int s) 199 | { 200 | unsigned long res = 0; 201 | int i; 202 | 203 | for (i = 0; i < s; i++) { 204 | res = (res << 1) | (Z & 1); 205 | Z >>= 1; 206 | } 207 | return res; 208 | } 209 | 210 | -------------------------------------------------------------------------------- /testu01/fnpair.tex: -------------------------------------------------------------------------------- 1 | \defmodule {fnpair} 2 | 3 | This module applies close-pairs tests from the module {\tt snpair} 4 | to a family of generators of different sizes. 5 | 6 | \bigskip 7 | \hrule 8 | \code\hide 9 | /* fnpair.h for ANSI C */ 10 | #ifndef FNPAIR_H 11 | #define FNPAIR_H 12 | \endhide 13 | #include "gdef.h" 14 | #include "ffam.h" 15 | #include "fres.h" 16 | #include "fcho.h" 17 | #include "snpair.h" 18 | 19 | 20 | extern long fnpair_Maxn; 21 | \endcode 22 | \tab 23 | Upper bound on $n$. 24 | When $n$ exceeds its limit value, the test is not done. 25 | Default value: $n = 2^{22}$. 26 | \endtab 27 | \ifdetailed %%%%%%%%%% 28 | 29 | 30 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 31 | \guisec{Structure for test results} 32 | 33 | The test results for the tests in this module can be recovered 34 | in the following structure. 35 | 36 | \code 37 | 38 | typedef struct { 39 | ftab_Table *PVal[snpair_StatType_N]; 40 | } fnpair_Res1; 41 | \endcode 42 | \tab 43 | Structure for keeping the tables of results of the tests in 44 | this module. Depending on the test, not all elements of the array 45 | will be meaningful; those elements that are not will be set to 46 | the NULL pointer. 47 | \endtab 48 | \code 49 | 50 | 51 | fnpair_Res1 * fnpair_CreateRes1 (void); 52 | \endcode 53 | \tab 54 | Creates and returns a structure that will hold the results 55 | of the tests in this module. 56 | \endtab 57 | \code 58 | 59 | 60 | void fnpair_DeleteRes1 (fnpair_Res1 *res); 61 | \endcode 62 | \tab 63 | Frees the memory allocated by {\tt fnpair\_CreateRes1}. 64 | \endtab 65 | 66 | \fi %%%%%%%%%%%%%%% 67 | 68 | 69 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 70 | \guisec{Choosing the parameter $\mathbf{m}$} 71 | 72 | One may choose to vary the parameter $m$ as a function of the sample size 73 | in the test {\tt fnpair\_ClosePairs1}. In that case, one must create 74 | an appropriate Choose function, pass it as a member of the argument {\tt 75 | cho} to the test, and call the test with a negative $m$ to signal that 76 | this is the case. If one wants to 77 | do the test with a fixed $m$, one has but to give the given $m> 0$ as a 78 | parameter to the test. 79 | 80 | \code 81 | 82 | 83 | fcho_Cho *fnpair_CreateM1 (int maxm); 84 | \endcode 85 | \tab 86 | Given the number of replications $N$ and the sample 87 | size $n$, the parameter $m$ in {\tt snpair\_Close\-Pairs} will be chosen 88 | by the relation 89 | $m = \min\left\{{\tt maxm},\sqrt{{n}/\left(4\sqrt{N}\right)}\right\}$. 90 | If this method 91 | of choosing $m$ is used, then the returned structure must be passed as 92 | the second pointer in the argument {\tt cho} of the test and the 93 | argument $m$ of the test {\tt fnpair\_ClosePairs1} must be negative. 94 | \endtab 95 | \code 96 | 97 | 98 | void fnpair_DeleteM1 (fcho_Cho * cho); 99 | \endcode 100 | \tab 101 | Frees the memory allocated by {\tt fnpair\_CreateM1}. 102 | \endtab 103 | 104 | 105 | 106 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 107 | \guisec{Applying the tests} 108 | 109 | \code 110 | 111 | 112 | void fnpair_ClosePairs1 (ffam_Fam *fam, fnpair_Res1 *res, fcho_Cho2 *cho, 113 | long N, int r, int t, int p, int m, 114 | int Nr, int j1, int j2, int jstep); 115 | \endcode 116 | \tab 117 | This function calls the test {\tt snpair\_ClosePairs} 118 | with parameters $N$ and $r$, in dimension $t$, with $L_p$ norm, 119 | sample size $n =$ {\tt cho->Chon->Choose(param, $i$, $j$)}, 120 | for the first {\tt Nr} generators of family {\tt fam}, for $j$ going from 121 | {\tt j1} to {\tt j2} by steps of {\tt jstep}. The parameters in {\tt param} 122 | were set at the creation of {\tt cho} and $i$ is the lsize of the 123 | generator being tested. If $m > 0$, it will be used as is in the test. 124 | If $m < 0$, it will be chosen by $m =$ 125 | {\tt cho->Chop2->Choose(param, $N$, $n$)}. 126 | When $n$ exceeds {\tt fnpair\_Maxn} or $n < 4m^2 N^{1/2}$, the test 127 | is not done. 128 | \endtab 129 | \code 130 | 131 | 132 | void fnpair_Bickel1 (ffam_Fam *fam, fnpair_Res1 *res, fcho_Cho *cho, 133 | long N, int r, int t, int p, lebool Torus, 134 | int Nr, int j1, int j2, int jstep); 135 | \endcode 136 | \tab 137 | Similar to {\tt fnpair\_ClosePairs1} but with {\tt snpair\_BickelBreiman}. 138 | There is no parameter $m$ in this test. 139 | \endtab 140 | \code 141 | 142 | 143 | void fnpair_BitMatch1 (ffam_Fam *fam, fnpair_Res1 *res, fcho_Cho *cho, 144 | long N, int r, int t, 145 | int Nr, int j1, int j2, int jstep); 146 | \endcode 147 | \tab 148 | Similar to {\tt fnpair\_Bickel1} but with 149 | {\tt snpair\_ClosePairsBitMatch}. 150 | \endtab 151 | \code 152 | \hide 153 | #endif 154 | \endhide 155 | \endcode 156 | 157 | -------------------------------------------------------------------------------- /mylib/mystr.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************\ 2 | * 3 | * Package: MyLib 4 | * File: mystr.c 5 | * Environment: ANSI C 6 | * 7 | * Copyright (c) 2002 Pierre L'Ecuyer, DIRO, Université de Montréal. 8 | * e-mail: lecuyer@iro.umontreal.ca 9 | * All rights reserved. 10 | * 11 | * This software is provided under the Apache 2 License. 12 | * 13 | * In scientific publications which used this software, a reference to it 14 | * would be appreciated. 15 | * 16 | \*************************************************************************/ 17 | 18 | #include "util.h" 19 | #include "mystr.h" 20 | #include 21 | #include 22 | #include 23 | 24 | 25 | void mystr_Delete (char S[], unsigned int index, unsigned int len) 26 | { 27 | int i; 28 | unsigned int length = strlen (S); 29 | if (index + len > length) 30 | S[index] = '\0'; 31 | else 32 | for (i = index; (unsigned int) i <= length - len; ++i) 33 | S[i] = S[i + len]; 34 | } 35 | 36 | 37 | void mystr_Insert (char Res[], char Source[], unsigned int Pos) 38 | { 39 | int i; 40 | unsigned int ResLength = strlen (Res); 41 | unsigned int SourceLength = strlen (Source); 42 | if (Pos > ResLength) 43 | util_Error ("mystr_Insert : Index out of array bound."); 44 | for (i = ResLength; (unsigned) i >= Pos; --i) { 45 | Res[i + SourceLength] = Res[i]; /* end of Res */ 46 | } 47 | for (i = Pos; (unsigned) i < Pos + SourceLength; ++i) 48 | Res[i] = Source[i - Pos]; /* adding Source to Res */ 49 | } 50 | 51 | 52 | void mystr_ItemS (char R[], char S[], const char T[], unsigned int N) 53 | { 54 | unsigned int i; 55 | char *temp; 56 | temp = strtok (S, T); /* first time */ 57 | for (i = 1; i <= N; ++i) { /* 2nd to Nth time */ 58 | if (temp == NULL) 59 | break; 60 | temp = strtok (NULL, T); 61 | } 62 | if (temp == NULL) { 63 | strncpy (R, "\0", (size_t) 1); 64 | return; 65 | } 66 | strcpy (R, temp); /* assignation */ 67 | } 68 | 69 | 70 | static int mystr_Rmatch (char s[], unsigned int i, char p[], unsigned int j) 71 | { 72 | int matched; 73 | unsigned int k; 74 | unsigned int s_len = strlen (s); 75 | unsigned int p_len = strlen (p); 76 | if (p[0] == 0) 77 | return 1; 78 | for (;;) { 79 | if ((i > s_len - 1 || s[i] == 0) && (j > p_len - 1 || p[j] == 0)) 80 | return 1; 81 | if (j > p_len - 1 || p[j] == 0) 82 | return 0; 83 | if (p[j] == '*') { 84 | k = i; 85 | if (j == p_len - 1 || p[j + 1] == 0) 86 | return 1; 87 | else { 88 | for (;;) { 89 | matched = mystr_Rmatch (s, k, p, j + 1); 90 | if ((matched || k > s_len - 1) || s[k] == 0) 91 | return matched; 92 | ++k; 93 | } 94 | } 95 | } 96 | if ((p[j] == '?' && s[i]) || (toupper (p[j]) == toupper (s[i]))) { 97 | ++i; 98 | ++j; 99 | } else 100 | return 0; 101 | } 102 | return 0; 103 | } 104 | 105 | 106 | int mystr_Match (char Source[], char Pattern[]) 107 | /* 108 | returns TRUE if the string in Source matches the string in Pattern 109 | The pattern may contain any number of the wild characters '*' and '?' 110 | '?' matches any single character 111 | '*' matches any sequence of charcters (including a zero length sequence) 112 | EG '*m?t*i*' will match 'Automatic' 113 | */ 114 | { 115 | return mystr_Rmatch (Source, 0, Pattern, 0); 116 | } 117 | 118 | 119 | void mystr_Slice (char R[], char S[], unsigned int P, unsigned int L) 120 | { 121 | unsigned int i; 122 | if (P + L > strlen (S)) 123 | util_Error ("*** ERROR : mystr_Slice Pattern longer then Source"); 124 | for (i = 0; i < L; i++) { 125 | R[i] = S[i + P]; 126 | } 127 | if (L <= strlen (R) - 1) 128 | R[L] = 0; 129 | } 130 | 131 | 132 | void mystr_Subst (char source[], char OldPattern[], char NewPattern[]) 133 | { 134 | unsigned int len; 135 | unsigned int index; 136 | char *PatternFound; 137 | PatternFound = strstr (source, OldPattern); 138 | if (PatternFound != NULL) { 139 | len = strlen (OldPattern); 140 | index = PatternFound - source; 141 | mystr_Delete (source, index, len); 142 | mystr_Insert (source, NewPattern, index); 143 | } 144 | } 145 | 146 | 147 | void mystr_Position (char Substring[], char Source[], unsigned int at, 148 | unsigned int *pos, int *found) 149 | { 150 | char *result = strstr (Source + at, Substring); 151 | if (at > strlen (Source)) 152 | util_Error ("mystr_Position : Index out of array bound."); 153 | if (result != NULL) { 154 | *pos = result - Source; 155 | *found = 1; 156 | } else 157 | *found = 0; 158 | } 159 | -------------------------------------------------------------------------------- /testu01/fvaria.tex: -------------------------------------------------------------------------------- 1 | \defmodule {fvaria} 2 | 3 | This module applies tests from the module {\tt svaria} 4 | to a family of generators of different sizes. 5 | 6 | \bigskip 7 | \hrule 8 | \code\hide 9 | /* fvaria.h for ANSI C */ 10 | #ifndef FVARIA_H 11 | #define FVARIA_H 12 | \endhide 13 | #include "ffam.h" 14 | #include "fres.h" 15 | #include "fcho.h" 16 | 17 | 18 | extern long fvaria_MaxN; 19 | extern long fvaria_Maxn; 20 | extern long fvaria_Maxk; 21 | extern long fvaria_MaxK; 22 | \endcode 23 | \tab 24 | Upper bounds on $N$, $n$, $k$ and $K$. 25 | When $N$, $n$, $k$ or $K$ exceed their limit value, the test is not done. 26 | Default values: $N = 2^{22}$, $n = 2^{22}$, $k = 2^{22}$ and $K = 2^{22}$. 27 | \endtab 28 | 29 | 30 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 31 | \guisec{The tests} 32 | \code 33 | 34 | void fvaria_SampleMean1 (ffam_Fam *fam, fres_Cont *res, fcho_Cho *cho, 35 | long n, int r, 36 | int Nr, int j1, int j2, int jstep); 37 | \endcode 38 | \tab This function calls the test {\tt svaria\_SampleMean} with parameters 39 | $N$, {\tt n} and {\tt r} for sample size $N$ chosen by the function 40 | {\tt cho->Choose(param, i, j)}, 41 | for the first {\tt Nr} generators of family {\tt fam}, for $j$ going from 42 | {\tt j1} to {\tt j2} by steps of {\tt jstep}. The parameters in {\tt param} 43 | were set at the creation of {\tt cho} and $i$ is the lsize of the 44 | generator being tested. 45 | When $N$ exceeds {\tt fvaria\_MaxN}, the test is not done. 46 | \endtab 47 | \code 48 | 49 | 50 | void fvaria_SampleCorr1 (ffam_Fam *fam, fres_Cont *res, fcho_Cho *cho, 51 | long N, int r, int k, 52 | int Nr, int j1, int j2, int jstep); 53 | \endcode 54 | \tab This function calls the test {\tt svaria\_SampleCorr} with parameters 55 | {\tt N}, $n$, {\tt r} and {\tt k} for sample size $n$ chosen by the function 56 | {\tt cho->Choose(param, i, j)}, 57 | for the first {\tt Nr} generators of family {\tt fam}, for $j$ going from 58 | {\tt j1} to {\tt j2} by steps of {\tt jstep}. The parameters in {\tt param} 59 | were set at the creation of {\tt cho} and $i$ is the lsize of the 60 | generator being tested. 61 | When $n$ exceeds {\tt fvaria\_Maxn}, the test is not done. 62 | \endtab 63 | \code 64 | 65 | 66 | void fvaria_SampleProd1 (ffam_Fam *fam, fres_Cont *res, fcho_Cho *cho, 67 | long N, int r, int t, 68 | int Nr, int j1, int j2, int jstep); 69 | \endcode 70 | \tab Similar to {\tt fvaria\_SampleCorr1} but with {\tt svaria\_SampleProd}. 71 | \endtab 72 | \code 73 | 74 | 75 | void fvaria_SumLogs1 (ffam_Fam *fam, fres_Cont *res, fcho_Cho *cho, 76 | long N, int r, 77 | int Nr, int j1, int j2, int jstep); 78 | \endcode 79 | \tab Similar to {\tt fvaria\_SampleCorr1} but with {\tt svaria\_SumLogs}. 80 | \endtab 81 | \code 82 | 83 | 84 | void fvaria_SumCollector1 (ffam_Fam *fam, fres_Cont *res, fcho_Cho *cho, 85 | long N, int r, double g, 86 | int Nr, int j1, int j2, int jstep); 87 | \endcode 88 | \tab Similar to {\tt fvaria\_SampleCorr1} but with {\tt svaria\_SumCollector}. 89 | \endtab 90 | \code 91 | 92 | 93 | void fvaria_Appearance1 (ffam_Fam *fam, fres_Cont *res, fcho_Cho *cho, 94 | long N, int r, int s, int L, 95 | int Nr, int j1, int j2, int jstep); 96 | \endcode 97 | \tab Similar to {\tt fvaria\_SampleCorr1} but with 98 | {\tt svaria\_AppearanceSpacings} and with $K$ as the varying sample size. 99 | \endtab 100 | \code 101 | 102 | 103 | void fvaria_WeightDistrib1 (ffam_Fam *fam, fres_Cont *res, fcho_Cho2 *cho, 104 | long N, long n, int r, long k, 105 | double alpha, double beta, 106 | int Nr, int j1, int j2, int jstep); 107 | \endcode 108 | \tab This function calls the test {\tt svaria\_WeightDistrib} with 109 | parameters {\tt N}, {\tt n}, {\tt r}, {\tt k}, {\tt alpha}, 110 | and {\tt beta} for the 111 | first {\tt Nr} generators of family {\tt fam}, for $j$ going from 112 | {\tt j1} to {\tt j2} by steps of {\tt jstep}. Either or both of {\tt n} 113 | and {\tt k} can be varied as the sample size, by passing a negative value as 114 | argument of the function. One must then create the corresponding function 115 | {\tt cho->Chon} or {\tt cho->Chop2} before calling the test. 116 | One will have either {\tt n} = {\tt cho->Chon->Choose(param, i, j)}, 117 | or {\tt k} = {\tt cho->Chop2->Choose(param, i, j)} or both. A positive 118 | value for {\tt n} or {\tt k} will be used as is by the test. When {\tt n} 119 | exceeds {\tt fvaria\_Maxn} or {\tt k} exceeds {\tt fvaria\_Maxk}, 120 | the test is not done. 121 | \endtab 122 | 123 | \code 124 | \hide 125 | #endif 126 | \endhide 127 | \endcode 128 | --------------------------------------------------------------------------------