QMCPACK
FakeRandom.h
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////////////////////
2 // This file is distributed under the University of Illinois/NCSA Open Source License.
3 // See LICENSE file in top directory for details.
4 //
5 // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
6 //
7 // File developed by: Mark Dewing, markdewing@gmail.com, University of Illinois at Urbana-Champaign
8 //
9 // File created by: Mark Dewing, markdewing@gmail.com, University of Illinois at Urbana-Champaign
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 
13 #ifndef FAKERANDOM_H
14 #define FAKERANDOM_H
15 
16 #include "RandomBase.h"
17 
18 // Deterministic generator for testing.
19 
20 namespace qmcplusplus
21 {
22 template<typename T = double>
23 class FakeRandom : public RandomBase<T>
24 {
25 public:
28 
29  FakeRandom();
30  T operator()() override;
31 
32  void init(int iseed) override{};
33  void seed(uint_fast32_t aseed) override{};
34  void write(std::ostream& rout) const override { rout << m_val; };
35  void read(std::istream& rin) override { rin >> m_val; };
36  void load(const std::vector<uint_type>& newstate) override{};
37  void save(std::vector<uint_type>& curstate) const override{};
38  size_t state_size() const override { return 0; };
39  std::unique_ptr<RandomBase<T>> makeClone() const override { return std::make_unique<FakeRandom<T>>(*this); }
40 
41  void set_value(double val);
42 
43 private:
44  T m_val{0.5};
45 };
46 
47 } // namespace qmcplusplus
48 #endif
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
typename RandomBase< T >::uint_type uint_type
Definition: FakeRandom.h:27
void init(int iseed) override
Definition: FakeRandom.h:32
void write(std::ostream &rout) const override
Definition: FakeRandom.h:34
typename RandomBase< T >::result_type result_type
Definition: FakeRandom.h:26
T operator()() override
Definition: FakeRandom.cpp:27
std::unique_ptr< RandomBase< T > > makeClone() const override
Definition: FakeRandom.h:39
void set_value(double val)
Definition: FakeRandom.cpp:21
void save(std::vector< uint_type > &curstate) const override
Definition: FakeRandom.h:37
uint_fast32_t uint_type
Definition: RandomBase.h:28
void seed(uint_fast32_t aseed) override
Definition: FakeRandom.h:33
size_t state_size() const override
Definition: FakeRandom.h:38
void load(const std::vector< uint_type > &newstate) override
Definition: FakeRandom.h:36
void read(std::istream &rin) override
Definition: FakeRandom.h:35