DGtal  1.1.0
AvnaimEtAl2x2DetSignComputer.h
1 
17 #pragma once
18 
31 #if defined(AvnaimEtAl2x2DetSignComputer_RECURSES)
32 #error Recursive header files inclusion detected in AvnaimEtAl2x2DetSignComputer.h
33 #else // defined(AvnaimEtAl2x2DetSignComputer_RECURSES)
34 
35 #define AvnaimEtAl2x2DetSignComputer_RECURSES
36 
37 #if !defined AvnaimEtAl2x2DetSignComputer_h
38 
39 #define AvnaimEtAl2x2DetSignComputer_h
40 
42 // Inclusions
43 #include <iostream>
44 #include "DGtal/base/Common.h"
45 #include "DGtal/base/ExpressionTemplates.h"
46 
47 #include "DGtal/kernel/NumberTraits.h"
48 #include "DGtal/kernel/CInteger.h"
49 #include "DGtal/kernel/CEuclideanRing.h"
50 #include "DGtal/kernel/CBoundedNumber.h"
52 
53 namespace DGtal
54 {
55 
56  namespace detail
57  {
58 
70  template <typename TNumber>
72  {
79  static TNumber compute(const TNumber& a, const TNumber& b)
80  {
81  BOOST_CONCEPT_ASSERT(( concepts::CInteger<TNumber> ));
82  return a / b;
83  }
84  };
85  //specialization for float and double
86  template < >
88  {
89  static float compute(const float& a, const float& b)
90  {
91  return std::floor(a / b);
92  }
93  };
94  template < >
95  struct EuclideanDivisionHelper<double>
96  {
97  static double compute(const double& a, const double& b)
98  {
99  return std::floor(a / b);
100  }
101  };
102  template < >
103  struct EuclideanDivisionHelper<long double>
104  {
105  static double compute(const double& a, const double& b)
106  {
107  return std::floor(a / b);
108  }
109  };
110  }
111 
113  // template class AvnaimEtAl2x2DetSignComputer
143  template <typename TInteger>
145  {
146  // ----------------------- Types ------------------------------------
147  public:
151  typedef TInteger ArgumentInteger;
154 
163 
177 
178  // ----------------------- Static members ---------------------------------
179  public:
184  BOOST_STATIC_CONSTANT( unsigned int, base = std::numeric_limits<Integer>::radix );
189  BOOST_STATIC_CONSTANT( unsigned int, exponent = std::numeric_limits<Integer>::digits );
190 
191  // ----------------------- Standard services ------------------------------
192  public:
197 
198 
199  // ----------------------- Interface --------------------------------------
200  public:
201 
208  void init(const ArgumentInteger& aA, const ArgumentInteger& aB);
209 
220 
232  const ArgumentInteger& aX, const ArgumentInteger& aY);
233 
238  void selfDisplay ( std::ostream & out ) const;
239 
244  bool isValid() const;
245 
246  // ------------------------- Internals ------------------------------------
247  private:
248 
259  int quadrant(const Integer& aX, const Integer& aY) const;
260 
274  Integer computation(const Integer& aA, const Integer& aB,
275  const Integer& aX, const Integer& aY) const;
276 
292  const Integer& aX, const Integer& aY) const;
293 
294  // ------------------------- Private Datas --------------------------------
295  private:
296 
312 
313  }; // end of class AvnaimEtAl2x2DetSignComputer
314 
315 
322  template <typename TInteger>
323  std::ostream&
324  operator<< ( std::ostream & out, const AvnaimEtAl2x2DetSignComputer<TInteger> & object );
325 
326 } // namespace DGtal
327 
328 
330 // Includes inline functions.
331 #include "DGtal/geometry/tools/determinant/AvnaimEtAl2x2DetSignComputer.ih"
332 
333 // //
335 
336 #endif // !defined AvnaimEtAl2x2DetSignComputer_h
337 
338 #undef AvnaimEtAl2x2DetSignComputer_RECURSES
339 #endif // else defined(AvnaimEtAl2x2DetSignComputer_RECURSES)
DGtal::AvnaimEtAl2x2DetSignComputer::operator()
ResultInteger operator()(const ArgumentInteger &aA, const ArgumentInteger &aB, const ArgumentInteger &aX, const ArgumentInteger &aY)
DGtal::AvnaimEtAl2x2DetSignComputer::init
void init(const ArgumentInteger &aA, const ArgumentInteger &aB)
DGtal::concepts::CInteger
Aim: Concept checking for Integer Numbers. More precisely, this concept is a refinement of both CEucl...
Definition: CInteger.h:88
DGtal::AvnaimEtAl2x2DetSignComputer::Value
ResultInteger Value
Definition: AvnaimEtAl2x2DetSignComputer.h:172
DGtal::AvnaimEtAl2x2DetSignComputer::result_type
ResultInteger result_type
Definition: AvnaimEtAl2x2DetSignComputer.h:176
DGtal::AvnaimEtAl2x2DetSignComputer::myA
Integer myA
Definition: AvnaimEtAl2x2DetSignComputer.h:301
DGtal::AvnaimEtAl2x2DetSignComputer::BOOST_CONCEPT_ASSERT
BOOST_CONCEPT_ASSERT((concepts::CEuclideanRing< ArgumentInteger >))
DGtal::concepts::CBoundedNumber
Aim: The concept CBoundedNumber specifies what are the bounded numbers. Models of this concept should...
Definition: CBoundedNumber.h:97
DGtal::AvnaimEtAl2x2DetSignComputer::argument_type
ArgumentInteger argument_type
Definition: AvnaimEtAl2x2DetSignComputer.h:162
DGtal::AvnaimEtAl2x2DetSignComputer::ResultInteger
Integer ResultInteger
Definition: AvnaimEtAl2x2DetSignComputer.h:168
DGtal::AvnaimEtAl2x2DetSignComputer::AvnaimEtAl2x2DetSignComputer
AvnaimEtAl2x2DetSignComputer()
DGtal::detail::EuclideanDivisionHelper< double >::compute
static double compute(const double &a, const double &b)
Definition: AvnaimEtAl2x2DetSignComputer.h:97
DGtal::AvnaimEtAl2x2DetSignComputer::operator()
ResultInteger operator()(const ArgumentInteger &aU, const ArgumentInteger &aV) const
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition: ClosedIntegerHalfPlane.h:49
DGtal::AvnaimEtAl2x2DetSignComputer::recursiveComputation
Integer recursiveComputation(const Integer &aA, const Integer &aB, const Integer &aX, const Integer &aY) const
DGtal::AvnaimEtAl2x2DetSignComputer::myB
Integer myB
Definition: AvnaimEtAl2x2DetSignComputer.h:306
DGtal::AvnaimEtAl2x2DetSignComputer::myMax
Integer myMax
Definition: AvnaimEtAl2x2DetSignComputer.h:311
DGtal::AvnaimEtAl2x2DetSignComputer
Aim: Class that provides a way of computing the sign of the determinant of a 2x2 matrix from its four...
Definition: AvnaimEtAl2x2DetSignComputer.h:145
DGtal::concepts::CEuclideanRing
Aim: Defines the mathematical concept equivalent to a unitary commutative ring with a division operat...
Definition: CEuclideanRing.h:88
DGtal::detail::EuclideanDivisionHelper< float >::compute
static float compute(const float &a, const float &b)
Definition: AvnaimEtAl2x2DetSignComputer.h:89
DGtal::AvnaimEtAl2x2DetSignComputer::isValid
bool isValid() const
DGtal::operator<<
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
DGtal::AvnaimEtAl2x2DetSignComputer::BOOST_CONCEPT_ASSERT
BOOST_CONCEPT_ASSERT((concepts::CBoundedNumber< ArgumentInteger >))
DGtal::detail::EuclideanDivisionHelper
Aim: Small stucture that provides a static method returning the Euclidean division of two integers.
Definition: AvnaimEtAl2x2DetSignComputer.h:72
DGtal::AvnaimEtAl2x2DetSignComputer::computation
Integer computation(const Integer &aA, const Integer &aB, const Integer &aX, const Integer &aY) const
DGtal::detail::EuclideanDivisionHelper::compute
static TNumber compute(const TNumber &a, const TNumber &b)
Definition: AvnaimEtAl2x2DetSignComputer.h:79
DGtal::AvnaimEtAl2x2DetSignComputer::ArgumentInteger
TInteger ArgumentInteger
Definition: AvnaimEtAl2x2DetSignComputer.h:151
DGtal::AvnaimEtAl2x2DetSignComputer::selfDisplay
void selfDisplay(std::ostream &out) const
DGtal::detail::EuclideanDivisionHelper< long double >::compute
static double compute(const double &a, const double &b)
Definition: AvnaimEtAl2x2DetSignComputer.h:105
DGtal::AvnaimEtAl2x2DetSignComputer::BOOST_STATIC_CONSTANT
BOOST_STATIC_CONSTANT(unsigned int, base=std::numeric_limits< Integer >::radix)
DGtal::AvnaimEtAl2x2DetSignComputer::Integer
ArgumentInteger Integer
Definition: AvnaimEtAl2x2DetSignComputer.h:158
DGtal::AvnaimEtAl2x2DetSignComputer::BOOST_STATIC_CONSTANT
BOOST_STATIC_CONSTANT(unsigned int, exponent=std::numeric_limits< Integer >::digits)
DGtal::AvnaimEtAl2x2DetSignComputer::quadrant
int quadrant(const Integer &aX, const Integer &aY) const