texlive[52782] Build/source/texk/dvipdfm-x: install a pseudo random
commits+kakuto at tug.org
commits+kakuto at tug.org
Thu Nov 14 00:07:52 CET 2019
Revision: 52782
http://tug.org/svn/texlive?view=revision&revision=52782
Author: kakuto
Date: 2019-11-14 00:07:52 +0100 (Thu, 14 Nov 2019)
Log Message:
-----------
install a pseudo random number generator
Modified Paths:
--------------
trunk/Build/source/texk/dvipdfm-x/ChangeLog
trunk/Build/source/texk/dvipdfm-x/Makefile.am
trunk/Build/source/texk/dvipdfm-x/Makefile.in
trunk/Build/source/texk/dvipdfm-x/README
trunk/Build/source/texk/dvipdfm-x/configure
trunk/Build/source/texk/dvipdfm-x/configure.ac
trunk/Build/source/texk/dvipdfm-x/mem.h
Added Paths:
-----------
trunk/Build/source/texk/dvipdfm-x/mt19937ar.c
Modified: trunk/Build/source/texk/dvipdfm-x/ChangeLog
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/ChangeLog 2019-11-13 22:17:42 UTC (rev 52781)
+++ trunk/Build/source/texk/dvipdfm-x/ChangeLog 2019-11-13 23:07:52 UTC (rev 52782)
@@ -1,3 +1,16 @@
+2019-11-14 Akira Kakuto <kakuto at w32tex.org>
+
+ * mt19937ar.c: Add to support common font names in all
+ platforms when SOURCE_DATE_EPOCH is suitably set. A pseudo
+ random number generating program coded by Takuji Nishimura and
+ Makoto Matsumoto.
+ * README: Add a subject "11. Random number generating function".
+ * mem.h: Add "#define srand(x) init_genrand((x))", etc. because
+ it is the only common header file for dpxcrypt.c, pdfencrypt.c,
+ and pdffont.c, which use rand().
+ * Makefile.am: Add mt19937ar.c.
+ * configure.ac: Version 20191114.
+
2019-11-13 Akira Kakuto <kakuto at w32tex.org>
* spc_dvips.c: Add -dDELAYSAFER in GS_CALCULATOR because
Modified: trunk/Build/source/texk/dvipdfm-x/Makefile.am
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/Makefile.am 2019-11-13 22:17:42 UTC (rev 52781)
+++ trunk/Build/source/texk/dvipdfm-x/Makefile.am 2019-11-13 23:07:52 UTC (rev 52782)
@@ -69,6 +69,7 @@
mfileio.h \
mpost.c \
mpost.h \
+ mt19937ar.c \
numbers.c \
numbers.h \
otl_opt.c \
Modified: trunk/Build/source/texk/dvipdfm-x/Makefile.in
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/Makefile.in 2019-11-13 22:17:42 UTC (rev 52781)
+++ trunk/Build/source/texk/dvipdfm-x/Makefile.in 2019-11-13 23:07:52 UTC (rev 52782)
@@ -144,22 +144,22 @@
dvi.$(OBJEXT) dvipdfmx.$(OBJEXT) epdf.$(OBJEXT) \
error.$(OBJEXT) fontmap.$(OBJEXT) jp2image.$(OBJEXT) \
jpegimage.$(OBJEXT) mem.$(OBJEXT) mfileio.$(OBJEXT) \
- mpost.$(OBJEXT) numbers.$(OBJEXT) otl_opt.$(OBJEXT) \
- pdfcolor.$(OBJEXT) pdfdev.$(OBJEXT) pdfdoc.$(OBJEXT) \
- pdfdraw.$(OBJEXT) pdfencrypt.$(OBJEXT) pdfencoding.$(OBJEXT) \
- pdffont.$(OBJEXT) pdfnames.$(OBJEXT) pdfobj.$(OBJEXT) \
- pdfparse.$(OBJEXT) pdfresource.$(OBJEXT) pdfximage.$(OBJEXT) \
- pkfont.$(OBJEXT) pngimage.$(OBJEXT) pst.$(OBJEXT) \
- pst_obj.$(OBJEXT) sfnt.$(OBJEXT) spc_color.$(OBJEXT) \
- spc_dvipdfmx.$(OBJEXT) spc_dvips.$(OBJEXT) spc_html.$(OBJEXT) \
- spc_misc.$(OBJEXT) spc_pdfm.$(OBJEXT) spc_tpic.$(OBJEXT) \
- spc_util.$(OBJEXT) spc_xtx.$(OBJEXT) specials.$(OBJEXT) \
- subfont.$(OBJEXT) t1_char.$(OBJEXT) t1_load.$(OBJEXT) \
- tfm.$(OBJEXT) truetype.$(OBJEXT) tt_aux.$(OBJEXT) \
- tt_cmap.$(OBJEXT) tt_glyf.$(OBJEXT) tt_gsub.$(OBJEXT) \
- tt_post.$(OBJEXT) tt_table.$(OBJEXT) type0.$(OBJEXT) \
- type1.$(OBJEXT) type1c.$(OBJEXT) unicode.$(OBJEXT) \
- vf.$(OBJEXT) xbb.$(OBJEXT)
+ mpost.$(OBJEXT) mt19937ar.$(OBJEXT) numbers.$(OBJEXT) \
+ otl_opt.$(OBJEXT) pdfcolor.$(OBJEXT) pdfdev.$(OBJEXT) \
+ pdfdoc.$(OBJEXT) pdfdraw.$(OBJEXT) pdfencrypt.$(OBJEXT) \
+ pdfencoding.$(OBJEXT) pdffont.$(OBJEXT) pdfnames.$(OBJEXT) \
+ pdfobj.$(OBJEXT) pdfparse.$(OBJEXT) pdfresource.$(OBJEXT) \
+ pdfximage.$(OBJEXT) pkfont.$(OBJEXT) pngimage.$(OBJEXT) \
+ pst.$(OBJEXT) pst_obj.$(OBJEXT) sfnt.$(OBJEXT) \
+ spc_color.$(OBJEXT) spc_dvipdfmx.$(OBJEXT) spc_dvips.$(OBJEXT) \
+ spc_html.$(OBJEXT) spc_misc.$(OBJEXT) spc_pdfm.$(OBJEXT) \
+ spc_tpic.$(OBJEXT) spc_util.$(OBJEXT) spc_xtx.$(OBJEXT) \
+ specials.$(OBJEXT) subfont.$(OBJEXT) t1_char.$(OBJEXT) \
+ t1_load.$(OBJEXT) tfm.$(OBJEXT) truetype.$(OBJEXT) \
+ tt_aux.$(OBJEXT) tt_cmap.$(OBJEXT) tt_glyf.$(OBJEXT) \
+ tt_gsub.$(OBJEXT) tt_post.$(OBJEXT) tt_table.$(OBJEXT) \
+ type0.$(OBJEXT) type1.$(OBJEXT) type1c.$(OBJEXT) \
+ unicode.$(OBJEXT) vf.$(OBJEXT) xbb.$(OBJEXT)
xdvipdfmx_OBJECTS = $(am_xdvipdfmx_OBJECTS)
xdvipdfmx_LDADD = $(LDADD)
xdvipdfmx_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
@@ -220,15 +220,16 @@
./$(DEPDIR)/error.Po ./$(DEPDIR)/fontmap.Po \
./$(DEPDIR)/jp2image.Po ./$(DEPDIR)/jpegimage.Po \
./$(DEPDIR)/mem.Po ./$(DEPDIR)/mfileio.Po ./$(DEPDIR)/mpost.Po \
- ./$(DEPDIR)/numbers.Po ./$(DEPDIR)/otl_opt.Po \
- ./$(DEPDIR)/pdfcolor.Po ./$(DEPDIR)/pdfdev.Po \
- ./$(DEPDIR)/pdfdoc.Po ./$(DEPDIR)/pdfdraw.Po \
- ./$(DEPDIR)/pdfencoding.Po ./$(DEPDIR)/pdfencrypt.Po \
- ./$(DEPDIR)/pdffont.Po ./$(DEPDIR)/pdfnames.Po \
- ./$(DEPDIR)/pdfobj.Po ./$(DEPDIR)/pdfparse.Po \
- ./$(DEPDIR)/pdfresource.Po ./$(DEPDIR)/pdfximage.Po \
- ./$(DEPDIR)/pkfont.Po ./$(DEPDIR)/pngimage.Po \
- ./$(DEPDIR)/pst.Po ./$(DEPDIR)/pst_obj.Po ./$(DEPDIR)/sfnt.Po \
+ ./$(DEPDIR)/mt19937ar.Po ./$(DEPDIR)/numbers.Po \
+ ./$(DEPDIR)/otl_opt.Po ./$(DEPDIR)/pdfcolor.Po \
+ ./$(DEPDIR)/pdfdev.Po ./$(DEPDIR)/pdfdoc.Po \
+ ./$(DEPDIR)/pdfdraw.Po ./$(DEPDIR)/pdfencoding.Po \
+ ./$(DEPDIR)/pdfencrypt.Po ./$(DEPDIR)/pdffont.Po \
+ ./$(DEPDIR)/pdfnames.Po ./$(DEPDIR)/pdfobj.Po \
+ ./$(DEPDIR)/pdfparse.Po ./$(DEPDIR)/pdfresource.Po \
+ ./$(DEPDIR)/pdfximage.Po ./$(DEPDIR)/pkfont.Po \
+ ./$(DEPDIR)/pngimage.Po ./$(DEPDIR)/pst.Po \
+ ./$(DEPDIR)/pst_obj.Po ./$(DEPDIR)/sfnt.Po \
./$(DEPDIR)/spc_color.Po ./$(DEPDIR)/spc_dvipdfmx.Po \
./$(DEPDIR)/spc_dvips.Po ./$(DEPDIR)/spc_html.Po \
./$(DEPDIR)/spc_misc.Po ./$(DEPDIR)/spc_pdfm.Po \
@@ -696,6 +697,7 @@
mfileio.h \
mpost.c \
mpost.h \
+ mt19937ar.c \
numbers.c \
numbers.h \
otl_opt.c \
@@ -1024,6 +1026,7 @@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/mem.Po at am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/mfileio.Po at am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/mpost.Po at am__quote@ # am--include-marker
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/mt19937ar.Po at am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/numbers.Po at am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/otl_opt.Po at am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pdfcolor.Po at am__quote@ # am--include-marker
@@ -1706,6 +1709,7 @@
-rm -f ./$(DEPDIR)/mem.Po
-rm -f ./$(DEPDIR)/mfileio.Po
-rm -f ./$(DEPDIR)/mpost.Po
+ -rm -f ./$(DEPDIR)/mt19937ar.Po
-rm -f ./$(DEPDIR)/numbers.Po
-rm -f ./$(DEPDIR)/otl_opt.Po
-rm -f ./$(DEPDIR)/pdfcolor.Po
@@ -1829,6 +1833,7 @@
-rm -f ./$(DEPDIR)/mem.Po
-rm -f ./$(DEPDIR)/mfileio.Po
-rm -f ./$(DEPDIR)/mpost.Po
+ -rm -f ./$(DEPDIR)/mt19937ar.Po
-rm -f ./$(DEPDIR)/numbers.Po
-rm -f ./$(DEPDIR)/otl_opt.Po
-rm -f ./$(DEPDIR)/pdfcolor.Po
Modified: trunk/Build/source/texk/dvipdfm-x/README
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/README 2019-11-13 22:17:42 UTC (rev 52781)
+++ trunk/Build/source/texk/dvipdfm-x/README 2019-11-13 23:07:52 UTC (rev 52782)
@@ -504,3 +504,53 @@
embedding from Japan Typography Association (in Japanese):
http://www.typography.or.jp/act/morals/moral4.html
+
+11. Random number generating function
+
+ Prefixes of font names are calculated by using a function which
+ generates pseudo random numbers. In order to obtain a unique
+ prefix on all platforms when current time is common, a special
+ function MT19937, coded by Takuji Nishimura and Makoto Matsumoto,
+ is used. The header of the C program by Takuji Nishimura and
+ Makoto Matsumoto is the following:
+
+ A C-program for MT19937, with initialization improved 2002/1/26.
+ Coded by Takuji Nishimura and Makoto Matsumoto.
+
+ Before using, initialize the state by using init_genrand(seed)
+ or init_by_array(init_key, key_length).
+
+ Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ 3. The names of its contributors may not be used to endorse or promote
+ products derived from this software without specific prior written
+ permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+ Any feedback is very welcome.
+ http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
+ email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space)
Modified: trunk/Build/source/texk/dvipdfm-x/configure
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/configure 2019-11-13 22:17:42 UTC (rev 52781)
+++ trunk/Build/source/texk/dvipdfm-x/configure 2019-11-13 23:07:52 UTC (rev 52782)
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for dvipdfm-x (TeX Live) 20190824.
+# Generated by GNU Autoconf 2.69 for dvipdfm-x (TeX Live) 20191114.
#
# Report bugs to <dvipdfmx at tug.org>.
#
@@ -590,8 +590,8 @@
# Identity of this package.
PACKAGE_NAME='dvipdfm-x (TeX Live)'
PACKAGE_TARNAME='dvipdfm-x--tex-live-'
-PACKAGE_VERSION='20190824'
-PACKAGE_STRING='dvipdfm-x (TeX Live) 20190824'
+PACKAGE_VERSION='20191114'
+PACKAGE_STRING='dvipdfm-x (TeX Live) 20191114'
PACKAGE_BUGREPORT='dvipdfmx at tug.org'
PACKAGE_URL=''
@@ -1350,7 +1350,7 @@
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures dvipdfm-x (TeX Live) 20190824 to adapt to many kinds of systems.
+\`configure' configures dvipdfm-x (TeX Live) 20191114 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1421,7 +1421,7 @@
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of dvipdfm-x (TeX Live) 20190824:";;
+ short | recursive ) echo "Configuration of dvipdfm-x (TeX Live) 20191114:";;
esac
cat <<\_ACEOF
@@ -1551,7 +1551,7 @@
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-dvipdfm-x (TeX Live) configure 20190824
+dvipdfm-x (TeX Live) configure 20191114
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2390,7 +2390,7 @@
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by dvipdfm-x (TeX Live) $as_me 20190824, which was
+It was created by dvipdfm-x (TeX Live) $as_me 20191114, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -8077,7 +8077,7 @@
# Define the identity of the package.
PACKAGE='dvipdfm-x--tex-live-'
- VERSION='20190824'
+ VERSION='20191114'
cat >>confdefs.h <<_ACEOF
@@ -14746,7 +14746,7 @@
Report bugs to <bug-libtool at gnu.org>."
lt_cl_version="\
-dvipdfm-x (TeX Live) config.lt 20190824
+dvipdfm-x (TeX Live) config.lt 20191114
configured by $0, generated by GNU Autoconf 2.69.
Copyright (C) 2011 Free Software Foundation, Inc.
@@ -16636,7 +16636,7 @@
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by dvipdfm-x (TeX Live) $as_me 20190824, which was
+This file was extended by dvipdfm-x (TeX Live) $as_me 20191114, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -16706,7 +16706,7 @@
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-dvipdfm-x (TeX Live) config.status 20190824
+dvipdfm-x (TeX Live) config.status 20191114
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
Modified: trunk/Build/source/texk/dvipdfm-x/configure.ac
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/configure.ac 2019-11-13 22:17:42 UTC (rev 52781)
+++ trunk/Build/source/texk/dvipdfm-x/configure.ac 2019-11-13 23:07:52 UTC (rev 52782)
@@ -7,7 +7,7 @@
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl
-AC_INIT([dvipdfm-x (TeX Live)], [20190824], [dvipdfmx at tug.org])
+AC_INIT([dvipdfm-x (TeX Live)], [20191114], [dvipdfmx at tug.org])
AC_PREREQ([2.65])
AC_CONFIG_SRCDIR([agl.c])
AC_CONFIG_AUX_DIR([../../build-aux])
Modified: trunk/Build/source/texk/dvipdfm-x/mem.h
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/mem.h 2019-11-13 22:17:42 UTC (rev 52781)
+++ trunk/Build/source/texk/dvipdfm-x/mem.h 2019-11-13 23:07:52 UTC (rev 52782)
@@ -38,4 +38,13 @@
#define RENEW(p,n,type) (type *) renew(p,((uint32_t)(n))*sizeof(type))
#define RELEASE(p) free(p)
+/*
+ * mem.h is not suitable for the following, but it is the only common
+ * header file for dpxcrypt.c, pdfencrypt.c, and pdffont.c, which use
+ * the function rand().
+ */
+extern void init_genrand(unsigned long long s);
+extern long genrand_int31(void);
+#define srand(x) init_genrand((x))
+#define rand() genrand_int31()
#endif /* _MEM_H_ */
Added: trunk/Build/source/texk/dvipdfm-x/mt19937ar.c
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/mt19937ar.c (rev 0)
+++ trunk/Build/source/texk/dvipdfm-x/mt19937ar.c 2019-11-13 23:07:52 UTC (rev 52782)
@@ -0,0 +1,192 @@
+/*
+ A C-program for MT19937, with initialization improved 2002/1/26.
+ Coded by Takuji Nishimura and Makoto Matsumoto.
+
+ Before using, initialize the state by using init_genrand(seed)
+ or init_by_array(init_key, key_length).
+
+ Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ 3. The names of its contributors may not be used to endorse or promote
+ products derived from this software without specific prior written
+ permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+ Any feedback is very welcome.
+ http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
+ email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space)
+*/
+
+#include <stdio.h>
+
+/* Period parameters */
+#define N 624
+#define M 397
+#define MATRIX_A 0x9908b0dfUL /* constant vector a */
+#define UPPER_MASK 0x80000000UL /* most significant w-r bits */
+#define LOWER_MASK 0x7fffffffUL /* least significant r bits */
+
+static unsigned long mt[N]; /* the array for the state vector */
+static int mti=N+1; /* mti==N+1 means mt[N] is not initialized */
+
+/* initializes mt[N] with a seed */
+/* void init_genrand(unsigned long s) */
+void init_genrand(unsigned long long s)
+{
+ mt[0]= s & 0xffffffffUL;
+ for (mti=1; mti<N; mti++) {
+ mt[mti] =
+ (1812433253UL * (mt[mti-1] ^ (mt[mti-1] >> 30)) + mti);
+ /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */
+ /* In the previous versions, MSBs of the seed affect */
+ /* only MSBs of the array mt[]. */
+ /* 2002/01/09 modified by Makoto Matsumoto */
+ mt[mti] &= 0xffffffffUL;
+ /* for >32 bit machines */
+ }
+}
+
+/* initialize by an array with array-length */
+/* init_key is the array for initializing keys */
+/* key_length is its length */
+/* slight change for C++, 2004/2/26 */
+void init_by_array(unsigned long init_key[], int key_length)
+{
+ int i, j, k;
+ init_genrand(19650218UL);
+ i=1; j=0;
+ k = (N>key_length ? N : key_length);
+ for (; k; k--) {
+ mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1664525UL))
+ + init_key[j] + j; /* non linear */
+ mt[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */
+ i++; j++;
+ if (i>=N) { mt[0] = mt[N-1]; i=1; }
+ if (j>=key_length) j=0;
+ }
+ for (k=N-1; k; k--) {
+ mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1566083941UL))
+ - i; /* non linear */
+ mt[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */
+ i++;
+ if (i>=N) { mt[0] = mt[N-1]; i=1; }
+ }
+
+ mt[0] = 0x80000000UL; /* MSB is 1; assuring non-zero initial array */
+}
+
+/* generates a random number on [0,0xffffffff]-interval */
+unsigned long genrand_int32(void)
+{
+ unsigned long y;
+ static unsigned long mag01[2]={0x0UL, MATRIX_A};
+ /* mag01[x] = x * MATRIX_A for x=0,1 */
+
+ if (mti >= N) { /* generate N words at one time */
+ int kk;
+
+ if (mti == N+1) /* if init_genrand() has not been called, */
+ init_genrand(5489UL); /* a default initial seed is used */
+
+ for (kk=0;kk<N-M;kk++) {
+ y = (mt[kk]&UPPER_MASK)|(mt[kk+1]&LOWER_MASK);
+ mt[kk] = mt[kk+M] ^ (y >> 1) ^ mag01[y & 0x1UL];
+ }
+ for (;kk<N-1;kk++) {
+ y = (mt[kk]&UPPER_MASK)|(mt[kk+1]&LOWER_MASK);
+ mt[kk] = mt[kk+(M-N)] ^ (y >> 1) ^ mag01[y & 0x1UL];
+ }
+ y = (mt[N-1]&UPPER_MASK)|(mt[0]&LOWER_MASK);
+ mt[N-1] = mt[M-1] ^ (y >> 1) ^ mag01[y & 0x1UL];
+
+ mti = 0;
+ }
+
+ y = mt[mti++];
+
+ /* Tempering */
+ y ^= (y >> 11);
+ y ^= (y << 7) & 0x9d2c5680UL;
+ y ^= (y << 15) & 0xefc60000UL;
+ y ^= (y >> 18);
+
+ return y;
+}
+
+/* generates a random number on [0,0x7fffffff]-interval */
+long genrand_int31(void)
+{
+ return (long)(genrand_int32()>>1);
+}
+
+/* generates a random number on [0,1]-real-interval */
+double genrand_real1(void)
+{
+ return genrand_int32()*(1.0/4294967295.0);
+ /* divided by 2^32-1 */
+}
+
+/* generates a random number on [0,1)-real-interval */
+double genrand_real2(void)
+{
+ return genrand_int32()*(1.0/4294967296.0);
+ /* divided by 2^32 */
+}
+
+/* generates a random number on (0,1)-real-interval */
+double genrand_real3(void)
+{
+ return (((double)genrand_int32()) + 0.5)*(1.0/4294967296.0);
+ /* divided by 2^32 */
+}
+
+/* generates a random number on [0,1) with 53-bit resolution*/
+double genrand_res53(void)
+{
+ unsigned long a=genrand_int32()>>5, b=genrand_int32()>>6;
+ return(a*67108864.0+b)*(1.0/9007199254740992.0);
+}
+/* These real versions are due to Isaku Wada, 2002/01/09 added */
+#ifdef TEST
+int main(void)
+{
+ int i;
+ unsigned long init[4]={0x123, 0x234, 0x345, 0x456}, length=4;
+ init_by_array(init, length);
+ printf("1000 outputs of genrand_int32()\n");
+ for (i=0; i<1000; i++) {
+ printf("%10lu ", genrand_int32());
+ if (i%5==4) printf("\n");
+ }
+ printf("\n1000 outputs of genrand_real2()\n");
+ for (i=0; i<1000; i++) {
+ printf("%10.8f ", genrand_real2());
+ if (i%5==4) printf("\n");
+ }
+ return 0;
+}
+#endif
Property changes on: trunk/Build/source/texk/dvipdfm-x/mt19937ar.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+LF
\ No newline at end of property
More information about the tex-live-commits
mailing list