]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Base/Functors/GaussianCost.hxx
de14605f33551b3a3667ec19e14f2bfac482aca5
[FrontAlgorithms.git] / lib / fpa / Base / Functors / GaussianCost.hxx
1 #ifndef __FPA__BASE__FUNCTORS__GAUSSIANCOST__HXX__
2 #define __FPA__BASE__FUNCTORS__GAUSSIANCOST__HXX__
3
4 // -------------------------------------------------------------------------
5 template< class _TResult >
6 _TResult fpa::Base::Functors::GaussianCost< _TResult >::
7 Evaluate( const _TResult& x ) const
8 {
9   _TResult r = _TResult( 0 );
10   if( this->m_Model->GetNumberOfSamples( ) > this->m_SupportSize )
11   {
12     r = this->m_Model->SquaredMahalanobis( x );
13     if( r <= _TResult( 1 ) )
14       this->m_Model->AddSample( x );
15   }
16   else
17   {
18     this->m_Model->AddSample( x );
19     if( this->m_Model->GetNumberOfSamples( ) > 2 )
20       r = this->m_Model->SquaredMahalanobis( x );
21
22   } // fi
23   if( r < this->m_MinimumCost )
24     return( this->m_MinimumCost );
25   else
26     return( r );
27 }
28
29 // -------------------------------------------------------------------------
30 template< class _TResult >
31 fpa::Base::Functors::GaussianCost< _TResult >::
32 GaussianCost( )
33   : Superclass( ),
34     m_SupportSize( 30 ),
35     m_MinimumCost( _TResult( 1e-10 ) )
36 {
37   this->m_Model = TModel::New( );
38 }
39
40 // -------------------------------------------------------------------------
41 template< class _TResult >
42 fpa::Base::Functors::GaussianCost< _TResult >::
43 ~GaussianCost( )
44 {
45 }
46
47 #endif // __FPA__BASE__FUNCTORS__GAUSSIANCOST__HXX__
48
49 // eof - $RCSfile$