This repository has been archived on 2026-03-28. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
eodev/src/doSampler.h
2010-09-04 23:07:37 +02:00

72 lines
1.6 KiB
C++

// (c) Thales group, 2010
/*
Authors:
Johann Dreo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _doSampler_h
#define _doSampler_h
#include <eoFunctor.h>
#include "doBounder.h"
#include "doBounderNo.h"
template < typename D >
class doSampler : public eoUF< D&, typename D::EOType >
{
public:
typedef typename D::EOType EOType;
doSampler(doBounder< EOType > & bounder)
: _bounder(bounder)
{}
doSampler()
: _bounder( _dummy_bounder )
{}
// virtual EOType operator()( D& ) = 0 (provided by eoUF< A1, R >)
virtual EOType sample( D& ) = 0;
EOType operator()( D& distrib )
{
unsigned int size = distrib.size();
assert(size > 0);
//-------------------------------------------------------------
// Point we want to sample to get higher a set of points
// (coordinates in n dimension)
// x = {x1, x2, ..., xn}
// the sample method is implemented in the derivated class
//-------------------------------------------------------------
EOType solution(sample(distrib));
//-------------------------------------------------------------
//-------------------------------------------------------------
// Now we are bounding the distribution thanks to min and max
// parameters.
//-------------------------------------------------------------
_bounder(solution);
//-------------------------------------------------------------
return solution;
}
private:
//! Bounder functor
doBounder< EOType > & _bounder;
doBounderNo<EOType> _dummy_bounder;
};
#endif // !_doSampler_h