Total Variation Inpainting using Split Bregman
Data Structures | Macros | Typedefs | Functions | Variables
randmt.c File Reference

Mersenne Twister MT19937 pseudorandom number generator. More...

#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#include "randmt.h"

Go to the source code of this file.

Data Structures

struct  randmtstruct_t
 An MT19937 pseudo-random number generator. More...
 

Macros

#define M_LOGSQRT2PI   0.9189385332046727417803297
 The constant $ \log \sqrt{2\pi} $.
 
#define MT_N   624
 
#define MT_M   397
 
#define MT_MATRIX_A   0x9908B0DFUL
 
#define MT_UPPER_MASK   0x80000000UL
 
#define MT_LOWER_MASK   0x7FFFFFFFUL
 

Typedefs

typedef struct randmtstruct_t randmttype_t
 An MT19937 pseudo-random number generator.
 

Functions

randmt_tnew_randmt (void)
 Create a new randmt_t. More...
 
void free_randmt (randmt_t *generator)
 Free a randmt_t. More...
 
void init_randmt_r (randmt_t *generator, unsigned long seed)
 Initialize randmt_t with a seed. More...
 
void init_randmt_auto_r (randmt_t *generator)
 Initialize generator with the current time and memory address. More...
 
unsigned long rand_uint32_r (randmt_t *generator)
 Generate a random 32-bit unsigned integer (reentrant) More...
 
double rand_gamma_r (randmt_t *generator, double a, double b)
 Generate a Gamma-distributed number (reentrant) More...
 
static double logfactorial (double n)
 
double rand_poisson_r (randmt_t *generator, double mu)
 Generate a Poisson-distributed number (reentrant) More...
 

Variables

randmt_t __randmt_global_generator = {{0}, MT_N + 1}
 Global randmt_t, used with the global versions of the functions.
 

Detailed Description

Mersenne Twister MT19937 pseudorandom number generator.

Warning
Do NOT use for cryptographic purposes. Read Internet RFC4086, http://tools.ietf.org/html/rfc4086.
Author
Makoto Matsumoto (1997-2002)
Takuji Nishimura (1997-2002)
Seiji Nishimura (2008) seiji.nosp@m.1976.nosp@m.@gmai.nosp@m.l.co.nosp@m.m
Nicolas Limare nicol.nosp@m.as.l.nosp@m.imare.nosp@m.@cml.nosp@m.a.ens.nosp@m.-cac.nosp@m.han.f.nosp@m.r
Pascal Getreuer getre.nosp@m.uer@.nosp@m.gmail.nosp@m..com
History

Copyright (C) 1997-2002, Makoto Matsumoto and Takuji Nishimura
Copyright (C) 2008, Seiji Nishimura seiji.nosp@m.1976.nosp@m.@gmai.nosp@m.l.co.nosp@m.m
Copyright (C) 2010-2011 Nicolas Limare nicol.nosp@m.as.l.nosp@m.imare.nosp@m.@cml.nosp@m.a.ens.nosp@m.-cac.nosp@m.han.f.nosp@m.r
Copyright (C) 2011, Pascal Getreuer getre.nosp@m.uer@.nosp@m.gmail.nosp@m..com
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.
  1. 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.
  1. 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.

Definition in file randmt.c.

Macro Definition Documentation

#define MT_LOWER_MASK   0x7FFFFFFFUL

least significant r bits

Definition at line 91 of file randmt.c.

#define MT_MATRIX_A   0x9908B0DFUL

constant vector a

Definition at line 89 of file randmt.c.

#define MT_N   624

length of the state vector

Definition at line 87 of file randmt.c.

#define MT_UPPER_MASK   0x80000000UL

most significant w-r bits

Definition at line 90 of file randmt.c.