EGS Brachy
An egs++ user code for rapid brachytherapy calculations
Loading...
Searching...
No Matches
/Users/marc/Developer/EGSnrc/HEN_HOUSE/user_codes/egs_brachy/egs_brachy/egs_sobol.h
Go to the documentation of this file.
1/*
2###############################################################################
3#
4# EGSnrc egs++ envelope geometry headers
5# Copyright (C) 2015 National Research Council Canada
6#
7# This file is part of EGSnrc.
8#
9# EGSnrc is free software: you can redistribute it and/or modify it under
10# the terms of the GNU Affero General Public License as published by the
11# Free Software Foundation, either version 3 of the License, or (at your
12# option) any later version.
13#
14# EGSnrc is distributed in the hope that it will be useful, but WITHOUT ANY
15# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
17# more details.
18#
19# You should have received a copy of the GNU Affero General Public License
20# along with EGSnrc. If not, see <http://www.gnu.org/licenses/>.
21#
22###############################################################################
23#
24# Author: Randle Taylor (randle.taylor@gmail.com) on behalf of
25# the Carleton Laboratory for Radiotherapy Physics
26#
27# Contributors:
28#
29###############################################################################
30*/
31
38#ifndef EGS_SOBOL_
39#define EGS_SOBOL_
40
41#ifdef WIN32
42
43 #ifdef BUILD_SOBOL_DLL
44 #define EGS_SOBOL_EXPORT __declspec(dllexport)
45 #else
46 #define EGS_SOBOL_EXPORT __declspec(dllimport)
47 #endif
48 #define EGS_SOBOL_LOCAL
49
50#else
51
52 #ifdef HAVE_VISIBILITY
53 #define EGS_SOBOL_EXPORT __attribute__ ((visibility ("default")))
54 #define EGS_SOBOL_LOCAL __attribute__ ((visibility ("hidden")))
55 #else
56 #define EGS_SOBOL_EXPORT
57 #define EGS_SOBOL_LOCAL
58 #endif
59
60#endif
61
62#include "sobol.h"
63
64#include "egs_rndm.h"
65#include "egs_input.h"
66#include "egs_functions.h"
67
68
71class EGS_SOBOL_LOCAL EGS_Sobol : public EGS_RandomGenerator {
72
73public:
74
75 EGS_Sobol(EGS_Input *inp): copy(0) {
76
77 int dimension;
78 int err = inp->getInput("dimension", dimension);
79 if (err || dimension < 0 || dimension > 3) {
80 dimension = 3;
81 }
82
83 init_seed=-1;
84 err = inp->getInput("initial seed", init_seed);
85 if (err || init_seed < 1) {
86 init_seed = sobol::tau_sobol(dimension);
87 }
88
89 np = dimension;
90
91 setState(dimension, init_seed);
92 };
93
94 EGS_Sobol(int dimension=3, EGS_I64 iseed=-1) :
95 EGS_RandomGenerator(dimension), copy(0) {
96
97 np = dimension;
98
99 if (iseed < 0) {
100 iseed=sobol::tau_sobol(dimension);
101 }
102
103 init_seed = iseed;
104
105 setState(dimension, iseed);
106 };
107
108 EGS_Sobol(const EGS_Sobol &r): copy(0) {
109 np = r.dim;
110 init_seed = r.init_seed;
111 setState(r.dim, r.init_seed);
112 };
113
115 /*if (copy){
116 delete copy;
117 }
118 */
119 };
120
123 void fillArray(int n, EGS_Float *array);
124
126 void describeRNG() const;
127
128 EGS_RandomGenerator *getCopy();
129
130 void setState(EGS_RandomGenerator *r);
131
132 void saveState();
133
134 void resetState();
135
136 int rngSize() const {
137 return baseSize() + sizeof(int) + 2*sizeof(EGS_I64);
138 };
139
140protected:
141
145 bool storePrivateState(ostream &data);
146
148 bool setPrivateState(istream &data);
149
150
151private:
152
153 void setState(int dimension, EGS_I64 init_seed);
154
155 int dim;
156 EGS_I64 init_seed,
160};
161#endif
EGS_RandomGenerator wrapper for Sobol library.
Definition egs_sobol.h:71
EGS_Sobol(EGS_Input *inp)
Definition egs_sobol.h:75
EGS_Sobol(const EGS_Sobol &r)
Definition egs_sobol.h:108
int rngSize() const
Definition egs_sobol.h:136
EGS_I64 cur_seed
initial seed for random number generator
Definition egs_sobol.h:157
EGS_Sobol * copy
current seed being used for random number generator (required to reinitialize
Definition egs_sobol.h:159
EGS_Sobol(int dimension=3, EGS_I64 iseed=-1)
Definition egs_sobol.h:94
EGS_I64 init_seed
Definition egs_sobol.h:156
#define EGS_SOBOL_LOCAL
Definition egs_sobol.h:57
int tau_sobol(int dim_num)
Definition sobol.cpp:28474
Sobol library functions from http://people.sc.fsu.edu/~jburkardt/cpp_src/sobol/sobol....