18 #ifndef PIC_POINT_SAMPLERS_SAMPLER_RANDOM_M_HPP 19 #define PIC_POINT_SAMPLERS_SAMPLER_RANDOM_M_HPP 23 #include "../base.hpp" 24 #include "../util/math.hpp" 26 #include "../point_samplers/sampler_random.hpp" 33 template<
unsigned int N>
82 bool Write(std::string name);
89 bool Read(std::string name);
92 template <
unsigned int N>
102 template <
unsigned int N>
107 this->nSamplers = nSamplers;
108 this->nLevels = nLevels;
109 oldSamples = nSamples;
114 #pragma omp parallel for 116 for(
int i = 0; i < nSamplers; i++) {
121 template <
unsigned int N>
124 if(window.
equal(oldWindow) && (oldSamples == nSamples)) {
129 for(
int i = 0; i < nSamplers; i++) {
130 samplers[i]->update(type, window, nSamples, nLevels);
134 oldSamples = nSamples;
138 template <
unsigned int N>
141 return samplers[(*m)() % nSamplers];
144 template <
unsigned int N>
149 file.open(name.c_str(), std::ios::in);
151 if(!file.is_open()) {
166 for(
unsigned int i = 0; i < N; i++) {
167 file >> oldWindow[i];
176 if(samplers != NULL) {
182 for(
int i = 0; i < nSamplers; i++) {
184 unsigned int samplesR = 0;
190 for(
unsigned int j=0; j<samplesR; j++) {
192 samplers[i]->
samplesR.push_back(value);
216 template <
unsigned int N>
221 file.open(name.c_str(), std::ios::out);
223 if(!file.is_open()) {
228 file <<
"nSamplers: " << nSamplers <<
" oldSamples: " << oldSamples <<
" nLevels: " << nLevels << std::endl;
230 file <<
"oldWindow: ";
231 for(
unsigned int i = 0; i < N; i++) {
232 file << oldWindow[i] <<
" ";
237 for(
int i = 0; i < nSamplers; i++) {
240 file <<
"nSamplesR: " << rs->
samplesR.size() << std::endl;
241 for(
unsigned int j=0; j< rs->
samplesR.size(); j++) {
The MRSamplers class.
Definition: sampler_random_m.hpp:34
int nLevels
Definition: sampler_random_m.hpp:44
int nSamplers
Definition: sampler_random_m.hpp:38
SAMPLER_TYPE
Definition: display.hpp:52
bool equal(Vec< N, T > a)
equal
Definition: display.hpp:203
RandomSampler< N > ** samplers
Definition: sampler_random_m.hpp:37
std::vector< int > samplesR
Definition: display.hpp:53
The RandomSampler class.
Definition: display.hpp:43
#define PIC_INLINE
Definition: base.hpp:33
SAMPLER_TYPE
Definition: point_samplers.hpp:51
bool Write(std::string name)
Write saves into an existing file.
bool Read(std::string name)
Read.
Definition: bilateral_separation.hpp:25
The RandomSampler class.
Definition: sampler_random.hpp:43
RandomSampler< N > * getSampler(std::mt19937 *m)
getSampler gets a sampler at a given level
int oldSamples
Definition: sampler_random_m.hpp:39
SAMPLER_TYPE type
Definition: sampler_random_m.hpp:41
The Vec class.
Definition: vec.hpp:35
Vec< N, int > oldWindow
Definition: sampler_random_m.hpp:40
bool update(Vec< N, int > window, int nSamples)
update