r34795 - in /branches/upstream/libmath-random-tt800-perl: ./ current/

jawnsy-guest at users.alioth.debian.org jawnsy-guest at users.alioth.debian.org
Tue May 5 15:42:19 UTC 2009


Author: jawnsy-guest
Date: Tue May  5 15:42:13 2009
New Revision: 34795

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=34795
Log:
[svn-inject] Installing original source of libmath-random-tt800-perl

Added:
    branches/upstream/libmath-random-tt800-perl/
    branches/upstream/libmath-random-tt800-perl/current/
    branches/upstream/libmath-random-tt800-perl/current/COPYRIGHT
    branches/upstream/libmath-random-tt800-perl/current/Changes
    branches/upstream/libmath-random-tt800-perl/current/MANIFEST
    branches/upstream/libmath-random-tt800-perl/current/Makefile.PL
    branches/upstream/libmath-random-tt800-perl/current/README
    branches/upstream/libmath-random-tt800-perl/current/TT800.pm
    branches/upstream/libmath-random-tt800-perl/current/TT800.xs
    branches/upstream/libmath-random-tt800-perl/current/test.pl
    branches/upstream/libmath-random-tt800-perl/current/tt800.h
    branches/upstream/libmath-random-tt800-perl/current/tt800_core.c
    branches/upstream/libmath-random-tt800-perl/current/typemap

Added: branches/upstream/libmath-random-tt800-perl/current/COPYRIGHT
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmath-random-tt800-perl/current/COPYRIGHT?rev=34795&op=file
==============================================================================
--- branches/upstream/libmath-random-tt800-perl/current/COPYRIGHT (added)
+++ branches/upstream/libmath-random-tt800-perl/current/COPYRIGHT Tue May  5 15:42:13 2009
@@ -1,0 +1,11 @@
+
+Orginal C implementation of the tt800 was published by M. Matsumoto
+<matumoto at math.keio.ac.jp>. 
+
+This Perl extension was written by Otmar Lendl (lendl at cosy.sbg.ac.at)
+for the Perl Journal.
+
+Copyright (c) 1997 by Otmar Lendl (Perl and XS code). All rights
+reserved. This program is free software; you can redistribute it and/or
+modify it under the same terms as Perl itself.
+

Added: branches/upstream/libmath-random-tt800-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmath-random-tt800-perl/current/Changes?rev=34795&op=file
==============================================================================
--- branches/upstream/libmath-random-tt800-perl/current/Changes (added)
+++ branches/upstream/libmath-random-tt800-perl/current/Changes Tue May  5 15:42:13 2009
@@ -1,0 +1,12 @@
+Revision history for Perl extension Math::(Random)::TT800.
+
+0.01  Sun Mar 30 11:26:24 1997
+	- original version; created by h2xs 1.16
+
+1.00  Sun Mar 30 17:02:50 MET DST 1997
+	- finished version.
+
+1.01  Wed Oct 23 17:36:34 CEST 2002
+	- renamed to Math::Random::TT800
+	- removed TT800.c vs. tt800.c clash
+	- initial CPAN upload

Added: branches/upstream/libmath-random-tt800-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmath-random-tt800-perl/current/MANIFEST?rev=34795&op=file
==============================================================================
--- branches/upstream/libmath-random-tt800-perl/current/MANIFEST (added)
+++ branches/upstream/libmath-random-tt800-perl/current/MANIFEST Tue May  5 15:42:13 2009
@@ -1,0 +1,12 @@
+Changes
+MANIFEST
+COPYRIGHT
+README
+Makefile.PL
+TT800.pm
+TT800.xs
+test.pl
+typemap
+tt800_core.c
+tt800.h
+

Added: branches/upstream/libmath-random-tt800-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmath-random-tt800-perl/current/Makefile.PL?rev=34795&op=file
==============================================================================
--- branches/upstream/libmath-random-tt800-perl/current/Makefile.PL (added)
+++ branches/upstream/libmath-random-tt800-perl/current/Makefile.PL Tue May  5 15:42:13 2009
@@ -1,0 +1,12 @@
+use ExtUtils::MakeMaker;
+# See lib/ExtUtils/MakeMaker.pm for details of how to influence
+# the contents of the Makefile that is written.
+WriteMakefile(
+    'NAME'	=> 'Math::Random::TT800',
+    'DISTNAME' => 'Math-Random-TT800',
+    'VERSION_FROM' => 'TT800.pm', # finds $VERSION
+    'OBJECT'	=> 'TT800.o tt800_core.o',
+    'LIBS'	=> [''],   # e.g., '-lm' 
+    'DEFINE'	=> '',     # e.g., '-DHAVE_SOMETHING' 
+    'INC'	=> '',     # e.g., '-I/usr/include/other' 
+);

