DGtal 1.3.0
Loading...
Searching...
No Matches
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)
35#define AvnaimEtAl2x2DetSignComputer_RECURSES
36
37#if !defined AvnaimEtAl2x2DetSignComputer_h
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
53namespace 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 < >
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)
Aim: Class that provides a way of computing the sign of the determinant of a 2x2 matrix from its four...
BOOST_CONCEPT_ASSERT((concepts::CBoundedNumber< ArgumentInteger >))
Integer computation(const Integer &aA, const Integer &aB, const Integer &aX, const Integer &aY) const
Integer recursiveComputation(const Integer &aA, const Integer &aB, const Integer &aX, const Integer &aY) const
ResultInteger operator()(const ArgumentInteger &aA, const ArgumentInteger &aB, const ArgumentInteger &aX, const ArgumentInteger &aY)
BOOST_STATIC_CONSTANT(unsigned int, exponent=std::numeric_limits< Integer >::digits)
void init(const ArgumentInteger &aA, const ArgumentInteger &aB)
void selfDisplay(std::ostream &out) const
BOOST_CONCEPT_ASSERT((concepts::CEuclideanRing< ArgumentInteger >))
ResultInteger operator()(const ArgumentInteger &aU, const ArgumentInteger &aV) const
int quadrant(const Integer &aX, const Integer &aY) const
BOOST_STATIC_CONSTANT(unsigned int, base=std::numeric_limits< Integer >::radix)
DGtal is the top-level namespace which contains all DGtal functions and types.
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
Aim: The concept CBoundedNumber specifies what are the bounded numbers. Models of this concept should...
Aim: Defines the mathematical concept equivalent to a unitary commutative ring with a division operat...
Aim: Concept checking for Integer Numbers. More precisely, this concept is a refinement of both CEucl...
Definition: CInteger.h:88
static double compute(const double &a, const double &b)
static float compute(const float &a, const float &b)
static double compute(const double &a, const double &b)
Aim: Small stucture that provides a static method returning the Euclidean division of two integers.
static TNumber compute(const TNumber &a, const TNumber &b)