annotate liboctave/oct-rand.h @ 7533:ff52243af934

save state separately for each MT random number generator
author John W. Eaton <jwe@octave.org>
date Tue, 26 Feb 2008 05:28:59 -0500
parents a1dbe9d80eee
children a2950622f070 72830070a17b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4308
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
1 /*
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
2
7017
a1dbe9d80eee [project @ 2007-10-12 21:27:11 by jwe]
jwe
parents: 7016
diff changeset
3 Copyright (C) 2003, 2005, 2006, 2007 John W. Eaton
4308
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
4
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
6
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6108
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6108
diff changeset
10 option) any later version.
4308
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
11
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
15 for more details.
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
16
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6108
diff changeset
18 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6108
diff changeset
19 <http://www.gnu.org/licenses/>.
4308
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
20
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
21 */
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
22
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
23 #if !defined (octave_rand_h)
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
24 #define octave_rand_h 1
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
25
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
26 #include <string>
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
27
5730
109fdf7b3dcb [project @ 2006-04-03 19:18:26 by jwe]
jwe
parents: 5307
diff changeset
28 #include "dColVector.h"
4308
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
29 #include "dMatrix.h"
4543
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4308
diff changeset
30 #include "dNDArray.h"
4308
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
31
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
32 struct
6108
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5730
diff changeset
33 OCTAVE_API
4308
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
34 octave_rand
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
35 {
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
36 // Return the current seed.
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
37 static double seed (void);
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
38
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
39 // Set the seed.
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
40 static void seed (double s);
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
41
5730
109fdf7b3dcb [project @ 2006-04-03 19:18:26 by jwe]
jwe
parents: 5307
diff changeset
42 // Return the current state.
7533
ff52243af934 save state separately for each MT random number generator
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
43 static ColumnVector state (const std::string& d = std::string ());
5730
109fdf7b3dcb [project @ 2006-04-03 19:18:26 by jwe]
jwe
parents: 5307
diff changeset
44
109fdf7b3dcb [project @ 2006-04-03 19:18:26 by jwe]
jwe
parents: 5307
diff changeset
45 // Set the current state/
7533
ff52243af934 save state separately for each MT random number generator
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
46 static void state (const ColumnVector &s,
ff52243af934 save state separately for each MT random number generator
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
47 const std::string& d = std::string ());
5730
109fdf7b3dcb [project @ 2006-04-03 19:18:26 by jwe]
jwe
parents: 5307
diff changeset
48
4308
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
49 // Return the current distribution.
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
50 static std::string distribution (void);
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
51
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
52 // Set the current distribution. May be either "uniform" (the
7533
ff52243af934 save state separately for each MT random number generator
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
53 // default), "normal", "exponential", "poisson", or "gamma".
4308
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
54 static void distribution (const std::string& d);
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
55
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
56 static void uniform_distribution (void);
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
57
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
58 static void normal_distribution (void);
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
59
5730
109fdf7b3dcb [project @ 2006-04-03 19:18:26 by jwe]
jwe
parents: 5307
diff changeset
60 static void exponential_distribution (void);
109fdf7b3dcb [project @ 2006-04-03 19:18:26 by jwe]
jwe
parents: 5307
diff changeset
61
109fdf7b3dcb [project @ 2006-04-03 19:18:26 by jwe]
jwe
parents: 5307
diff changeset
62 static void poisson_distribution (void);
109fdf7b3dcb [project @ 2006-04-03 19:18:26 by jwe]
jwe
parents: 5307
diff changeset
63
109fdf7b3dcb [project @ 2006-04-03 19:18:26 by jwe]
jwe
parents: 5307
diff changeset
64 static void gamma_distribution (void);
109fdf7b3dcb [project @ 2006-04-03 19:18:26 by jwe]
jwe
parents: 5307
diff changeset
65
4308
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
66 // Return the next number from the sequence.
5730
109fdf7b3dcb [project @ 2006-04-03 19:18:26 by jwe]
jwe
parents: 5307
diff changeset
67 static double scalar (double a = 1.);
4308
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
68
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
69 // Return a matrix of numbers from the sequence, filled in column
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
70 // major order.
5730
109fdf7b3dcb [project @ 2006-04-03 19:18:26 by jwe]
jwe
parents: 5307
diff changeset
71 static Matrix matrix (octave_idx_type r, octave_idx_type c, double a = 1.);
4308
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
72
4543
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4308
diff changeset
73 // Return an N-dimensional array of numbers from the sequence,
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4308
diff changeset
74 // filled in column major order.
5730
109fdf7b3dcb [project @ 2006-04-03 19:18:26 by jwe]
jwe
parents: 5307
diff changeset
75 static NDArray nd_array (const dim_vector& dims, double a = 1.);
4543
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4308
diff changeset
76
4308
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
77 // Return an array of numbers from the sequence.
5730
109fdf7b3dcb [project @ 2006-04-03 19:18:26 by jwe]
jwe
parents: 5307
diff changeset
78 static Array<double> vector (octave_idx_type n, double a = 1.);
4308
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
79 };
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
80
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
81 #endif
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
82
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
83 /*
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
84 ;;; Local Variables: ***
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
85 ;;; mode: C++ ***
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
86 ;;; End: ***
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
87 */