Quantum++  v1.0.0-beta3
C++11 quantum computing library
random_devices.h
Go to the documentation of this file.
1 /*
2  * Quantum++
3  *
4  * Copyright (c) 2013 - 2017 Vlad Gheorghiu (vgheorgh@gmail.com)
5  *
6  * This file is part of Quantum++.
7  *
8  * Quantum++ is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * Quantum++ is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with Quantum++. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
27 #ifndef CLASSES_RANDOM_DEVICES_H_
28 #define CLASSES_RANDOM_DEVICES_H_
29 
30 namespace qpp
31 {
32 
46 class RandomDevices final : public internal::Singleton<RandomDevices> //
47 // Singleton
48 {
50 
51  std::random_device rd_;
52 public:
53  std::mt19937 rng_;
54 private:
58  RandomDevices() : rd_{}, rng_{rd_()}
59  {
60  }
61 
65  ~RandomDevices() = default;
66 }; /* class RandomDevices */
67 
68 } /* namespace qpp */
69 
70 #endif /* CLASSES_RANDOM_DEVICES_H_ */
Singleton policy class, used internally to implement the singleton pattern via CRTP (Curiously recurr...
Definition: singleton.h:77
Quantum++ main namespace.
Definition: codes.h:30
RandomDevices()
Initializes and seeds the random number generators.
Definition: random_devices.h:58
Singeleton class that manages the source of randomness in the library.
Definition: random_devices.h:46
std::random_device rd_
used to seed std::mt19937 rng_
Definition: random_devices.h:51
std::mt19937 rng_
Mersenne twister random number generator.
Definition: random_devices.h:53
~RandomDevices()=default
Default destructor.