code formating

This commit is contained in:
nojhan 2011-09-15 17:27:46 +02:00
commit 37a2c68b69
4 changed files with 142 additions and 192 deletions

View file

@ -30,7 +30,7 @@ Authors:
#include <eoFunctor.h> #include <eoFunctor.h>
#include "edoBounder.h" #include "edoRepairer.h"
#include "edoBounderNo.h" #include "edoBounderNo.h"
//! edoSampler< D > //! edoSampler< D >
@ -41,15 +41,15 @@ class edoSampler : public eoUF< D&, typename D::EOType >
public: public:
typedef typename D::EOType EOType; typedef typename D::EOType EOType;
edoSampler(edoBounder< EOType > & bounder) edoSampler(edoRepairer< EOType > & repairer)
: /*_dummy_bounder(),*/ _bounder(bounder) : _dummy_repairer(), _repairer(repairer)
{} {}
/*
edoSampler() edoSampler()
: _dummy_bounder(), _bounder( _dummy_bounder ) : _dummy_repairer(), _repairer( _dummy_repairer )
{} {}
*/
// virtual EOType operator()( D& ) = 0 (provided by eoUF< A1, R >) // virtual EOType operator()( D& ) = 0 (provided by eoUF< A1, R >)
@ -58,28 +58,15 @@ public:
unsigned int size = distrib.size(); unsigned int size = distrib.size();
assert(size > 0); assert(size > 0);
//-------------------------------------------------------------
// Point we want to sample to get higher a set of points // Point we want to sample to get higher a set of points
// (coordinates in n dimension) // (coordinates in n dimension)
// x = {x1, x2, ..., xn} // x = {x1, x2, ..., xn}
// the sample method is implemented in the derivated class // the sample method is implemented in the derivated class
//-------------------------------------------------------------
EOType solution(sample(distrib)); EOType solution(sample(distrib));
//-------------------------------------------------------------
//-------------------------------------------------------------
// Now we are bounding the distribution thanks to min and max // Now we are bounding the distribution thanks to min and max
// parameters. // parameters.
//------------------------------------------------------------- _repairer(solution);
_bounder(solution);
//-------------------------------------------------------------
return solution; return solution;
} }
@ -89,10 +76,10 @@ protected:
virtual EOType sample( D& ) = 0; virtual EOType sample( D& ) = 0;
private: private:
//edoBounderNo<EOType> _dummy_bounder; edoBounderNo<EOType> _dummy_repairer;
//! Bounder functor //! repairer functor
edoBounder< EOType > & _bounder; edoRepairer< EOType > & _repairer;
}; };

View file

@ -45,31 +45,19 @@ class edoSamplerNormalMono : public edoSampler< edoNormalMono< EOT > >
public: public:
typedef typename EOT::AtomType AtomType; typedef typename EOT::AtomType AtomType;
edoSamplerNormalMono( edoBounder< EOT > & bounder ) edoSamplerNormalMono( edoRepairer<EOT> & repairer ) : edoSampler( repairer) {}
: edoSampler< edoNormalMono< EOT > >( bounder )
{}
EOT sample( edoNormalMono< EOT >& distrib ) EOT sample( edoNormalMono< EOT >& distrib )
{ {
unsigned int size = distrib.size(); unsigned int size = distrib.size();
assert(size > 0); assert(size > 0);
//-------------------------------------------------------------
// Point we want to sample to get higher a set of points // Point we want to sample to get higher a set of points
// (coordinates in n dimension) // (coordinates in n dimension)
// x = {x1, x2, ..., xn} // x = {x1, x2, ..., xn}
//-------------------------------------------------------------
EOT solution; EOT solution;
//-------------------------------------------------------------
//-------------------------------------------------------------
// Sampling all dimensions // Sampling all dimensions
//-------------------------------------------------------------
for (unsigned int i = 0; i < size; ++i) for (unsigned int i = 0; i < size; ++i)
{ {
AtomType mean = distrib.mean()[i]; AtomType mean = distrib.mean()[i];
@ -81,9 +69,6 @@ public:
solution.push_back(random); solution.push_back(random);
} }
//-------------------------------------------------------------
return solution; return solution;
} }
}; };

View file

@ -40,6 +40,8 @@ class edoSamplerNormalMulti : public edoSampler< edoNormalMulti< EOT > >
public: public:
typedef typename EOT::AtomType AtomType; typedef typename EOT::AtomType AtomType;
edoSamplerNormalMulti( edoRepairer<EOT> & repairer ) : edoSampler( repairer) {}
class Cholesky class Cholesky
{ {
public: public:

View file

@ -44,51 +44,27 @@ class edoSamplerUniform : public edoSampler< edoUniform< EOT > >
public: public:
typedef D Distrib; typedef D Distrib;
edoSamplerUniform(edoBounder< EOT > & bounder) edoSamplerUniform( edoRepairer<EOT> & repairer ) : edoSampler( repairer) {}
: edoSampler< edoUniform<EOT> >(bounder) // FIXME: Why D is not used here ?
{}
/*
edoSamplerUniform()
: edoSampler< edoUniform<EOT> >()
{}
*/
EOT sample( edoUniform< EOT >& distrib ) EOT sample( edoUniform< EOT >& distrib )
{ {
unsigned int size = distrib.size(); unsigned int size = distrib.size();
assert(size > 0); assert(size > 0);
//-------------------------------------------------------------
// Point we want to sample to get higher a set of points // Point we want to sample to get higher a set of points
// (coordinates in n dimension) // (coordinates in n dimension)
// x = {x1, x2, ..., xn} // x = {x1, x2, ..., xn}
//-------------------------------------------------------------
EOT solution; EOT solution;
//-------------------------------------------------------------
//-------------------------------------------------------------
// Sampling all dimensions // Sampling all dimensions
//-------------------------------------------------------------
for (unsigned int i = 0; i < size; ++i) for (unsigned int i = 0; i < size; ++i)
{ {
double min = distrib.min()[i]; double min = distrib.min()[i];
double max = distrib.max()[i]; double max = distrib.max()[i];
double random = rng.uniform(min, max); double random = rng.uniform(min, max);
assert(min <= random && random <= max);
solution.push_back(random); solution.push_back(random);
} }
//-------------------------------------------------------------
return solution; return solution;
} }
}; };