RayZaler 0.1
The free opto-mechanical simulation framework
Random.h
1//
2// Copyright (c) 2024 Gonzalo José Carracedo Carballal
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU Lesser General Public License as
6// published by the Free Software Foundation, either version 3 of the
7// License, or (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful, but
10// WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU Lesser General Public License for more details.
13//
14// You should have received a copy of the GNU Lesser General Public
15// License along with this program. If not, see
16// <http://www.gnu.org/licenses/>
17//
18
19#ifndef _RZ_RANDOM_H
20#define _RZ_RANDOM_H
21
22#include <Vector.h>
23#include <random>
24
25#define RZ_SHARED_STATE_DEFAULT_SEED 0x12345
26
27namespace RZ {
29 uint64_t m_epoch = 0;
30 std::mt19937_64 m_generator;
31 std::uniform_real_distribution<Real> m_uniform;
32 std::normal_distribution<Real> m_normal;
33 public:
34 ExprRandomState(uint64_t seed = RZ_SHARED_STATE_DEFAULT_SEED);
35
36 void update();
37 void setSeed(uint64_t seed);
38 uint64_t epoch() const;
39 Real randu();
40 Real randn();
41 };
42}
43
44#endif // _RZ_RANDOM_H
Definition: Random.h:28