randmtzig.h

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 2006-2012 John W. Eaton
00004 
00005 This file is part of Octave.
00006 
00007 Octave is free software; you can redistribute it and/or modify it
00008 under the terms of the GNU General Public License as published by the
00009 Free Software Foundation; either version 3 of the License, or (at your
00010 option) any later version.
00011 
00012 Octave is distributed in the hope that it will be useful, but WITHOUT
00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00015 for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Octave; see the file COPYING.  If not, see
00019 <http://www.gnu.org/licenses/>.
00020 
00021 */
00022 
00023 /*
00024    A C-program for MT19937, with initialization improved 2002/2/10.
00025    Coded by Takuji Nishimura and Makoto Matsumoto.
00026    This is a faster version by taking Shawn Cokus's optimization,
00027    Matthe Bellew's simplification, Isaku Wada's real version.
00028    David Bateman added normal and exponential distributions following
00029    Marsaglia and Tang's Ziggurat algorithm.
00030 
00031    Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
00032    Copyright (C) 2004, David Bateman
00033    All rights reserved.
00034 
00035    Redistribution and use in source and binary forms, with or without
00036    modification, are permitted provided that the following conditions
00037    are met:
00038 
00039      1. Redistributions of source code must retain the above copyright
00040         notice, this list of conditions and the following disclaimer.
00041 
00042      2. Redistributions in binary form must reproduce the above copyright
00043         notice, this list of conditions and the following disclaimer in the
00044         documentation and/or other materials provided with the distribution.
00045 
00046      3. The names of its contributors may not be used to endorse or promote
00047         products derived from this software without specific prior written
00048         permission.
00049 
00050    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00051    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00052    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00053    A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER
00054    OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00055    EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00056    PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00057    PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00058    LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00059    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00060    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00061 
00062 */
00063 
00064 #ifndef _RANDMTZIG_H
00065 #define _RANDMTZIG_H
00066 
00067 #define MT_N 624
00068 
00069 #ifdef  __cplusplus
00070 extern "C" {
00071 #endif
00072 
00073 /* === Mersenne Twister === */
00074 extern OCTAVE_API void oct_init_by_int (uint32_t s);
00075 extern OCTAVE_API void oct_init_by_array (uint32_t init_key[], int key_length);
00076 extern OCTAVE_API void oct_init_by_entropy (void);
00077 extern OCTAVE_API void oct_set_state (uint32_t save[]);
00078 extern OCTAVE_API void oct_get_state (uint32_t save[]);
00079 
00080 /* === Array generators === */
00081 extern OCTAVE_API double oct_randu (void);
00082 extern OCTAVE_API double oct_randn (void);
00083 extern OCTAVE_API double oct_rande (void);
00084 
00085 /* === Array generators === */
00086 extern OCTAVE_API void oct_fill_randu (octave_idx_type n, double *p);
00087 extern OCTAVE_API void oct_fill_randn (octave_idx_type n, double *p);
00088 extern OCTAVE_API void oct_fill_rande (octave_idx_type n, double *p);
00089 
00090 #ifdef  __cplusplus
00091 }
00092 #endif
00093 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines