Mercurial > octave
annotate liboctave/numeric/oct-rand.cc @ 31605:e88a07dec498 stable
maint: Use macros to begin/end C++ namespaces.
* oct-conf-post-public.in.h: Define two macros (OCTAVE_BEGIN_NAMESPACE,
OCTAVE_END_NAMESPACE) that can be used to start/end a namespace.
* mk-opts.pl, build-env.h, build-env.in.cc, __betainc__.cc, __contourc__.cc,
__dsearchn__.cc, __eigs__.cc, __expint__.cc, __ftp__.cc, __gammainc__.cc,
__ichol__.cc, __ilu__.cc, __isprimelarge__.cc, __lin_interpn__.cc,
__magick_read__.cc, __pchip_deriv__.cc, __qp__.cc, amd.cc, auto-shlib.cc,
auto-shlib.h, balance.cc, base-text-renderer.cc, base-text-renderer.h,
besselj.cc, bitfcns.cc, bsxfun.cc, c-file-ptr-stream.cc, c-file-ptr-stream.h,
call-stack.cc, call-stack.h, ccolamd.cc, cellfun.cc, chol.cc, colamd.cc,
colloc.cc, conv2.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc, data.h, debug.cc,
defaults.cc, defaults.h, defun-int.h, defun.cc, det.cc, dirfns.cc, display.cc,
display.h, dlmread.cc, dmperm.cc, dot.cc, dynamic-ld.cc, dynamic-ld.h, eig.cc,
ellipj.cc, environment.cc, environment.h, error.cc, error.h, errwarn.h,
event-manager.cc, event-manager.h, event-queue.cc, event-queue.h, fcn-info.cc,
fcn-info.h, fft.cc, fft2.cc, fftn.cc, file-io.cc, filter.cc, find.cc,
ft-text-renderer.cc, ft-text-renderer.h, gcd.cc, getgrent.cc, getpwent.cc,
getrusage.cc, givens.cc, gl-render.cc, gl-render.h, gl2ps-print.cc,
gl2ps-print.h, graphics-toolkit.cc, graphics-toolkit.h, graphics.cc,
graphics.in.h, gsvd.cc, gtk-manager.cc, gtk-manager.h, hash.cc, help.cc,
help.h, hess.cc, hex2num.cc, hook-fcn.cc, hook-fcn.h, input.cc, input.h,
interpreter-private.cc, interpreter-private.h, interpreter.cc, interpreter.h,
inv.cc, jsondecode.cc, jsonencode.cc, kron.cc, latex-text-renderer.cc,
latex-text-renderer.h, load-path.cc, load-path.h, load-save.cc, load-save.h,
lookup.cc, ls-ascii-helper.cc, ls-ascii-helper.h, ls-oct-text.cc, ls-utils.cc,
ls-utils.h, lsode.cc, lu.cc, mappers.cc, matrix_type.cc, max.cc, mex-private.h,
mex.cc, mgorth.cc, nproc.cc, oct-fstrm.cc, oct-fstrm.h, oct-hdf5-types.cc,
oct-hdf5-types.h, oct-hist.cc, oct-hist.h, oct-iostrm.cc, oct-iostrm.h,
oct-opengl.h, oct-prcstrm.cc, oct-prcstrm.h, oct-procbuf.cc, oct-procbuf.h,
oct-process.cc, oct-process.h, oct-stdstrm.h, oct-stream.cc, oct-stream.h,
oct-strstrm.cc, oct-strstrm.h, oct-tex-lexer.in.ll, oct-tex-parser.yy,
ordqz.cc, ordschur.cc, pager.cc, pager.h, pinv.cc, pow2.cc, pr-flt-fmt.cc,
pr-output.cc, procstream.cc, procstream.h, psi.cc, qr.cc, quad.cc, quadcc.cc,
qz.cc, rand.cc, rcond.cc, regexp.cc, schur.cc, settings.cc, settings.h,
sighandlers.cc, sighandlers.h, sparse-xdiv.cc, sparse-xdiv.h, sparse-xpow.cc,
sparse-xpow.h, sparse.cc, spparms.cc, sqrtm.cc, stack-frame.cc, stack-frame.h,
stream-euler.cc, strfind.cc, strfns.cc, sub2ind.cc, svd.cc, sylvester.cc,
symbfact.cc, syminfo.cc, syminfo.h, symrcm.cc, symrec.cc, symrec.h,
symscope.cc, symscope.h, symtab.cc, symtab.h, syscalls.cc, sysdep.cc, sysdep.h,
text-engine.cc, text-engine.h, text-renderer.cc, text-renderer.h, time.cc,
toplev.cc, tril.cc, tsearch.cc, typecast.cc, url-handle-manager.cc,
url-handle-manager.h, urlwrite.cc, utils.cc, utils.h, variables.cc,
variables.h, xdiv.cc, xdiv.h, xnorm.cc, xnorm.h, xpow.cc, xpow.h,
__delaunayn__.cc, __fltk_uigetfile__.cc, __glpk__.cc, __init_fltk__.cc,
__init_gnuplot__.cc, __ode15__.cc, __voronoi__.cc, audiodevinfo.cc,
audioread.cc, convhulln.cc, fftw.cc, gzip.cc, mk-build-env-features.sh,
mk-builtins.pl, cdef-class.cc, cdef-class.h, cdef-fwd.h, cdef-manager.cc,
cdef-manager.h, cdef-method.cc, cdef-method.h, cdef-object.cc, cdef-object.h,
cdef-package.cc, cdef-package.h, cdef-property.cc, cdef-property.h,
cdef-utils.cc, cdef-utils.h, ov-base.cc, ov-base.h, ov-bool-mat.cc,
ov-builtin.h, ov-cell.cc, ov-class.cc, ov-class.h, ov-classdef.cc,
ov-classdef.h, ov-complex.cc, ov-fcn-handle.cc, ov-fcn-handle.h, ov-fcn.h,
ov-java.cc, ov-java.h, ov-mex-fcn.h, ov-null-mat.cc, ov-oncleanup.cc,
ov-struct.cc, ov-typeinfo.cc, ov-typeinfo.h, ov-usr-fcn.cc, ov-usr-fcn.h,
ov.cc, ov.h, octave.cc, octave.h, mk-ops.sh, op-b-b.cc, op-b-bm.cc,
op-b-sbm.cc, op-bm-b.cc, op-bm-bm.cc, op-bm-sbm.cc, op-cdm-cdm.cc, op-cell.cc,
op-chm.cc, op-class.cc, op-cm-cm.cc, op-cm-cs.cc, op-cm-m.cc, op-cm-s.cc,
op-cm-scm.cc, op-cm-sm.cc, op-cs-cm.cc, op-cs-cs.cc, op-cs-m.cc, op-cs-s.cc,
op-cs-scm.cc, op-cs-sm.cc, op-dm-dm.cc, op-dm-scm.cc, op-dm-sm.cc,
op-dm-template.cc, op-dms-template.cc, op-fcdm-fcdm.cc, op-fcm-fcm.cc,
op-fcm-fcs.cc, op-fcm-fm.cc, op-fcm-fs.cc, op-fcn.cc, op-fcs-fcm.cc,
op-fcs-fcs.cc, op-fcs-fm.cc, op-fcs-fs.cc, op-fdm-fdm.cc, op-fm-fcm.cc,
op-fm-fcs.cc, op-fm-fm.cc, op-fm-fs.cc, op-fs-fcm.cc, op-fs-fcs.cc,
op-fs-fm.cc, op-fs-fs.cc, op-i16-i16.cc, op-i32-i32.cc, op-i64-i64.cc,
op-i8-i8.cc, op-int-concat.cc, op-m-cm.cc, op-m-cs.cc, op-m-m.cc, op-m-s.cc,
op-m-scm.cc, op-m-sm.cc, op-mi.cc, op-pm-pm.cc, op-pm-scm.cc, op-pm-sm.cc,
op-pm-template.cc, op-range.cc, op-s-cm.cc, op-s-cs.cc, op-s-m.cc, op-s-s.cc,
op-s-scm.cc, op-s-sm.cc, op-sbm-b.cc, op-sbm-bm.cc, op-sbm-sbm.cc,
op-scm-cm.cc, op-scm-cs.cc, op-scm-m.cc, op-scm-s.cc, op-scm-scm.cc,
op-scm-sm.cc, op-sm-cm.cc, op-sm-cs.cc, op-sm-m.cc, op-sm-s.cc, op-sm-scm.cc,
op-sm-sm.cc, op-str-m.cc, op-str-s.cc, op-str-str.cc, op-struct.cc,
op-ui16-ui16.cc, op-ui32-ui32.cc, op-ui64-ui64.cc, op-ui8-ui8.cc, ops.h,
anon-fcn-validator.cc, anon-fcn-validator.h, bp-table.cc, bp-table.h,
comment-list.cc, comment-list.h, filepos.h, lex.h, lex.ll, oct-lvalue.cc,
oct-lvalue.h, oct-parse.yy, parse.h, profiler.cc, profiler.h,
pt-anon-scopes.cc, pt-anon-scopes.h, pt-arg-list.cc, pt-arg-list.h,
pt-args-block.cc, pt-args-block.h, pt-array-list.cc, pt-array-list.h,
pt-assign.cc, pt-assign.h, pt-binop.cc, pt-binop.h, pt-bp.cc, pt-bp.h,
pt-cbinop.cc, pt-cbinop.h, pt-cell.cc, pt-cell.h, pt-check.cc, pt-check.h,
pt-classdef.cc, pt-classdef.h, pt-cmd.h, pt-colon.cc, pt-colon.h, pt-const.cc,
pt-const.h, pt-decl.cc, pt-decl.h, pt-eval.cc, pt-eval.h, pt-except.cc,
pt-except.h, pt-exp.cc, pt-exp.h, pt-fcn-handle.cc, pt-fcn-handle.h, pt-id.cc,
pt-id.h, pt-idx.cc, pt-idx.h, pt-jump.h, pt-loop.cc, pt-loop.h, pt-mat.cc,
pt-mat.h, pt-misc.cc, pt-misc.h, pt-pr-code.cc, pt-pr-code.h, pt-select.cc,
pt-select.h, pt-spmd.cc, pt-spmd.h, pt-stmt.cc, pt-stmt.h, pt-tm-const.cc,
pt-tm-const.h, pt-unop.cc, pt-unop.h, pt-vm-eval.cc, pt-walk.cc, pt-walk.h,
pt.cc, pt.h, token.cc, token.h, Range.cc, Range.h, idx-vector.cc, idx-vector.h,
range-fwd.h, CollocWt.cc, CollocWt.h, aepbalance.cc, aepbalance.h, chol.cc,
chol.h, gepbalance.cc, gepbalance.h, gsvd.cc, gsvd.h, hess.cc, hess.h,
lo-mappers.cc, lo-mappers.h, lo-specfun.cc, lo-specfun.h, lu.cc, lu.h,
oct-convn.cc, oct-convn.h, oct-fftw.cc, oct-fftw.h, oct-norm.cc, oct-norm.h,
oct-rand.cc, oct-rand.h, oct-spparms.cc, oct-spparms.h, qr.cc, qr.h, qrp.cc,
qrp.h, randgamma.cc, randgamma.h, randmtzig.cc, randmtzig.h, randpoisson.cc,
randpoisson.h, schur.cc, schur.h, sparse-chol.cc, sparse-chol.h, sparse-lu.cc,
sparse-lu.h, sparse-qr.cc, sparse-qr.h, svd.cc, svd.h, child-list.cc,
child-list.h, dir-ops.cc, dir-ops.h, file-ops.cc, file-ops.h, file-stat.cc,
file-stat.h, lo-sysdep.cc, lo-sysdep.h, lo-sysinfo.cc, lo-sysinfo.h,
mach-info.cc, mach-info.h, oct-env.cc, oct-env.h, oct-group.cc, oct-group.h,
oct-password.cc, oct-password.h, oct-syscalls.cc, oct-syscalls.h, oct-time.cc,
oct-time.h, oct-uname.cc, oct-uname.h, action-container.cc, action-container.h,
base-list.h, cmd-edit.cc, cmd-edit.h, cmd-hist.cc, cmd-hist.h, f77-fcn.h,
file-info.cc, file-info.h, lo-array-errwarn.cc, lo-array-errwarn.h, lo-hash.cc,
lo-hash.h, lo-ieee.h, lo-regexp.cc, lo-regexp.h, lo-utils.cc, lo-utils.h,
oct-base64.cc, oct-base64.h, oct-glob.cc, oct-glob.h, oct-inttypes.h,
oct-mutex.cc, oct-mutex.h, oct-refcount.h, oct-shlib.cc, oct-shlib.h,
oct-sparse.cc, oct-sparse.h, oct-string.h, octave-preserve-stream-state.h,
pathsearch.cc, pathsearch.h, quit.cc, quit.h, unwind-prot.cc, unwind-prot.h,
url-transfer.cc, url-transfer.h : Use new macros to begin/end C++ namespaces.
author | Rik <rik@octave.org> |
---|---|
date | Thu, 01 Dec 2022 14:23:45 -0800 |
parents | 796f54d4ddbf |
children | aac27ad79be6 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
30059
diff
changeset
|
3 // Copyright (C) 2003-2022 The Octave Project Developers |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
4308 | 25 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21723
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21202
diff
changeset
|
27 # include "config.h" |
4308 | 28 #endif |
7533
ff52243af934
save state separately for each MT random number generator
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
29 |
23475
d691ed308237
maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents:
23457
diff
changeset
|
30 #include <cassert> |
21912
d92dcbcd7691
prefer C++ wrappers for C standard headers in C++ code
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
31 #include <cstdint> |
d92dcbcd7691
prefer C++ wrappers for C standard headers in C++ code
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
32 |
23475
d691ed308237
maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents:
23457
diff
changeset
|
33 #include <limits> |
4308 | 34 |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
35 #include "lo-error.h" |
5730 | 36 #include "lo-ieee.h" |
37 #include "lo-mappers.h" | |
22322
93b3cdd36854
move most f77 function decls to separate header files
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
38 #include "lo-ranlib-proto.h" |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
39 #include "mach-info.h" |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
40 #include "oct-locbuf.h" |
4308 | 41 #include "oct-rand.h" |
4415 | 42 #include "oct-time.h" |
23475
d691ed308237
maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents:
23457
diff
changeset
|
43 #include "quit.h" |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
44 #include "randgamma.h" |
5730 | 45 #include "randmtzig.h" |
46 #include "randpoisson.h" | |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
47 #include "singleton-cleanup.h" |
4308 | 48 |
31605
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
49 OCTAVE_BEGIN_NAMESPACE(octave) |
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
50 |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
51 rand *rand::m_instance = nullptr; |
6435 | 52 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
53 rand::rand (void) |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
54 : m_current_distribution (uniform_dist), m_use_old_generators (false), |
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
55 m_rand_states () |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
56 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
57 initialize_ranlib_generators (); |
7537
a2950622f070
make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents:
7536
diff
changeset
|
58 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
59 initialize_mersenne_twister (); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
60 } |
24866
441b27c0fd5e
use C++11 features to eliminate some macros in oct-rand.cc
John W. Eaton <jwe@octave.org>
parents:
24856
diff
changeset
|
61 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
62 bool rand::instance_ok (void) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
63 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
64 bool retval = true; |
5730 | 65 |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
66 if (! m_instance) |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
67 { |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
68 m_instance = new rand (); |
26369
0249ba4c9589
Fix static analyzer detected V668 issues (bug #55347).
Andreas Weber <octave@josoansi.de>
parents:
25433
diff
changeset
|
69 singleton_cleanup_list::add (cleanup_instance); |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
70 } |
7533
ff52243af934
save state separately for each MT random number generator
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
71 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
72 return retval; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
73 } |
7533
ff52243af934
save state separately for each MT random number generator
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
74 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
75 double rand::do_seed (void) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
76 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
77 union d2i { double d; int32_t i[2]; }; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
78 union d2i u; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
79 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
80 mach_info::float_format ff = mach_info::native_float_format (); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
81 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
82 switch (ff) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
83 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
84 case mach_info::flt_fmt_ieee_big_endian: |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
85 F77_FUNC (getsd, GETSD) (u.i[1], u.i[0]); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
86 break; |
4308 | 87 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
88 default: |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
89 F77_FUNC (getsd, GETSD) (u.i[0], u.i[1]); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
90 break; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
91 } |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
92 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
93 return u.d; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
94 } |
7536 | 95 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
96 static int32_t |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
97 force_to_fit_range (int32_t i, int32_t lo, int32_t hi) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
98 { |
26436
0dcb3e515370
oct-rand.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
99 assert (hi > lo && lo >= 0); |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
100 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
101 i = (i > 0 ? i : -i); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
102 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
103 if (i < lo) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
104 i = lo; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
105 else if (i > hi) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
106 i = i % hi; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
107 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
108 return i; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
109 } |
7533
ff52243af934
save state separately for each MT random number generator
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
110 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
111 void rand::do_seed (double s) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
112 { |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
113 m_use_old_generators = true; |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
114 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
115 int i0, i1; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
116 union d2i { double d; int32_t i[2]; }; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
117 union d2i u; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
118 u.d = s; |
7533
ff52243af934
save state separately for each MT random number generator
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
119 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
120 mach_info::float_format ff = mach_info::native_float_format (); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
121 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
122 switch (ff) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
123 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
124 case mach_info::flt_fmt_ieee_big_endian: |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
125 i1 = force_to_fit_range (u.i[0], 1, 2147483563); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
126 i0 = force_to_fit_range (u.i[1], 1, 2147483399); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
127 break; |
7533
ff52243af934
save state separately for each MT random number generator
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
128 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
129 default: |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
130 i0 = force_to_fit_range (u.i[0], 1, 2147483563); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
131 i1 = force_to_fit_range (u.i[1], 1, 2147483399); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
132 break; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
133 } |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
134 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
135 F77_FUNC (setsd, SETSD) (i0, i1); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
136 } |
7533
ff52243af934
save state separately for each MT random number generator
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
137 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
138 void rand::do_reset (void) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
139 { |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
140 m_use_old_generators = true; |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
141 initialize_ranlib_generators (); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
142 } |
7533
ff52243af934
save state separately for each MT random number generator
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
143 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
144 uint32NDArray rand::do_state (const std::string& d) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
145 { |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
146 return m_rand_states[d.empty () ? m_current_distribution : get_dist_id (d)]; |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
147 } |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
148 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
149 void rand::do_state (const uint32NDArray& s, const std::string& d) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
150 { |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
151 m_use_old_generators = false; |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
152 |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
153 int old_dist = m_current_distribution; |
4308 | 154 |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
155 int new_dist = (d.empty () ? m_current_distribution : get_dist_id (d)); |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
156 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
157 uint32NDArray saved_state; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
158 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
159 if (old_dist != new_dist) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
160 saved_state = get_internal_state (); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
161 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
162 set_internal_state (s); |
4308 | 163 |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
164 m_rand_states[new_dist] = get_internal_state (); |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
165 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
166 if (old_dist != new_dist) |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
167 m_rand_states[old_dist] = saved_state; |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
168 } |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
169 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
170 void rand::do_reset (const std::string& d) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
171 { |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
172 m_use_old_generators = false; |
4308 | 173 |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
174 int old_dist = m_current_distribution; |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
175 |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
176 int new_dist = (d.empty () ? m_current_distribution : get_dist_id (d)); |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
177 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
178 uint32NDArray saved_state; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
179 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
180 if (old_dist != new_dist) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
181 saved_state = get_internal_state (); |
4308 | 182 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
183 init_mersenne_twister (); |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
184 m_rand_states[new_dist] = get_internal_state (); |
4308 | 185 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
186 if (old_dist != new_dist) |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
187 m_rand_states[old_dist] = saved_state; |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
188 } |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
189 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
190 std::string rand::do_distribution (void) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
191 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
192 std::string retval; |
5730 | 193 |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
194 switch (m_current_distribution) |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
195 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
196 case uniform_dist: |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
197 retval = "uniform"; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
198 break; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
199 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
200 case normal_dist: |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
201 retval = "normal"; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
202 break; |
5730 | 203 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
204 case expon_dist: |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
205 retval = "exponential"; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
206 break; |
5730 | 207 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
208 case poisson_dist: |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
209 retval = "poisson"; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
210 break; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
211 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
212 case gamma_dist: |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
213 retval = "gamma"; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
214 break; |
5730 | 215 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
216 default: |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
217 (*current_liboctave_error_handler) |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
218 ("rand: invalid distribution ID = %d", m_current_distribution); |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
219 break; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
220 } |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
221 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
222 return retval; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
223 } |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
224 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
225 void rand::do_distribution (const std::string& d) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
226 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
227 int id = get_dist_id (d); |
5730 | 228 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
229 switch (id) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
230 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
231 case uniform_dist: |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
232 rand::uniform_distribution (); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
233 break; |
5730 | 234 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
235 case normal_dist: |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
236 rand::normal_distribution (); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
237 break; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
238 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
239 case expon_dist: |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
240 rand::exponential_distribution (); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
241 break; |
4308 | 242 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
243 case poisson_dist: |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
244 rand::poisson_distribution (); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
245 break; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
246 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
247 case gamma_dist: |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
248 rand::gamma_distribution (); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
249 break; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
250 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
251 default: |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
252 (*current_liboctave_error_handler) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
253 ("rand: invalid distribution ID = %d", id); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
254 break; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
255 } |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
256 } |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
257 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
258 void rand::do_uniform_distribution (void) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
259 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
260 switch_to_generator (uniform_dist); |
4308 | 261 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
262 F77_FUNC (setcgn, SETCGN) (uniform_dist); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
263 } |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
264 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
265 void rand::do_normal_distribution (void) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
266 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
267 switch_to_generator (normal_dist); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
268 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
269 F77_FUNC (setcgn, SETCGN) (normal_dist); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
270 } |
4308 | 271 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
272 void rand::do_exponential_distribution (void) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
273 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
274 switch_to_generator (expon_dist); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
275 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
276 F77_FUNC (setcgn, SETCGN) (expon_dist); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
277 } |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
278 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
279 void rand::do_poisson_distribution (void) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
280 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
281 switch_to_generator (poisson_dist); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
282 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
283 F77_FUNC (setcgn, SETCGN) (poisson_dist); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
284 } |
4308 | 285 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
286 void rand::do_gamma_distribution (void) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
287 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
288 switch_to_generator (gamma_dist); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
289 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
290 F77_FUNC (setcgn, SETCGN) (gamma_dist); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
291 } |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
292 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
293 template <> |
29228
5c14f81e0937
Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27923
diff
changeset
|
294 OCTAVE_API double rand::uniform<double> (void) |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
295 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
296 double retval; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
297 |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
298 if (m_use_old_generators) |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
299 F77_FUNC (dgenunf, DGENUNF) (0.0, 1.0, retval); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
300 else |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26446
diff
changeset
|
301 retval = rand_uniform<double> (); |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
302 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
303 return retval; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
304 } |
4308 | 305 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
306 template <> |
29228
5c14f81e0937
Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27923
diff
changeset
|
307 OCTAVE_API double rand::normal<double> (void) |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
308 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
309 double retval; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
310 |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
311 if (m_use_old_generators) |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
312 F77_FUNC (dgennor, DGENNOR) (0.0, 1.0, retval); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
313 else |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26446
diff
changeset
|
314 retval = rand_normal<double> (); |
4308 | 315 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
316 return retval; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
317 } |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
318 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
319 template <> |
29228
5c14f81e0937
Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27923
diff
changeset
|
320 OCTAVE_API double rand::exponential<double> (void) |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
321 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
322 double retval; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
323 |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
324 if (m_use_old_generators) |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
325 F77_FUNC (dgenexp, DGENEXP) (1.0, retval); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
326 else |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26446
diff
changeset
|
327 retval = rand_exponential<double> (); |
4543 | 328 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
329 return retval; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
330 } |
5730 | 331 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
332 template <> |
29228
5c14f81e0937
Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27923
diff
changeset
|
333 OCTAVE_API double rand::poisson<double> (double a) |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
334 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
335 double retval; |
5730 | 336 |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
337 if (m_use_old_generators) |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
338 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
339 if (a < 0.0 || ! math::isfinite (a)) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
340 retval = numeric_limits<double>::NaN (); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
341 else |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
342 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
343 // workaround bug in ignpoi, by calling with different Mu |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
344 F77_FUNC (dignpoi, DIGNPOI) (a + 1, retval); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
345 F77_FUNC (dignpoi, DIGNPOI) (a, retval); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
346 } |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
347 } |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
348 else |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26446
diff
changeset
|
349 retval = rand_poisson<double> (a); |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
350 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
351 return retval; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
352 } |
5730 | 353 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
354 template <> |
29228
5c14f81e0937
Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27923
diff
changeset
|
355 OCTAVE_API double rand::gamma<double> (double a) |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
356 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
357 double retval; |
4543 | 358 |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
359 if (m_use_old_generators) |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
360 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
361 if (a <= 0.0 || ! math::isfinite (a)) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
362 retval = numeric_limits<double>::NaN (); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
363 else |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
364 F77_FUNC (dgengam, DGENGAM) (1.0, a, retval); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
365 } |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
366 else |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26446
diff
changeset
|
367 retval = rand_gamma<double> (a); |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
368 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
369 return retval; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
370 } |
7533
ff52243af934
save state separately for each MT random number generator
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
371 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
372 template <> |
29228
5c14f81e0937
Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27923
diff
changeset
|
373 OCTAVE_API float rand::uniform<float> (void) |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
374 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
375 float retval; |
4543 | 376 |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
377 if (m_use_old_generators) |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
378 F77_FUNC (fgenunf, FGENUNF) (0.0f, 1.0f, retval); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
379 else |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26446
diff
changeset
|
380 retval = rand_uniform<float> (); |
4543 | 381 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
382 return retval; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
383 } |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
384 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
385 template <> |
29228
5c14f81e0937
Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27923
diff
changeset
|
386 OCTAVE_API float rand::normal<float> (void) |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
387 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
388 float retval; |
14655
43db83eff9db
Implement single precision rand, randn, rande, randg and randp generators (bug #34351, #36293)
David Bateman <dbateman@free.fr>
parents:
14138
diff
changeset
|
389 |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
390 if (m_use_old_generators) |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
391 F77_FUNC (fgennor, FGENNOR) (0.0f, 1.0f, retval); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
392 else |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26446
diff
changeset
|
393 retval = rand_normal<float> (); |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
394 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
395 return retval; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
396 } |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
397 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
398 template <> |
29228
5c14f81e0937
Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27923
diff
changeset
|
399 OCTAVE_API float rand::exponential<float> (void) |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
400 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
401 float retval; |
14655
43db83eff9db
Implement single precision rand, randn, rande, randg and randp generators (bug #34351, #36293)
David Bateman <dbateman@free.fr>
parents:
14138
diff
changeset
|
402 |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
403 if (m_use_old_generators) |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
404 F77_FUNC (fgenexp, FGENEXP) (1.0f, retval); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
405 else |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26446
diff
changeset
|
406 retval = rand_exponential<float> (); |
14655
43db83eff9db
Implement single precision rand, randn, rande, randg and randp generators (bug #34351, #36293)
David Bateman <dbateman@free.fr>
parents:
14138
diff
changeset
|
407 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
408 return retval; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
409 } |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
410 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
411 template <> |
29228
5c14f81e0937
Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27923
diff
changeset
|
412 OCTAVE_API float rand::poisson<float> (float a) |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
413 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
414 float retval; |
7537
a2950622f070
make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents:
7536
diff
changeset
|
415 |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
416 if (m_use_old_generators) |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
417 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
418 if (a < 0.0f || ! math::isfinite (a)) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
419 retval = numeric_limits<float>::NaN (); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
420 else |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
421 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
422 // workaround bug in ignpoi, by calling with different Mu |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
423 F77_FUNC (fignpoi, FIGNPOI) (a + 1, retval); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
424 F77_FUNC (fignpoi, FIGNPOI) (a, retval); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
425 } |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
426 } |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
427 else |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
428 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
429 // Keep poisson distribution in double precision for accuracy |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26446
diff
changeset
|
430 retval = rand_poisson<double> (a); |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
431 } |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
432 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
433 return retval; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
434 } |
7537
a2950622f070
make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents:
7536
diff
changeset
|
435 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
436 template <> |
29228
5c14f81e0937
Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27923
diff
changeset
|
437 OCTAVE_API float rand::gamma<float> (float a) |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
438 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
439 float retval; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
440 |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
441 if (m_use_old_generators) |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
442 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
443 if (a <= 0.0f || ! math::isfinite (a)) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
444 retval = numeric_limits<float>::NaN (); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
445 else |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
446 F77_FUNC (fgengam, FGENGAM) (1.0f, a, retval); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
447 } |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
448 else |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26446
diff
changeset
|
449 retval = rand_gamma<float> (a); |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
450 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
451 return retval; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
452 } |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
453 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
454 template <typename T> |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
455 T rand::do_scalar (T a) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
456 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
457 T retval = 0; |
14655
43db83eff9db
Implement single precision rand, randn, rande, randg and randp generators (bug #34351, #36293)
David Bateman <dbateman@free.fr>
parents:
14138
diff
changeset
|
458 |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
459 switch (m_current_distribution) |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
460 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
461 case uniform_dist: |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
462 retval = uniform<T> (); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
463 break; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
464 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
465 case normal_dist: |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
466 retval = normal<T> (); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
467 break; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
468 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
469 case expon_dist: |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
470 retval = exponential<T> (); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
471 break; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
472 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
473 case poisson_dist: |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
474 retval = poisson<T> (a); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
475 break; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
476 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
477 case gamma_dist: |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
478 retval = gamma<T> (a); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
479 break; |
14655
43db83eff9db
Implement single precision rand, randn, rande, randg and randp generators (bug #34351, #36293)
David Bateman <dbateman@free.fr>
parents:
14138
diff
changeset
|
480 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
481 default: |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
482 (*current_liboctave_error_handler) |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
483 ("rand: invalid distribution ID = %d", m_current_distribution); |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
484 break; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
485 } |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
486 |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
487 if (! m_use_old_generators) |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
488 save_state (); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
489 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
490 return retval; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
491 } |
14655
43db83eff9db
Implement single precision rand, randn, rande, randg and randp generators (bug #34351, #36293)
David Bateman <dbateman@free.fr>
parents:
14138
diff
changeset
|
492 |
29228
5c14f81e0937
Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27923
diff
changeset
|
493 template OCTAVE_API double rand::do_scalar<double> (double); |
5c14f81e0937
Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27923
diff
changeset
|
494 template OCTAVE_API float rand::do_scalar<float> (float); |
14655
43db83eff9db
Implement single precision rand, randn, rande, randg and randp generators (bug #34351, #36293)
David Bateman <dbateman@free.fr>
parents:
14138
diff
changeset
|
495 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
496 template <typename T> |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
497 Array<T> |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
498 rand::do_vector (octave_idx_type n, T a) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
499 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
500 Array<T> retval; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
501 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
502 if (n > 0) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
503 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
504 retval.clear (n, 1); |
14655
43db83eff9db
Implement single precision rand, randn, rande, randg and randp generators (bug #34351, #36293)
David Bateman <dbateman@free.fr>
parents:
14138
diff
changeset
|
505 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
506 fill (retval.numel (), retval.fortran_vec (), a); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
507 } |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
508 else if (n < 0) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
509 (*current_liboctave_error_handler) ("rand: invalid negative argument"); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
510 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
511 return retval; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
512 } |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
513 |
29228
5c14f81e0937
Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27923
diff
changeset
|
514 template OCTAVE_API Array<double> |
5c14f81e0937
Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27923
diff
changeset
|
515 rand::do_vector<double> (octave_idx_type, double); |
5c14f81e0937
Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27923
diff
changeset
|
516 template OCTAVE_API Array<float> |
5c14f81e0937
Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27923
diff
changeset
|
517 rand::do_vector<float> (octave_idx_type, float); |
14655
43db83eff9db
Implement single precision rand, randn, rande, randg and randp generators (bug #34351, #36293)
David Bateman <dbateman@free.fr>
parents:
14138
diff
changeset
|
518 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
519 NDArray rand::do_nd_array (const dim_vector& dims, double a) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
520 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
521 NDArray retval; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
522 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
523 if (! dims.all_zero ()) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
524 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
525 retval.clear (dims); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
526 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
527 fill (retval.numel (), retval.fortran_vec (), a); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
528 } |
14655
43db83eff9db
Implement single precision rand, randn, rande, randg and randp generators (bug #34351, #36293)
David Bateman <dbateman@free.fr>
parents:
14138
diff
changeset
|
529 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
530 return retval; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
531 } |
14655
43db83eff9db
Implement single precision rand, randn, rande, randg and randp generators (bug #34351, #36293)
David Bateman <dbateman@free.fr>
parents:
14138
diff
changeset
|
532 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
533 FloatNDArray rand::do_float_nd_array (const dim_vector& dims, float a) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
534 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
535 FloatNDArray retval; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
536 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
537 if (! dims.all_zero ()) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
538 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
539 retval.clear (dims); |
14655
43db83eff9db
Implement single precision rand, randn, rande, randg and randp generators (bug #34351, #36293)
David Bateman <dbateman@free.fr>
parents:
14138
diff
changeset
|
540 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
541 fill (retval.numel (), retval.fortran_vec (), a); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
542 } |
14655
43db83eff9db
Implement single precision rand, randn, rande, randg and randp generators (bug #34351, #36293)
David Bateman <dbateman@free.fr>
parents:
14138
diff
changeset
|
543 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
544 return retval; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
545 } |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
546 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
547 // Make the random number generator give us a different sequence every |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
548 // time we start octave unless we specifically set the seed. The |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
549 // technique used below will cycle monthly, but it does seem to |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
550 // work ok to give fairly different seeds each time Octave starts. |
14655
43db83eff9db
Implement single precision rand, randn, rande, randg and randp generators (bug #34351, #36293)
David Bateman <dbateman@free.fr>
parents:
14138
diff
changeset
|
551 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
552 void rand::initialize_ranlib_generators (void) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
553 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
554 sys::localtime tm; |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
555 int stored_distribution = m_current_distribution; |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
556 F77_FUNC (setcgn, SETCGN) (uniform_dist); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
557 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
558 int hour = tm.hour () + 1; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
559 int minute = tm.min () + 1; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
560 int second = tm.sec () + 1; |
14655
43db83eff9db
Implement single precision rand, randn, rande, randg and randp generators (bug #34351, #36293)
David Bateman <dbateman@free.fr>
parents:
14138
diff
changeset
|
561 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
562 int32_t s0 = tm.mday () * hour * minute * second; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
563 int32_t s1 = hour * minute * second; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
564 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
565 s0 = force_to_fit_range (s0, 1, 2147483563); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
566 s1 = force_to_fit_range (s1, 1, 2147483399); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
567 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
568 F77_FUNC (setall, SETALL) (s0, s1); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
569 F77_FUNC (setcgn, SETCGN) (stored_distribution); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
570 } |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
571 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
572 void rand::initialize_mersenne_twister (void) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
573 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
574 uint32NDArray s; |
14655
43db83eff9db
Implement single precision rand, randn, rande, randg and randp generators (bug #34351, #36293)
David Bateman <dbateman@free.fr>
parents:
14138
diff
changeset
|
575 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
576 init_mersenne_twister (); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
577 s = get_internal_state (); |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
578 m_rand_states[uniform_dist] = s; |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
579 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
580 init_mersenne_twister (); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
581 s = get_internal_state (); |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
582 m_rand_states[normal_dist] = s; |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
583 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
584 init_mersenne_twister (); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
585 s = get_internal_state (); |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
586 m_rand_states[expon_dist] = s; |
14655
43db83eff9db
Implement single precision rand, randn, rande, randg and randp generators (bug #34351, #36293)
David Bateman <dbateman@free.fr>
parents:
14138
diff
changeset
|
587 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
588 init_mersenne_twister (); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
589 s = get_internal_state (); |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
590 m_rand_states[poisson_dist] = s; |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
591 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
592 init_mersenne_twister (); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
593 s = get_internal_state (); |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
594 m_rand_states[gamma_dist] = s; |
14655
43db83eff9db
Implement single precision rand, randn, rande, randg and randp generators (bug #34351, #36293)
David Bateman <dbateman@free.fr>
parents:
14138
diff
changeset
|
595 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
596 // All of the initializations above have messed with the internal state. |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
597 // Restore the state of the currently selected distribution. |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
598 set_internal_state (m_rand_states[m_current_distribution]); |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
599 } |
7537
a2950622f070
make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents:
7536
diff
changeset
|
600 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
601 uint32NDArray rand::get_internal_state (void) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
602 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
603 uint32NDArray s (dim_vector (MT_N + 1, 1)); |
7537
a2950622f070
make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents:
7536
diff
changeset
|
604 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
605 get_mersenne_twister_state (reinterpret_cast<uint32_t *> (s.fortran_vec ())); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
606 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
607 return s; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
608 } |
7537
a2950622f070
make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents:
7536
diff
changeset
|
609 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
610 void rand::save_state (void) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
611 { |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
612 m_rand_states[m_current_distribution] = get_internal_state ();; |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
613 } |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
614 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
615 int rand::get_dist_id (const std::string& d) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
616 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
617 int retval = unknown_dist; |
7537
a2950622f070
make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents:
7536
diff
changeset
|
618 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
619 if (d == "uniform" || d == "rand") |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
620 retval = uniform_dist; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
621 else if (d == "normal" || d == "randn") |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
622 retval = normal_dist; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
623 else if (d == "exponential" || d == "rande") |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
624 retval = expon_dist; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
625 else if (d == "poisson" || d == "randp") |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
626 retval = poisson_dist; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
627 else if (d == "gamma" || d == "randg") |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
628 retval = gamma_dist; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
629 else |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
630 (*current_liboctave_error_handler) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
631 ("rand: invalid distribution '%s'", d.c_str ()); |
7537
a2950622f070
make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents:
7536
diff
changeset
|
632 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
633 return retval; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
634 } |
7537
a2950622f070
make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents:
7536
diff
changeset
|
635 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
636 void rand::set_internal_state (const uint32NDArray& s) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
637 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
638 octave_idx_type len = s.numel (); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
639 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
640 const uint32_t *sdata = reinterpret_cast <const uint32_t *> (s.data ()); |
7537
a2950622f070
make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents:
7536
diff
changeset
|
641 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
642 if (len == MT_N + 1 && sdata[MT_N] <= MT_N && sdata[MT_N] > 0) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
643 set_mersenne_twister_state (sdata); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
644 else |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
645 init_mersenne_twister (sdata, len); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
646 } |
7537
a2950622f070
make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents:
7536
diff
changeset
|
647 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
648 void rand::switch_to_generator (int dist) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
649 { |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
650 if (dist != m_current_distribution) |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
651 { |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
652 m_current_distribution = dist; |
7537
a2950622f070
make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents:
7536
diff
changeset
|
653 |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
654 set_internal_state (m_rand_states[dist]); |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
655 } |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
656 } |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
657 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
658 void rand::fill (octave_idx_type len, double *v, double a) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
659 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
660 if (len < 1) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
661 return; |
7537
a2950622f070
make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents:
7536
diff
changeset
|
662 |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
663 switch (m_current_distribution) |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
664 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
665 case uniform_dist: |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
666 if (m_use_old_generators) |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
667 std::generate_n (v, len, [](void) { double x; F77_FUNC (dgenunf, DGENUNF) (0.0, 1.0, x); return x; }); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
668 else |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
669 rand_uniform<double> (len, v); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
670 break; |
7537
a2950622f070
make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents:
7536
diff
changeset
|
671 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
672 case normal_dist: |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
673 if (m_use_old_generators) |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
674 std::generate_n (v, len, [](void) { double x; F77_FUNC (dgennor, DGENNOR) (0.0, 1.0, x); return x; }); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
675 else |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
676 rand_normal<double> (len, v); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
677 break; |
7537
a2950622f070
make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents:
7536
diff
changeset
|
678 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
679 case expon_dist: |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
680 if (m_use_old_generators) |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
681 std::generate_n (v, len, [](void) { double x; F77_FUNC (dgenexp, DGENEXP) (1.0, x); return x; }); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
682 else |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
683 rand_exponential<double> (len, v); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
684 break; |
7537
a2950622f070
make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents:
7536
diff
changeset
|
685 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
686 case poisson_dist: |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
687 if (m_use_old_generators) |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
688 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
689 if (a < 0.0 || ! math::isfinite (a)) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
690 std::fill_n (v, len, numeric_limits<double>::NaN ()); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
691 else |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
692 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
693 // workaround bug in ignpoi, by calling with different Mu |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
694 double tmp; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
695 F77_FUNC (dignpoi, DIGNPOI) (a + 1, tmp); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
696 std::generate_n (v, len, [a](void) { double x; F77_FUNC (dignpoi, DIGNPOI) (a, x); return x; }); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
697 } |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
698 } |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
699 else |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
700 rand_poisson<double> (a, len, v); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
701 break; |
7537
a2950622f070
make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents:
7536
diff
changeset
|
702 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
703 case gamma_dist: |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
704 if (m_use_old_generators) |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
705 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
706 if (a <= 0.0 || ! math::isfinite (a)) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
707 std::fill_n (v, len, numeric_limits<double>::NaN ()); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
708 else |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
709 std::generate_n (v, len, [a](void) { double x; F77_FUNC (dgengam, DGENGAM) (1.0, a, x); return x; }); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
710 } |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
711 else |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
712 rand_gamma<double> (a, len, v); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
713 break; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
714 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
715 default: |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
716 (*current_liboctave_error_handler) |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
717 ("rand: invalid distribution ID = %d", m_current_distribution); |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
718 break; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
719 } |
7537
a2950622f070
make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents:
7536
diff
changeset
|
720 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
721 save_state (); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
722 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
723 return; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
724 } |
8124
d227d096d49e
oct-rand.cc (initialize_mersenne_twister): use separate initializations for each generator
Brian Gough
parents:
7537
diff
changeset
|
725 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
726 void rand::fill (octave_idx_type len, float *v, float a) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
727 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
728 if (len < 1) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
729 return; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
730 |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
731 switch (m_current_distribution) |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
732 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
733 case uniform_dist: |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
734 if (m_use_old_generators) |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
735 std::generate_n (v, len, [](void) { float x; F77_FUNC (fgenunf, FGENUNF) (0.0f, 1.0f, x); return x; }); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
736 else |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26446
diff
changeset
|
737 rand_uniform<float> (len, v); |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
738 break; |
8124
d227d096d49e
oct-rand.cc (initialize_mersenne_twister): use separate initializations for each generator
Brian Gough
parents:
7537
diff
changeset
|
739 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
740 case normal_dist: |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
741 if (m_use_old_generators) |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
742 std::generate_n (v, len, [](void) { float x; F77_FUNC (fgennor, FGENNOR) (0.0f, 1.0f, x); return x; }); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
743 else |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26446
diff
changeset
|
744 rand_normal<float> (len, v); |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
745 break; |
8124
d227d096d49e
oct-rand.cc (initialize_mersenne_twister): use separate initializations for each generator
Brian Gough
parents:
7537
diff
changeset
|
746 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
747 case expon_dist: |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
748 if (m_use_old_generators) |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
749 std::generate_n (v, len, [](void) { float x; F77_FUNC (fgenexp, FGENEXP) (1.0f, x); return x; }); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
750 else |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26446
diff
changeset
|
751 rand_exponential<float> (len, v); |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
752 break; |
24852
53db3b152397
Correctly set rand state at startup (bug #53300).
Rik <rik@octave.org>
parents:
24534
diff
changeset
|
753 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
754 case poisson_dist: |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
755 if (m_use_old_generators) |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
756 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
757 if (a < 0.0f || ! math::isfinite (a)) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
758 std::fill_n (v, len, numeric_limits<float>::NaN ()); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
759 else |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
760 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
761 // workaround bug in ignpoi, by calling with different Mu |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
762 float tmp; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
763 F77_FUNC (fignpoi, FIGNPOI) (a + 1, tmp); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
764 std::generate_n (v, len, [a](void) { float x; F77_FUNC (fignpoi, FIGNPOI) (a, x); return x; }); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
765 } |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
766 } |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
767 else |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26446
diff
changeset
|
768 rand_poisson<float> (a, len, v); |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
769 break; |
7537
a2950622f070
make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents:
7536
diff
changeset
|
770 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
771 case gamma_dist: |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
772 if (m_use_old_generators) |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
773 { |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
774 if (a <= 0.0f || ! math::isfinite (a)) |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
775 std::fill_n (v, len, numeric_limits<float>::NaN ()); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
776 else |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
777 std::generate_n (v, len, [a](void) { float x; F77_FUNC (fgengam, FGENGAM) (1.0f, a, x); return x; }); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
778 } |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
779 else |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26446
diff
changeset
|
780 rand_gamma<float> (a, len, v); |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
781 break; |
7537
a2950622f070
make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents:
7536
diff
changeset
|
782 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
783 default: |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
784 (*current_liboctave_error_handler) |
30059
cc7ca74e883d
maint: use "m_" prefix for member variables in class rand.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
785 ("rand: invalid distribution ID = %d", m_current_distribution); |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
786 break; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
787 } |
7537
a2950622f070
make octave_rand a proper singleton class
John W. Eaton <jwe@octave.org>
parents:
7536
diff
changeset
|
788 |
25433
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
789 save_state (); |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
790 |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
791 return; |
49e0447413ad
use templates and move rand functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
792 } |
31605
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
793 |
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
794 OCTAVE_END_NAMESPACE(octave) |