DGtal  0.9.2
ScalarFunctors.h
1 
17 #pragma once
18 
31 #if defined(ScalarFunctors_RECURSES)
32 #error Recursive header files inclusion detected in ScalarFunctors.h
33 #else // defined(ScalarFunctors_RECURSES)
34 
35 #define ScalarFunctors_RECURSES
36 
37 #if !defined ScalarFunctors_h
38 
39 #define ScalarFunctors_h
40 
42 // Inclusions
43 #include <iostream>
44 #include "DGtal/base/Common.h"
46 
47 namespace DGtal {
48  namespace functors {
49 
54  template <typename TScalar>
55  struct HatFunction {
56  typedef TScalar Scalar;
57  typedef Scalar argument_type;
58  typedef Scalar value_type;
59 
60  Scalar myV0;
61  Scalar myV0OverR;
62  Scalar myR;
63 
64  public:
65  HatFunction( Scalar v0, Scalar r )
66  : myV0( v0 ), myV0OverR( v0 / r ), myR( r ) {}
67  Scalar operator()( Scalar d ) const
68  { // d >= 0
69  ASSERT( d >= 0.0 );
70  if ( d >= myR ) return 0.0;
71  return myV0 - myV0OverR * d;
72  }
73  };
74 
79  template <typename TScalar>
81  typedef TScalar Scalar;
82  typedef Scalar argument_type;
83  typedef Scalar value_type;
84 
85  Scalar myV0;
86  Scalar myR;
87 
88  public:
89  BallConstantFunction( Scalar v0, Scalar r )
90  : myV0( v0 ), myR( r ) {}
91  Scalar operator()( Scalar d ) const
92  {// d >= 0
93  ASSERT( d >= 0.0 );
94  return ( d > myR ) ? 0.0 : myV0;
95  }
96  };
97 
98 
99  } // namespace functors
100 } // namespace DGtal
101 
102 
104 // Includes inline functions.
105 #include "DGtal/math/ScalarFunctors.ih"
106 
107 // //
109 
110 #endif // !defined ScalarFunctors_h
111 
112 #undef ScalarFunctors_RECURSES
113 #endif // else defined(ScalarFunctors_RECURSES)
DGtal is the top-level namespace which contains all DGtal functions and types.
Scalar operator()(Scalar d) const
Scalar operator()(Scalar d) const
HatFunction(Scalar v0, Scalar r)
BallConstantFunction(Scalar v0, Scalar r)