]> Creatis software - FrontAlgorithms.git/blob - libs/fpa/Base/Functors/Inverse.hxx
...
[FrontAlgorithms.git] / libs / fpa / Base / Functors / Inverse.hxx
1 #ifndef __fpa__Base__Functors__Inverse__hxx__
2 #define __fpa__Base__Functors__Inverse__hxx__
3
4 // -------------------------------------------------------------------------
5 template< class _TInput, class _TOutput >
6 typename fpa::Base::Functors::Inverse< _TInput, _TOutput >::
7 TOutput fpa::Base::Functors::Inverse< _TInput, _TOutput >::
8 Evaluate( const TInput& x ) const
9 {
10   TInput sign = TInput( ( x < TInput( 0 ) )? -1: 1 );
11   TOutput y = TOutput( 1 ) / ( TOutput( 1 ) + TOutput( x * sign ) );
12   if( sign < TInput( 0 ) )
13     return( y * this->m_NegativeValue );
14   else
15     return( y );
16 }
17
18 // -------------------------------------------------------------------------
19 template< class _TInput, class _TOutput >
20 fpa::Base::Functors::Inverse< _TInput, _TOutput >::
21 Inverse( )
22   : Superclass( ),
23     m_NegativeValue( _TOutput( -1 ) )
24 {
25 }
26
27 // -------------------------------------------------------------------------
28 template< class _TInput, class _TOutput >
29 fpa::Base::Functors::Inverse< _TInput, _TOutput >::
30 ~Inverse( )
31 {
32 }
33
34 #endif // __fpa__Base__Functors__Inverse__hxx__
35
36 // eof - $RCSfile$