Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
MixMaxEngineImpl.h
Go to the documentation of this file.
1
2
3#include <cstdio>
4#include <cstdint>
5#include <cstdlib>
6#include <vector>
7
8#ifndef ROOT_Math_MixMaxEngineImpl
9#define ROOT_Math_MixMaxEngineImpl
10
11
12#if (ROOT_MM_N==17)
13namespace mixmax_17 {
14#elif (ROOT_MM_N==240)
15namespace mixmax_240 {
16#elif (ROOT_MM_N==256)
17namespace mixmax_256 {
18#else
19namespace {
20#endif
21
22#ifdef WIN32
23#define __thread __declspec(thread)
24extern "C" int fscanf(FILE *stream, const char *format, ...);
25#endif
26
27#include "mixmax.icc"
28
29#undef N
30}
31
32#include "Math/MixMaxEngine.h"
33
34#include <iostream>
35
36#if (ROOT_MM_N==17)
37using namespace mixmax_17;
38#elif (ROOT_MM_N==240)
39using namespace mixmax_240;
40#elif (ROOT_MM_N==256)
41using namespace mixmax_256;
42#endif
43
44
45namespace ROOT {
46 namespace Math {
47
48
49
50 // dummy implementation
51 template<int N>
53 public:
54 MixMaxEngineImpl(uint64_t) {
55 std::cerr << "MixMaxEngineImpl - These template parameters are not supported for MixMaxEngine" << std::endl;
56 }
58 void SetSeed(uint64_t) { }
59 double Rndm() { return -1; }
60 double IntRndm() { return 0; }
61 void SetState(const std::vector<uint64_t> &) { }
62 void GetState(std::vector<uint64_t> &) { }
63 int Counter() { return -1; }
64 void SetCounter(int) {}
65 void Iterate() {}
66 };
67
68
69template<>
72public:
73
76
77 MixMaxEngineImpl(uint64_t seed) {
78 fRngState = rng_alloc();
79 SetSeed(seed);
80 }
82 rng_free(fRngState);
83 }
84 void SetSeedFast(Result_t seed) {
85 seed_spbox(fRngState, seed);
86 }
87 void SetSeed(Result_t seed) {
88 //seed_spbox(fRngState, seed);
89 seed_uniquestream(fRngState, 0, 0, (uint32_t)(seed>>32), (uint32_t)seed );
90 }
91 double Rndm() {
92 return get_next_float(fRngState);
93 }
94 // generate one integer number
96 return get_next(fRngState);
97 }
98 void SetState(const std::vector<StateInt_t> & state) {
99 if (fRngState) rng_free(fRngState);
100 fRngState = rng_copy(const_cast<StateInt_t*>(state.data()) );
101 }
102 void GetState(std::vector<StateInt_t> & state) const {
103 int n = rng_get_N();
104 state.resize(n);
105 for (int i = 0; i < n; ++i)
106 state[i] = fRngState->V[i];
107 }
108 void Iterate() {
109 iterate(fRngState);
110 }
111 int Counter() const {
112 return fRngState->counter;
113 }
114 void SetCounter(int val) {
115 fRngState->counter = val;
116 }
117 static int Size() {
118 return rng_get_N();
119 }
120
121 // to silent some warning
122 void RndmArray(int n, double * array) {
123 fill_array(fRngState, n, array);
124 }
125 void ReadState(const char filename[] ) {
126 read_state(fRngState, filename);
127 }
128 // branch generator given a vector of seed (at least 4 32 bit values)
129 void Branch(uint32_t * seedvec) {
130 branch_inplace(fRngState, seedvec);
131 }
132
133
134};
135
136
137 } // end namespace Math
138} // end namespace ROOT
139
140#endif
#define ROOT_MM_N
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t format
MixMaxEngine< ROOT_MM_N, 0 >::Result_t Result_t
void SetState(const std::vector< StateInt_t > &state)
MixMaxEngine< ROOT_MM_N, 0 >::StateInt_t StateInt_t
void GetState(std::vector< StateInt_t > &state) const
void SetState(const std::vector< uint64_t > &)
void GetState(std::vector< uint64_t > &)
const Int_t n
Definition legend1.C:16
void seed_spbox(rng_state_t *X, myuint seed)
Definition mixmax.icc:205
int rng_get_N(void)
Definition mixmax.icc:240
int iterate(rng_state_t *X)
Definition mixmax.icc:34
#define get_next(X)
Definition mixmax.h:189
void branch_inplace(rng_state_t *Xin, myID_t *ID)
Definition mixmax.icc:394
void seed_uniquestream(rng_state_t *X, myID_t clusterID, myID_t machineID, myID_t runID, myID_t streamID)
Definition mixmax.icc:361
rng_state_t * rng_alloc()
Definition mixmax.icc:154
rng_state_t * rng_copy(myuint *Y)
Definition mixmax.icc:168
#define get_next_float(X)
Definition mixmax.h:190
int rng_free(rng_state_t *X)
Definition mixmax.icc:162
void read_state(rng_state_t *X, const char filename[])
Definition mixmax.icc:286
void fill_array(rng_state_t *X, unsigned int n, double *array)
Definition mixmax.icc:85
Namespace for new Math classes and functions.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
myuint V[240]
Definition mixmax.h:54
int counter
Definition mixmax.h:56