annotate liboctave/numeric/oct-rand.h @ 20791:f7084eae3318

maint: Use Octave coding conventions for #if statements. * mk-opts.pl, dialog.h, find-files-dialog.h, find-files-model.h, file-editor-tab.h, octave-qscintilla.h, octave-txt-lexer.h, main-window.h, octave-cmd.h, octave-dock-widget.h, octave-gui.h, thread-manager.h, workspace-model.h, workspace-view.h, builtins.h, Cell.h, bitfcns.cc, c-file-ptr-stream.h, cdisplay.h, comment-list.h, cutils.h, data.h, debug.h, defaults.in.h, defun-dld.h, defun-int.h, defun.h, dirfns.h, display.h, dynamic-ld.h, error.h, event-queue.h, file-io.h, filter.cc, getrusage.cc, gl-render.h, gl2ps-renderer.h, graphics.in.h, gripes.h, help.h, hook-fcn.h, input.h, jit-ir.h, jit-typeinfo.h, jit-util.h, load-path.h, load-save.h, ls-ascii-helper.h, ls-hdf5.h, ls-mat-ascii.h, ls-mat4.h, ls-mat5.h, ls-oct-binary.h, ls-oct-text.h, ls-utils.h, oct-errno.h, oct-fstrm.h, oct-handle.h, oct-hdf5-types.h, oct-hdf5.h, oct-hist.h, oct-iostrm.h, oct-lvalue.h, oct-map.h, oct-obj.h, oct-prcstrm.h, oct-procbuf.h, oct-stdstrm.h, oct-stream.h, oct-strstrm.h, oct.h, octave-link.h, pager.h, pr-output.h, procstream.h, profiler.h, pt-jit.h, sighandlers.cc, sighandlers.h, siglist.h, sparse-xdiv.h, sparse-xpow.h, symtab.h, syscalls.cc, sysdep.h, toplev.cc, toplev.h, utils.h, variables.h, workspace-element.h, xdiv.h, xnorm.h, xpow.h, dmperm.cc, oct-qhull.h, mkbuiltins, oct-conf.in.h, ov-base-diag.h, ov-base-int.h, ov-base-mat.h, ov-base-scalar.h, ov-base-sparse.h, ov-base.h, ov-bool-mat.h, ov-bool-sparse.h, ov-bool.h, ov-builtin.h, ov-cell.h, ov-ch-mat.h, ov-class.h, ov-classdef.h, ov-colon.h, ov-complex.h, ov-cs-list.h, ov-cx-diag.h, ov-cx-mat.h, ov-cx-sparse.h, ov-dld-fcn.h, ov-fcn-handle.h, ov-fcn-inline.h, ov-fcn.h, ov-float.h, ov-flt-complex.h, ov-flt-cx-diag.h, ov-flt-cx-mat.h, ov-flt-re-diag.h, ov-flt-re-mat.h, ov-int-traits.h, ov-int16.h, ov-int32.h, ov-int64.h, ov-int8.h, ov-java.h, ov-lazy-idx.h, ov-mex-fcn.h, ov-null-mat.h, ov-perm.h, ov-range.h, ov-re-diag.h, ov-re-mat.h, ov-re-sparse.h, ov-scalar.h, ov-str-mat.h, ov-struct.h, ov-type-conv.h, ov-typeinfo.h, ov-uint16.h, ov-uint32.h, ov-uint64.h, ov-uint8.h, ov-usr-fcn.h, ov.h, octave.h, ops.h, options-usage.h, lex.h, parse.h, pt-all.h, pt-arg-list.h, pt-array-list.h, pt-assign.h, pt-binop.h, pt-bp.h, pt-cbinop.h, pt-cell.h, pt-check.h, pt-classdef.h, pt-cmd.h, pt-colon.h, pt-const.h, pt-decl.h, pt-eval.h, pt-except.h, pt-exp.h, pt-fcn-handle.h, pt-funcall.h, pt-id.h, pt-idx.h, pt-jump.h, pt-loop.h, pt-mat.h, pt-misc.h, pt-pr-code.h, pt-select.h, pt-stmt.h, pt-unop.h, pt-walk.h, pt.h, token.h, version.in.h, Array-util.h, Array.h, CColVector.h, CDiagMatrix.h, CMatrix.h, CNDArray.h, CRowVector.h, CSparse.h, DiagArray2.h, MArray-decl.h, MArray-defs.h, MArray.h, MDiagArray2.h, MSparse.h, Matrix.h, MatrixType.h, PermMatrix.h, Range.h, Sparse.h, boolMatrix.h, boolNDArray.h, boolSparse.h, chMatrix.h, chNDArray.h, dColVector.h, dDiagMatrix.h, dMatrix.h, dNDArray.h, dRowVector.h, dSparse.h, dim-vector.h, fCColVector.h, fCDiagMatrix.h, fCMatrix.h, fCNDArray.h, fCRowVector.h, fColVector.h, fDiagMatrix.h, fMatrix.h, fNDArray.h, fRowVector.h, idx-vector.h, int16NDArray.h, int32NDArray.h, int64NDArray.h, int8NDArray.h, intNDArray.h, uint16NDArray.h, uint32NDArray.h, uint64NDArray.h, uint8NDArray.h, f77-fcn.h, lo-error.h, quit.h, CmplxAEPBAL.h, CmplxCHOL.h, CmplxGEPBAL.h, CmplxHESS.h, CmplxLU.h, CmplxQR.h, CmplxQRP.h, CmplxSCHUR.h, CmplxSVD.h, CollocWt.h, DAE.h, DAEFunc.h, DAERT.h, DAERTFunc.h, DASPK.h, DASRT.h, DASSL.h, DET.h, EIG.h, LSODE.h, ODE.h, ODEFunc.h, ODES.h, ODESFunc.h, Quad.h, SparseCmplxCHOL.h, SparseCmplxLU.h, SparseCmplxQR.cc, SparseCmplxQR.h, SparseQR.h, SparsedbleCHOL.h, SparsedbleLU.h, base-aepbal.h, base-dae.h, base-de.h, base-lu.h, base-min.h, base-qr.h, bsxfun-decl.h, bsxfun-defs.cc, bsxfun.h, dbleAEPBAL.h, dbleCHOL.h, dbleGEPBAL.h, dbleHESS.h, dbleLU.h, dbleQR.h, dbleQRP.h, dbleSCHUR.h, dbleSVD.h, eigs-base.cc, fCmplxAEPBAL.h, fCmplxCHOL.h, fCmplxGEPBAL.h, fCmplxHESS.h, fCmplxLU.h, fCmplxQR.h, fCmplxQRP.h, fCmplxSCHUR.h, fCmplxSVD.h, fEIG.h, floatAEPBAL.h, floatCHOL.h, floatGEPBAL.h, floatHESS.h, floatLU.h, floatQR.h, floatQRP.h, floatSCHUR.h, floatSVD.h, lo-mappers.cc, lo-mappers.h, lo-specfun.cc, lo-specfun.h, oct-convn.h, oct-fftw.h, oct-norm.h, oct-rand.h, oct-spparms.h, randmtzig.c, sparse-base-chol.h, sparse-base-lu.h, sparse-dmsolve.cc, Sparse-diag-op-defs.h, Sparse-op-decls.h, Sparse-op-defs.h, Sparse-perm-op-defs.h, mk-ops.awk, mx-base.h, mx-defs.h, mx-ext.h, mx-inlines.cc, mx-op-decl.h, mx-op-defs.h, sparse-mk-ops.awk, dir-ops.h, file-ops.h, file-stat.h, lo-sysdep.h, mach-info.h, oct-env.h, oct-group.h, oct-openmp.h, oct-passwd.h, oct-syscalls.h, oct-time.cc, oct-time.h, oct-uname.h, pathlen.h, sysdir.h, syswait.h, action-container.h, base-list.h, byte-swap.h, caseless-str.h, cmd-edit.h, cmd-hist.h, data-conv.h, functor.h, glob-match.h, kpse.cc, lo-array-gripes.h, lo-cutils.h, lo-ieee.h, lo-macros.h, lo-math.h, lo-regexp.h, lo-traits.h, lo-utils.h, oct-alloc.h, oct-base64.h, oct-binmap.h, oct-cmplx.h, oct-glob.h, oct-inttypes.h, oct-locbuf.h, oct-mutex.h, oct-refcount.h, oct-rl-edit.h, oct-rl-hist.h, oct-shlib.h, oct-sort.h, oct-sparse.h, pathsearch.h, singleton-cleanup.h, sparse-sort.h, sparse-util.h, statdefs.h, str-vec.h, sun-utils.h, unwind-prot.h, url-transfer.h: Use Octave coding conventions for #if statements.
author Rik <rik@octave.org>
date Thu, 03 Dec 2015 10:23:38 -0800
parents 4197fc428c7d
children 93748bcaec17
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
19697
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 17822
diff changeset
3 Copyright (C) 2003-2015 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
20791
f7084eae3318 maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents: 19697
diff changeset
23 #if ! defined (octave_oct_rand_h)
17822
ebb3ef964372 maint: Use common #define syntax "octave_filename_h" in h_files.
Rik <rik@octave.org>
parents: 17769
diff changeset
24 #define octave_oct_rand_h 1
4308
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
25
7537
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
26 #include <map>
4308
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
27 #include <string>
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
28
5730
109fdf7b3dcb [project @ 2006-04-03 19:18:26 by jwe]
jwe
parents: 5307
diff changeset
29 #include "dColVector.h"
4543
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4308
diff changeset
30 #include "dNDArray.h"
14655
43db83eff9db Implement single precision rand, randn, rande, randg and randp generators (bug #34351, #36293)
David Bateman <dbateman@free.fr>
parents: 14138
diff changeset
31 #include "fNDArray.h"
7537
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
32 #include "lo-ieee.h"
4308
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
33
7537
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
34 class
6108
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5730
diff changeset
35 OCTAVE_API
4308
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
36 octave_rand
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
37 {
7537
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
38 protected:
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
39
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
40 octave_rand (void);
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
41
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
42 public:
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
43
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
44 ~octave_rand (void) { }
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
45
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
46 static bool instance_ok (void);
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
47
4308
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
48 // Return the current seed.
7537
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
49 static double seed (void)
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
50 {
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
51 return instance_ok () ? instance->do_seed () : octave_NaN;
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
52 }
4308
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
53
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
54 // Set the seed.
7537
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
55 static void seed (double s)
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
56 {
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
57 if (instance_ok ())
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
58 instance->do_seed (s);
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
59 }
4308
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
60
10709
92a85ed5b86e Don't special case color_property type when emitting factory default (bug #30118)
David Bateman <dbateman@free.fr>
parents: 10312
diff changeset
61 // Reset the seed.
92a85ed5b86e Don't special case color_property type when emitting factory default (bug #30118)
David Bateman <dbateman@free.fr>
parents: 10312
diff changeset
62 static void reset (void)
92a85ed5b86e Don't special case color_property type when emitting factory default (bug #30118)
David Bateman <dbateman@free.fr>
parents: 10312
diff changeset
63 {
92a85ed5b86e Don't special case color_property type when emitting factory default (bug #30118)
David Bateman <dbateman@free.fr>
parents: 10312
diff changeset
64 if (instance_ok ())
92a85ed5b86e Don't special case color_property type when emitting factory default (bug #30118)
David Bateman <dbateman@free.fr>
parents: 10312
diff changeset
65 instance->do_reset ();
92a85ed5b86e Don't special case color_property type when emitting factory default (bug #30118)
David Bateman <dbateman@free.fr>
parents: 10312
diff changeset
66 }
92a85ed5b86e Don't special case color_property type when emitting factory default (bug #30118)
David Bateman <dbateman@free.fr>
parents: 10312
diff changeset
67
5730
109fdf7b3dcb [project @ 2006-04-03 19:18:26 by jwe]
jwe
parents: 5307
diff changeset
68 // Return the current state.
7537
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
69 static ColumnVector state (const std::string& d = std::string ())
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
70 {
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
71 return instance_ok () ? instance->do_state (d) : ColumnVector ();
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
72 }
5730
109fdf7b3dcb [project @ 2006-04-03 19:18:26 by jwe]
jwe
parents: 5307
diff changeset
73
109fdf7b3dcb [project @ 2006-04-03 19:18:26 by jwe]
jwe
parents: 5307
diff changeset
74 // 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
75 static void state (const ColumnVector &s,
10312
cbc402e64d83 untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
76 const std::string& d = std::string ())
7537
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
77 {
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
78 if (instance_ok ())
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
79 instance->do_state (s, d);
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
80 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
81
10709
92a85ed5b86e Don't special case color_property type when emitting factory default (bug #30118)
David Bateman <dbateman@free.fr>
parents: 10312
diff changeset
82 // Reset the current state/
92a85ed5b86e Don't special case color_property type when emitting factory default (bug #30118)
David Bateman <dbateman@free.fr>
parents: 10312
diff changeset
83 static void reset (const std::string& d)
92a85ed5b86e Don't special case color_property type when emitting factory default (bug #30118)
David Bateman <dbateman@free.fr>
parents: 10312
diff changeset
84 {
92a85ed5b86e Don't special case color_property type when emitting factory default (bug #30118)
David Bateman <dbateman@free.fr>
parents: 10312
diff changeset
85 if (instance_ok ())
92a85ed5b86e Don't special case color_property type when emitting factory default (bug #30118)
David Bateman <dbateman@free.fr>
parents: 10312
diff changeset
86 instance->do_reset (d);
92a85ed5b86e Don't special case color_property type when emitting factory default (bug #30118)
David Bateman <dbateman@free.fr>
parents: 10312
diff changeset
87 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
88
4308
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
89 // Return the current distribution.
7537
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
90 static std::string distribution (void)
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
91 {
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
92 return instance_ok () ? instance->do_distribution () : std::string ();
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
93 }
4308
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
94
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
95 // 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
96 // default), "normal", "exponential", "poisson", or "gamma".
7537
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
97 static void distribution (const std::string& d)
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
98 {
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
99 if (instance_ok ())
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
100 instance->do_distribution (d);
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
101 }
4308
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
102
7537
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
103 static void uniform_distribution (void)
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
104 {
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
105 if (instance_ok ())
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
106 instance->do_uniform_distribution ();
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
107 }
4308
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
108
7537
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
109 static void normal_distribution (void)
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
110 {
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
111 if (instance_ok ())
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
112 instance->do_normal_distribution ();
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
113 }
4308
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
114
7537
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
115 static void exponential_distribution (void)
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
116 {
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
117 if (instance_ok ())
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
118 instance->do_exponential_distribution ();
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
119 }
5730
109fdf7b3dcb [project @ 2006-04-03 19:18:26 by jwe]
jwe
parents: 5307
diff changeset
120
7537
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
121 static void poisson_distribution (void)
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
122 {
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
123 if (instance_ok ())
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
124 instance->do_poisson_distribution ();
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
125 }
5730
109fdf7b3dcb [project @ 2006-04-03 19:18:26 by jwe]
jwe
parents: 5307
diff changeset
126
7537
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
127 static void gamma_distribution (void)
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
128 {
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
129 if (instance_ok ())
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
130 instance->do_gamma_distribution ();
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
131 }
5730
109fdf7b3dcb [project @ 2006-04-03 19:18:26 by jwe]
jwe
parents: 5307
diff changeset
132
4308
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
133 // Return the next number from the sequence.
7537
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
134 static double scalar (double a = 1.0)
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
135 {
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
136 return instance_ok () ? instance->do_scalar (a) : octave_NaN;
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
137 }
4308
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
138
14655
43db83eff9db Implement single precision rand, randn, rande, randg and randp generators (bug #34351, #36293)
David Bateman <dbateman@free.fr>
parents: 14138
diff changeset
139 // Return the next number from the sequence.
43db83eff9db Implement single precision rand, randn, rande, randg and randp generators (bug #34351, #36293)
David Bateman <dbateman@free.fr>
parents: 14138
diff changeset
140 static float float_scalar (float a = 1.0)
7537
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
141 {
14655
43db83eff9db Implement single precision rand, randn, rande, randg and randp generators (bug #34351, #36293)
David Bateman <dbateman@free.fr>
parents: 14138
diff changeset
142 return instance_ok () ? instance->do_float_scalar (a) : octave_Float_NaN;
7537
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
143 }
4308
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
144
14655
43db83eff9db Implement single precision rand, randn, rande, randg and randp generators (bug #34351, #36293)
David Bateman <dbateman@free.fr>
parents: 14138
diff changeset
145 // Return an array of numbers from the sequence.
43db83eff9db Implement single precision rand, randn, rande, randg and randp generators (bug #34351, #36293)
David Bateman <dbateman@free.fr>
parents: 14138
diff changeset
146 static Array<double> vector (octave_idx_type n, double a = 1.0)
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
147 {
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
148 return instance_ok () ? instance->do_vector (n, a) : Array<double> ();
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
149 }
14655
43db83eff9db Implement single precision rand, randn, rande, randg and randp generators (bug #34351, #36293)
David Bateman <dbateman@free.fr>
parents: 14138
diff changeset
150
43db83eff9db Implement single precision rand, randn, rande, randg and randp generators (bug #34351, #36293)
David Bateman <dbateman@free.fr>
parents: 14138
diff changeset
151 // Return an array of numbers from the sequence.
43db83eff9db Implement single precision rand, randn, rande, randg and randp generators (bug #34351, #36293)
David Bateman <dbateman@free.fr>
parents: 14138
diff changeset
152 static Array<float> float_vector (octave_idx_type n, float a = 1.0)
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
153 {
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
154 return instance_ok () ? instance->do_float_vector (n, a) : Array<float> ();
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
155 }
14655
43db83eff9db Implement single precision rand, randn, rande, randg and randp generators (bug #34351, #36293)
David Bateman <dbateman@free.fr>
parents: 14138
diff changeset
156
4543
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4308
diff changeset
157 // 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
158 // filled in column major order.
7537
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
159 static NDArray nd_array (const dim_vector& dims, double a = 1.0)
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
160 {
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
161 return instance_ok () ? instance->do_nd_array (dims, a) : NDArray ();
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
162 }
4543
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4308
diff changeset
163
14655
43db83eff9db Implement single precision rand, randn, rande, randg and randp generators (bug #34351, #36293)
David Bateman <dbateman@free.fr>
parents: 14138
diff changeset
164
43db83eff9db Implement single precision rand, randn, rande, randg and randp generators (bug #34351, #36293)
David Bateman <dbateman@free.fr>
parents: 14138
diff changeset
165 // Return an N-dimensional array of numbers from the sequence,
43db83eff9db Implement single precision rand, randn, rande, randg and randp generators (bug #34351, #36293)
David Bateman <dbateman@free.fr>
parents: 14138
diff changeset
166 // filled in column major order.
43db83eff9db Implement single precision rand, randn, rande, randg and randp generators (bug #34351, #36293)
David Bateman <dbateman@free.fr>
parents: 14138
diff changeset
167 static FloatNDArray float_nd_array (const dim_vector& dims, float a = 1.0)
7537
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
168 {
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
169 return instance_ok () ? instance->do_float_nd_array (dims, a)
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
170 : FloatNDArray ();
7537
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
171 }
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
172
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
173 private:
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
174
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
175 static octave_rand *instance;
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
176
13983
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
177 static void cleanup_instance (void) { delete instance; instance = 0; }
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
178
7537
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
179 enum
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
180 {
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
181 unknown_dist,
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
182 uniform_dist,
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
183 normal_dist,
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
184 expon_dist,
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
185 poisson_dist,
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
186 gamma_dist
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
187 };
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
188
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
189 // Current distribution of random numbers.
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
190 int current_distribution;
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
191
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
192 // If TRUE, use old RANLIB generators. Otherwise, use Mersenne
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
193 // Twister generator.
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
194 bool use_old_generators;
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
195
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
196 // Saved MT states.
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
197 std::map<int, ColumnVector> rand_states;
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
198
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
199 // Return the current seed.
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
200 double do_seed (void);
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
201
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
202 // Set the seed.
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
203 void do_seed (double s);
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
204
10709
92a85ed5b86e Don't special case color_property type when emitting factory default (bug #30118)
David Bateman <dbateman@free.fr>
parents: 10312
diff changeset
205 // Reset the seed.
92a85ed5b86e Don't special case color_property type when emitting factory default (bug #30118)
David Bateman <dbateman@free.fr>
parents: 10312
diff changeset
206 void do_reset ();
92a85ed5b86e Don't special case color_property type when emitting factory default (bug #30118)
David Bateman <dbateman@free.fr>
parents: 10312
diff changeset
207
7537
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
208 // Return the current state.
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
209 ColumnVector do_state (const std::string& d);
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
210
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
211 // Set the current state/
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
212 void do_state (const ColumnVector &s, const std::string& d);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
213
10709
92a85ed5b86e Don't special case color_property type when emitting factory default (bug #30118)
David Bateman <dbateman@free.fr>
parents: 10312
diff changeset
214 // Reset the current state/
92a85ed5b86e Don't special case color_property type when emitting factory default (bug #30118)
David Bateman <dbateman@free.fr>
parents: 10312
diff changeset
215 void do_reset (const std::string& d);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
216
7537
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
217 // Return the current distribution.
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
218 std::string do_distribution (void);
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
219
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
220 // Set the current distribution. May be either "uniform" (the
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
221 // default), "normal", "exponential", "poisson", or "gamma".
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
222 void do_distribution (const std::string& d);
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
223
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
224 void do_uniform_distribution (void);
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
225
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
226 void do_normal_distribution (void);
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
227
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
228 void do_exponential_distribution (void);
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
229
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
230 void do_poisson_distribution (void);
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
231
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
232 void do_gamma_distribution (void);
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
233
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
234 // Return the next number from the sequence.
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
235 double do_scalar (double a = 1.);
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
236
14655
43db83eff9db Implement single precision rand, randn, rande, randg and randp generators (bug #34351, #36293)
David Bateman <dbateman@free.fr>
parents: 14138
diff changeset
237 // Return the next number from the sequence.
43db83eff9db Implement single precision rand, randn, rande, randg and randp generators (bug #34351, #36293)
David Bateman <dbateman@free.fr>
parents: 14138
diff changeset
238 float do_float_scalar (float a = 1.);
43db83eff9db Implement single precision rand, randn, rande, randg and randp generators (bug #34351, #36293)
David Bateman <dbateman@free.fr>
parents: 14138
diff changeset
239
43db83eff9db Implement single precision rand, randn, rande, randg and randp generators (bug #34351, #36293)
David Bateman <dbateman@free.fr>
parents: 14138
diff changeset
240 // Return an array of numbers from the sequence.
43db83eff9db Implement single precision rand, randn, rande, randg and randp generators (bug #34351, #36293)
David Bateman <dbateman@free.fr>
parents: 14138
diff changeset
241 Array<double> do_vector (octave_idx_type n, double a = 1.);
43db83eff9db Implement single precision rand, randn, rande, randg and randp generators (bug #34351, #36293)
David Bateman <dbateman@free.fr>
parents: 14138
diff changeset
242
43db83eff9db Implement single precision rand, randn, rande, randg and randp generators (bug #34351, #36293)
David Bateman <dbateman@free.fr>
parents: 14138
diff changeset
243 // Return an array of numbers from the sequence.
43db83eff9db Implement single precision rand, randn, rande, randg and randp generators (bug #34351, #36293)
David Bateman <dbateman@free.fr>
parents: 14138
diff changeset
244 Array<float> do_float_vector (octave_idx_type n, float a = 1.);
7537
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
245
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
246 // Return an N-dimensional array of numbers from the sequence,
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
247 // filled in column major order.
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
248 NDArray do_nd_array (const dim_vector& dims, double a = 1.);
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
249
14655
43db83eff9db Implement single precision rand, randn, rande, randg and randp generators (bug #34351, #36293)
David Bateman <dbateman@free.fr>
parents: 14138
diff changeset
250 // Return an N-dimensional array of numbers from the sequence,
43db83eff9db Implement single precision rand, randn, rande, randg and randp generators (bug #34351, #36293)
David Bateman <dbateman@free.fr>
parents: 14138
diff changeset
251 // filled in column major order.
43db83eff9db Implement single precision rand, randn, rande, randg and randp generators (bug #34351, #36293)
David Bateman <dbateman@free.fr>
parents: 14138
diff changeset
252 FloatNDArray do_float_nd_array (const dim_vector& dims, float a = 1.);
7537
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
253
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
254 // Some helper functions.
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
255
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
256 void initialize_ranlib_generators (void);
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
257
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
258 void initialize_mersenne_twister (void);
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
259
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
260 ColumnVector get_internal_state (void);
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
261
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
262 void save_state (void);
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
263
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
264 int get_dist_id (const std::string& d);
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
265
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
266 void set_internal_state (const ColumnVector& s);
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
267
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
268 void switch_to_generator (int dist);
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
269
a2950622f070 make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7533
diff changeset
270 void fill (octave_idx_type len, double *v, double a);
14655
43db83eff9db Implement single precision rand, randn, rande, randg and randp generators (bug #34351, #36293)
David Bateman <dbateman@free.fr>
parents: 14138
diff changeset
271
43db83eff9db Implement single precision rand, randn, rande, randg and randp generators (bug #34351, #36293)
David Bateman <dbateman@free.fr>
parents: 14138
diff changeset
272 void fill (octave_idx_type len, float *v, float a);
4308
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
273 };
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
274
b738d1a02adb [project @ 2003-01-24 19:37:12 by jwe]
jwe
parents:
diff changeset
275 #endif