Added: branches/upstream/libmath-random-tt800-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmath-random-tt800-perl/current/README?rev=34795&op=file
==============================================================================
--- branches/upstream/libmath-random-tt800-perl/current/README (added)
+++ branches/upstream/libmath-random-tt800-perl/current/README Tue May  5 15:42:13 2009
@@ -1,0 +1,19 @@
+
+This perl extension module implements M. Matsumoto's twisted generalized
+shift register generator called TT800 as described in his article
+published in ACM Transactions on Modelling and Computer Simulation, 
+Vol. 4, No. 3, 1994, pages 254-266. 
+
+This implementation is based on the C code by M. Matsumoto
+<matumoto at math.keio.ac.jp> available from 
+ftp://random.mat.sbg.ac.at/pub/data/tt800.c.
+
+Converted to a perl extension module and enhancements to 
+support multiple streams of pseudorandom numbers 
+by Otmar Lendl <lendl at cosy.sbg.ac.at>.
+
+Copyright (c) 1997 by Otmar Lendl (Perl and XS code). All rights
+reserved. This program is free software; you can redistribute it and/or
+modify it under the same terms as Perl itself.
+
+

Added: branches/upstream/libmath-random-tt800-perl/current/TT800.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmath-random-tt800-perl/current/TT800.pm?rev=34795&op=file
==============================================================================
--- branches/upstream/libmath-random-tt800-perl/current/TT800.pm (added)
+++ branches/upstream/libmath-random-tt800-perl/current/TT800.pm Tue May  5 15:42:13 2009
@@ -1,0 +1,89 @@
+package Math::Random::TT800;
+
+use strict;
+use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
+
+require Exporter;
+require DynaLoader;
+
+ at ISA = qw(Exporter DynaLoader);
+
+ at EXPORT = qw();
+ at EXPORT_OK = qw();
+
+$VERSION = '1.01';
+
+bootstrap Math::Random::TT800 $VERSION;
+
+1;
+
+__END__
+
+
+=head1 NAME
+
+Math::Random::TT800 - Matsumoto's TT800 Pseudorandom number generator
+
+=head1 DESCRIPTION
+
+This perl extension module implements M. Matsumoto's twisted generalized
+shift register generator called TT800 as described in his article
+published in ACM Transactions on Modelling and Computer Simulation, 
+Vol. 4, No. 3, 1994, pages 254-266. 
+
+=head1 SYNOPSIS
+
+	use Math::Random::TT800;
+
+	my $tt = new Math::Random::TT800;
+
+	$value = $tt->next();
+
+	$ivalue = $tt->next_int();
+	
+
+=head1 FUNCTIONS
+
+=over 4
+
+=item new
+
+        my $tt = new Math::Random::TT800;
+        my $tt = new Math::Random::TT800 @seeds;
+
+Create a new TT800 object. Providing seeds is optional.
+A TT800 takes 25 integers as seed which must not be all zero.
+If less than 25 integers are supplied, the rest are taken from the
+default seed.
+
+
+=item next
+
+	$value = $tt->next();
+
+next returns the next pseudorandom number from the TT800 object as
+a floating point value in the range [0,1).
+
+=item next_int
+
+	$ivalue = $tt->next_int();
+
+next_int returns a integer value filled with 32 random bits.
+
+=back
+
+=head1 COPYRIGHT
+
+This implementation is based on the C code by M. Matsumoto
+<matumoto at math.keio.ac.jp> available from 
+ftp://random.mat.sbg.ac.at/pub/data/tt800.c.
+
+Converted to a perl extension module and enhancements to 
+support multiple streams of pseudorandom numbers 
+by Otmar Lendl <lendl at cosy.sbg.ac.at>.
+
+Copyright (c) 1997 by Otmar Lendl (Perl and XS code). All rights
+reserved. This program is free software; you can redistribute it and/or
+modify it under the same terms as Perl itself.
+
+=cut

