votca 2026-dev
Loading...
Searching...
No Matches
kmcrandom.h
Go to the documentation of this file.
1/*
2 * Copyright 2009-2026 The VOTCA Development Team
3 * (http://www.votca.org)
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License")
6 *
7 * You may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 */
19
20#pragma once
21#ifndef VOTCA_XTP_KMCRANDOM_H
22#define VOTCA_XTP_KMCRANDOM_H
23
24// Standard includes
25#include <cmath>
26#include <cstdint>
27#include <random>
28
29// Local VOTCA includes
30#include "eigen.h"
31
32namespace votca {
33namespace xtp {
34
42class KMCRandom {
43 public:
44 KMCRandom(std::uint64_t seed, std::uint64_t stream);
46 double Uniform() {
47 return (double(engine_() >> 11) + 1.0) * (1.0 / 9007199254740992.0);
48 }
49
50 double Exponential(double rate) { return -std::log(Uniform()) / rate; }
54 double Normal();
55
56 private:
57 std::mt19937_64 engine_;
58};
59
60} // namespace xtp
61} // namespace votca
62
63#endif // VOTCA_XTP_KMCRANDOM_H
double Normal()
standard normal (Box-Muller)
Definition kmcengine.cc:61
double Uniform()
uniform in (0,1]
Definition kmcrandom.h:46
KMCRandom(std::uint64_t seed, std::uint64_t stream)
Definition kmcengine.cc:39
std::mt19937_64 engine_
Definition kmcrandom.h:57
double Exponential(double rate)
Exp(rate), i.e. -ln(u)/rate.
Definition kmcrandom.h:50
Index Integer(Index n)
uniform integer in [0, n)
Definition kmcengine.cc:47
Provides a means for comparing floating point numbers.
Definition basebead.h:33
Eigen::Index Index
Definition types.h:26