00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 #ifndef _edoNormalAdaptive_h
00030 #define _edoNormalAdaptive_h
00031 
00032 #include "edoDistrib.h"
00033 
00034 #ifdef WITH_EIGEN
00035 
00036 #include <Eigen/Dense>
00037 
00071 template < typename EOT >
00072 class edoNormalAdaptive : public edoDistrib< EOT >
00073 {
00074 public:
00075     
00076     typedef typename EOT::AtomType AtomType;
00077     typedef Eigen::Matrix< AtomType, Eigen::Dynamic, 1> Vector; 
00078     typedef Eigen::Matrix< AtomType, Eigen::Dynamic, Eigen::Dynamic> Matrix;
00079 
00080     edoNormalAdaptive( unsigned int dim = 1 ) :
00081         _dim(dim),
00082         _mean( Vector::Zero(dim) ),
00083         _C( Matrix::Identity(dim,dim) ),
00084         _B( Matrix::Identity(dim,dim) ),
00085         _D( Vector::Constant( dim, 1) ),
00086         _sigma(1.0),
00087         _p_c( Vector::Zero(dim) ),
00088         _p_s( Vector::Zero(dim) )
00089     {
00090         assert( _dim > 0);
00091     }
00092 
00093     edoNormalAdaptive( unsigned int dim,
00094             Vector mean,
00095             Matrix C,
00096             Matrix B,
00097             Vector D,
00098             double sigma,
00099             Vector p_c,
00100             Vector p_s
00101         ) :
00102         _mean( mean ),
00103         _C( C ),
00104         _B( B ),
00105         _D( D ),
00106         _sigma(sigma),
00107         _p_c( p_c ),
00108         _p_s( p_s )
00109     {
00110         assert( dim > 0);
00111         assert( _mean.innerSize() == dim );
00112         assert( _C.innerSize() == dim && _C.outerSize() == dim );
00113         assert( _B.innerSize() == dim && _B.outerSize() == dim );
00114         assert( _D.innerSize() == dim );
00115         assert( _sigma != 0.0 );
00116         assert( _p_c.innerSize() == dim );
00117         assert( _p_s.innerSize() == dim );
00118     }
00119 
00120     unsigned int size()
00121     {
00122         return _mean.innerSize();
00123     }
00124 
00125     Vector mean()       const {return _mean;}
00126     Matrix covar()      const {return _C;}
00127     Matrix coord_sys()  const {return _B;}
00128     Vector scaling()    const {return _D;}
00129     double sigma()      const {return _sigma;}
00130     Vector path_covar() const {return _p_c;}
00131     Vector path_sigma() const {return _p_s;}
00132 
00133     void mean(       Vector m ) { _mean = m;  assert( m.size() == _dim ); }
00134     void covar(      Matrix c ) { _C = c;     assert( c.innerSize() == _dim && c.outerSize() == _dim ); }
00135     void coord_sys(  Matrix b ) { _B = b;     assert( b.innerSize() == _dim && b.outerSize() == _dim ); }
00136     void scaling(    Vector d ) { _D = d;     assert( d.size() == _dim ); }
00137     void sigma(      double s ) { _sigma = s; assert( s != 0.0 );}
00138     void path_covar( Vector p ) { _p_c = p;   assert( p.size() == _dim ); }
00139     void path_sigma( Vector p ) { _p_s = p;   assert( p.size() == _dim ); }
00140 
00141 private:
00142     unsigned int _dim;
00143     Vector _mean; 
00144     Matrix _C; 
00145     Matrix _B; 
00146     Vector _D; 
00147     double _sigma; 
00148     Vector _p_c; 
00149     Vector _p_s; 
00150 };
00151 
00152 #else
00153 #pragma message "WARNING: there is no Boost::uBLAS implementation of edoNormalAdaptive, build WITH_EIGEN if you need it."
00154 #endif // WITH_EIGEN
00155 
00156 #endif // !_edoNormalAdaptive_h