Added: branches/upstream/libmath-random-tt800-perl/current/TT800.xs
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmath-random-tt800-perl/current/TT800.xs?rev=34795&op=file
==============================================================================
--- branches/upstream/libmath-random-tt800-perl/current/TT800.xs (added)
+++ branches/upstream/libmath-random-tt800-perl/current/TT800.xs Tue May  5 15:42:13 2009
@@ -1,0 +1,59 @@
+#ifdef __cplusplus
+extern "C" {
+#endif
+#include "EXTERN.h"
+#include "perl.h"
+#include "XSUB.h"
+#include <string.h>
+#ifdef __cplusplus
+}
+#endif
+
+#include "tt800.h"
+
+MODULE = Math::Random::TT800		PACKAGE = Math::Random::TT800
+
+TT800
+new(class = "Math::Random::TT800", ...)
+		char *		class
+	CODE:
+		{
+		int i;
+
+		RETVAL = (TT800) safemalloc(sizeof(struct tt800_state));
+		memcpy(RETVAL,(char * ) &tt800_initial_state,
+			sizeof(struct tt800_state));
+
+		if ( items > (TT800_N + 1))
+			items = TT800_N + 1;
+		for (i = 1; i < items; i++)
+			RETVAL->x[i-1] = (U32) SvIV(ST(i));
+		}
+	OUTPUT:
+		RETVAL
+
+
+void
+DESTROY(tt)
+		TT800	tt
+	CODE:
+		safefree((char *) tt);
+
+
+U32
+next_int(tt)
+		TT800 tt
+	CODE:
+		RETVAL = tt800_get_next_int(tt);
+	OUTPUT:
+		RETVAL
+
+
+double
+next(tt)
+		TT800 tt
+	CODE:
+		RETVAL = tt800_get_next_int(tt) * TT800_INV_MOD;
+	OUTPUT:
+		RETVAL
+

Added: branches/upstream/libmath-random-tt800-perl/current/test.pl
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmath-random-tt800-perl/current/test.pl?rev=34795&op=file
==============================================================================
--- branches/upstream/libmath-random-tt800-perl/current/test.pl (added)
+++ branches/upstream/libmath-random-tt800-perl/current/test.pl Tue May  5 15:42:13 2009
@@ -1,0 +1,58 @@
+# Before `make install' is performed this script should be runnable with
+# `make test'. After `make install' it should work as `perl test.pl'
+
+######################### We start with some black magic to print on failure.
+
+# Change 1..1 below to 1..last_test_to_print .
+# (It may become useful if the test is moved to ./t subdirectory.)
+
+BEGIN { $| = 1; print "1..9\n"; }
+END {print "not ok 1\n" unless $loaded;}
+use Math::Random::TT800;
+$loaded = 1;
+print "ok 1\n";
+
+######################### End of black magic.
+
+# Insert your test code below (better if it prints "ok 13"
+# (correspondingly "not ok 13") depending on the success of chunk 13
+# of the test code):
+
+#
+#  Testing with default seed
+#
+$tt = new Math::Random::TT800;
+
+(sprintf("%u",$tt->next_int()) eq "3169973338") or print "not ";
+print "ok 2\n";
+
+(abs($tt->next() - 0.63445952502881) < 0.0000001 ) or print "not ";
+print "ok 3\n";
+
+for (1..100) { $tt->next_int(); }
+
+(sprintf("%u",$tt->next_int()) eq "3491672134") or print "not ";
+print "ok 4\n";
+
+(abs($tt->next() - 0.25527860719135) < 0.0000001 ) or print "not ";
+print "ok 5\n";
+
+#
+#  Testing with custom seed
+#
+$tt = new Math::Random::TT800 42,1,8,1,4,131,91231,9173123;
+
+(sprintf("%u",$tt->next_int()) eq "42010539") or print "not ";
+print "ok 6\n";
+
+(abs($tt->next() - 2.3283064370808e-10) < 0.0000001 ) or print "not ";
+print "ok 7\n";
+
+for (1..100) { $tt->next_int(); }
+
+(sprintf("%u",$tt->next_int()) eq "2788880872") or print "not ";
+print "ok 8\n";
+
+(abs($tt->next() - 0.625562964851401) < 0.0000001 ) or print "not ";
+print "ok 9\n";
+

Added: branches/upstream/libmath-random-tt800-perl/current/tt800.h
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmath-random-tt800-perl/current/tt800.h?rev=34795&op=file
==============================================================================
--- branches/upstream/libmath-random-tt800-perl/current/tt800.h (added)
+++ branches/upstream/libmath-random-tt800-perl/current/tt800.h Tue May  5 15:42:13 2009
@@ -1,0 +1,15 @@
+
+#define TT800_N 25
+#define TT800_M 7
+#define TT800_INV_MOD 2.3283064370807974e-10            /* 1.0 / (2^32-1) */
+
+struct tt800_state
+        {
+	U32		x[TT800_N];		/* make use of the perl type */
+	int             k;
+	};
+
+typedef struct tt800_state *TT800;
+
+extern struct tt800_state tt800_initial_state;
+U32 tt800_get_next_int(TT800 g);

