correct template typedef for NormalMulti* classes

This commit is contained in:
nojhan 2012-07-10 12:04:25 +02:00
commit 2c0638aa8f
4 changed files with 21 additions and 20 deletions

View file

@ -155,18 +155,16 @@ public:
#ifdef WITH_EIGEN #ifdef WITH_EIGEN
//! edoEstimatorNormalMulti< EOT > //! edoEstimatorNormalMulti< EOT >
template < typename EOT > template < typename EOT, typename EOD = edoNormalMulti<EOT> >
class edoEstimatorNormalMulti : public edoEstimator< edoNormalMulti< EOT > > class edoEstimatorNormalMulti : public edoEstimator< EOD >
{ {
public: public:
class CovMatrix class CovMatrix
{ {
public: public:
typedef typename EOT::AtomType AtomType; typedef typename EOT::AtomType AtomType;
// typedef typename edoNormalMulti<AtomType>::Vector Vector; typedef typename EOD::Vector Vector;
// typedef typename edoNormalMulti<AtomType>::Matrix Matrix; typedef typename EOD::Matrix Matrix;
typedef Eigen::Matrix< AtomType, 1, Eigen::Dynamic, Eigen::RowMajor> Vector;
typedef Eigen::Matrix< AtomType, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> Matrix;
CovMatrix( const eoPop< EOT >& pop ) CovMatrix( const eoPop< EOT >& pop )
{ {

View file

@ -52,13 +52,12 @@ public:
#else #else
#ifdef WITH_EIGEN #ifdef WITH_EIGEN
template < typename EOT > template < typename EOT, typename EOD = edoNormalMulti< EOT > >
class edoNormalMultiCenter : public edoModifierMass< edoNormalMulti< EOT > > class edoNormalMultiCenter : public edoModifierMass<EOD>
{ {
public: public:
typedef typename EOT::AtomType AtomType; typedef typename EOT::AtomType AtomType;
// typedef typename edoNormalMulti<AtomType>::Vector Vector; typedef typename EOD::Vector Vector;
typedef Eigen::Matrix< AtomType, 1, Eigen::Dynamic, Eigen::RowMajor> Vector;
void operator() ( edoNormalMulti< EOT >& distrib, EOT& mass ) void operator() ( edoNormalMulti< EOT >& distrib, EOT& mass )
{ {

View file

@ -96,10 +96,9 @@ class edoSamplerNormalMulti : public edoSampler< EOD >
{ {
public: public:
typedef typename EOT::AtomType AtomType; typedef typename EOT::AtomType AtomType;
// typedef typename edoNormalMulti<AtomType>::Vector Vector;
// typedef typename edoNormalMulti<AtomType>::Matrix Matrix; typedef typename EOD::Vector Vector;
typedef Eigen::Matrix< AtomType, 1, Eigen::Dynamic, Eigen::RowMajor> Vector; typedef typename EOD::Matrix Matrix;
typedef Eigen::Matrix< AtomType, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> Matrix;
edoSamplerNormalMulti( edoRepairer<EOT> & repairer ) edoSamplerNormalMulti( edoRepairer<EOT> & repairer )
: edoSampler< EOD >( repairer) : edoSampler< EOD >( repairer)
@ -116,7 +115,7 @@ public:
// Computes L and D such as V = L D L^T // Computes L and D such as V = L D L^T
Eigen::LDLT<Matrix> cholesky( distrib.varcovar() ); Eigen::LDLT<Matrix> cholesky( distrib.varcovar() );
Matrix L = cholesky.matrixL(); Matrix L = cholesky.matrixL();
Matrix D = cholesky.vectorD(); Matrix D = cholesky.vectorD().asDiagonal();
// now compute the final symetric matrix: LsD = L D^1/2 // now compute the final symetric matrix: LsD = L D^1/2
// remember that V = ( L D^1/2) ( L D^1/2)^T // remember that V = ( L D^1/2) ( L D^1/2)^T

View file

@ -43,7 +43,7 @@ Authors:
typedef eoReal< eoMinimizingFitness > EOT; typedef eoReal< eoMinimizingFitness > EOT;
typedef edoNormalMulti< EOT > Distrib; typedef edoNormalMulti< EOT > Distrib;
typedef EOT::AtomType AtomType; typedef typename EOT::AtomType AtomType;
#ifdef WITH_BOOST #ifdef WITH_BOOST
#include <boost/numeric/ublas/vector.hpp> #include <boost/numeric/ublas/vector.hpp>
@ -53,10 +53,8 @@ typedef EOT::AtomType AtomType;
#else #else
#ifdef WITH_EIGEN #ifdef WITH_EIGEN
#include <Eigen/Dense> #include <Eigen/Dense>
// typedef typename edoNormalMulti<AtomType>::Vector Vector; typedef typename edoNormalMulti<EOT>::Vector Vector;
// typedef typename edoNormalMulti<AtomType>::Matrix Matrix; typedef typename edoNormalMulti<EOT>::Matrix Matrix;
typedef Eigen::Matrix< AtomType, 1, Eigen::Dynamic, Eigen::RowMajor> Vector;
typedef Eigen::Matrix< AtomType, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> Matrix;
#endif #endif
#endif #endif
@ -144,7 +142,14 @@ int main(int ac, char** av)
// (2) distribution initial parameters // (2) distribution initial parameters
#ifdef WITH_BOOST
Vector mean( s_size, mean_value ); Vector mean( s_size, mean_value );
#else
#ifdef WITH_EIGEN
Vector mean( s_size );
mean = Vector::Constant( s_size, mean_value);
#endif
#endif
Matrix varcovar( s_size, s_size ); Matrix varcovar( s_size, s_size );
varcovar( 0, 0 ) = covar1_value; varcovar( 0, 0 ) = covar1_value;