Added: branches/upstream/libmath-random-tt800-perl/current/tt800_core.c
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmath-random-tt800-perl/current/tt800_core.c?rev=34795&op=file
==============================================================================
--- branches/upstream/libmath-random-tt800-perl/current/tt800_core.c (added)
+++ branches/upstream/libmath-random-tt800-perl/current/tt800_core.c Tue May  5 15:42:13 2009
@@ -1,0 +1,78 @@
+/* A C-program for TT800 : July 8th 1996 Version */
+/* by M. Matsumoto, email: matumoto at math.keio.ac.jp */
+/* genrand() generate one pseudorandom number with double precision */
+/* which is uniformly distributed on [0,1]-interval */
+/* for each call.  One may choose any initial 25 seeds */
+/* except all zeros. */
+
+/* See: ACM Transactions on Modelling and Computer Simulation, */
+/* Vol. 4, No. 3, 1994, pages 254-266. */
+
+/* we need 32 bits ore more for these numbers. 64 bits do not hurt. */
+
+#include "EXTERN.h"
+#include "perl.h"
+#include "tt800.h"
+
+struct tt800_state tt800_initial_state = {
+        {                                       /* initial 25 seeds, */
+        0x95f24dab, 0x0b685215, 0xe76ccae7, 0xaf3ec239, 0x715fad23,
+        0x24a590ad, 0x69e4b5ef, 0xbf456141, 0x96bc1b7b, 0xa7bdf825,
+        0xc1de75b7, 0x8858a9c9, 0x2da87693, 0xb657f9dd, 0xffdc8a9f,
+        0x8121da71, 0x8b823ecb, 0x885d05f5, 0x4e20cd47, 0x5a9ad5d9,
+        0x512c0c03, 0xea857ccd, 0x4cc1d30f, 0x8891a8a1, 0xa6b7aadb
+        },
+        0                               /* initial k */
+        };
+
+
+static unsigned int mag01[2]=
+        {                       /* this is magic vector `a', don't change */
+        0x0, 0x8ebfd028
+        };
+
+
+/*
+ * tt800_get_next_int: Return next TT800 number (unscaled)
+ *
+ * Input:
+ *      g:  Pointer to a struct tt800_state.
+ *
+ */
+U32 tt800_get_next_int(TT800 g)
+{
+U32 y;
+
+if (g->k == TT800_N) /* generate TT800_N words at one time */
+	{ 
+	int kk;
+
+	for (kk=0; kk < TT800_N - TT800_M; kk++) 
+		{
+		g->x[kk] = 	g->x[kk+TT800_M] ^ 
+				(g->x[kk] >> 1) ^ mag01[g->x[kk] & 1];
+		}
+
+	for (; kk<TT800_N;kk++) 
+		{
+		g->x[kk] = 	g->x[kk+(TT800_M-TT800_N)] ^
+				(g->x[kk] >> 1) ^ mag01[g->x[kk] & 1];
+		}
+	g->k=0;
+	}
+
+y = g->x[g->k];
+y ^= (y << 7) & 0x2b5b2500; /* s and b, magic vectors */
+y ^= (y << 15) & 0xdb8b0000; /* t and c, magic vectors */
+/* 
+   the following line was added by Makoto Matsumoto in the 1996 version
+   to improve lower bit's corellation.
+   Delete this line to o use the code published in 1994.
+*/
+
+g->k++;
+
+y ^= (y >> 16); /* added to the 1994 version */
+return(y);
+}
+

Added: branches/upstream/libmath-random-tt800-perl/current/typemap
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmath-random-tt800-perl/current/typemap?rev=34795&op=file
==============================================================================
--- branches/upstream/libmath-random-tt800-perl/current/typemap (added)
+++ branches/upstream/libmath-random-tt800-perl/current/typemap Tue May  5 15:42:13 2009
@@ -1,0 +1,16 @@
+TYPEMAP
+TT800		T_TT800
+
+INPUT
+T_TT800
+	if (sv_isa($arg, \"Math::Random::TT800\")) {
+	    IV tmp = SvIV((SV*)SvRV($arg));
+	    $var = ($type) tmp;
+	}
+	else
+	    croak(\"$var is not of type Math::Random::TT800\")
+
+OUTPUT
+T_TT800
+	sv_setref_pv($arg, \"Math::Random::TT800\", (void*)$var);
+




More information about the Pkg-perl-cvs-commits mailing list