Loading [MathJax]/extensions/TeX/AMSsymbols.js
DGtal 2.0.0
IntegerComputer.h
1
16
17#pragma once
18
30
31#if defined(IntegerComputer_RECURSES)
32#error Recursive header files inclusion detected in IntegerComputer.h
33#else // defined(IntegerComputer_RECURSES)
35#define IntegerComputer_RECURSES
36
37#if !defined IntegerComputer_h
39#define IntegerComputer_h
40
42// Inclusions
43#include <iostream>
44#include "DGtal/base/Common.h"
45#include "DGtal/kernel/NumberTraits.h"
46#include "DGtal/kernel/CUnsignedNumber.h"
47#include "DGtal/kernel/CIntegralNumber.h"
48#include "DGtal/kernel/CInteger.h"
49#include "DGtal/kernel/SpaceND.h"
51
52namespace DGtal
53{
54
56 // template class IntegerComputer
81 template <typename TInteger>
83 {
84 // ----------------------- Associated types ------------------------------
85 public:
89
92
97
101
102 // ----------------------- Standard services ------------------------------
103 public:
104
109
119
128 IntegerComputer ( const Self & other );
129
139 Self & operator= ( const Self & other );
140
141
142 // ----------------------- Integer services ------------------------------
143 public:
144
149 static bool isZero( IntegerParamType a );
150
155 static bool isNotZero( IntegerParamType a );
156
161 static bool isPositive( IntegerParamType a );
162
167 static bool isNegative( IntegerParamType a );
168
174
180
186
193
201
208
216
231
239
247
257 IntegerParamType na, IntegerParamType nb ) const;
258
268
278
288
299 Integer getCFrac( std::vector<Integer> & quotients,
316 template <typename OutputIterator>
317 Integer getCFrac( OutputIterator outIt,
319
330 Point2I convergent( const std::vector<Integer> & quotients,
331 unsigned int k ) const;
332
333 // ----------------------- Point2I services ------------------------------
334 public:
340 void reduce( Vector2I & p ) const ;
341
342
350 Integer crossProduct( const Vector2I & u, const Vector2I & v) const;
351
360 const Vector2I & u, const Vector2I & v) const;
361
369 Integer dotProduct( const Vector2I & u, const Vector2I & v ) const;
370
379 const Vector2I & u, const Vector2I & v) const;
380
403 IntegerParamType c ) const;
404
420 const Vector2I & p,
421 const Vector2I & u,
422 const Vector2I & N,
423 IntegerParamType c ) const;
424
451 const Point2I & A, const Vector2I & u,
452 const Vector2I & N, IntegerParamType c,
453 const Vector2I & N2, IntegerParamType c2,
454 bool compute_v = true ) const;
455
456 // ----------------------- Point3I services ------------------------------
457 public:
458
464 void reduce( Vector3I & p ) const;
465
473 Integer dotProduct( const Vector3I & u, const Vector3I & v) const;
474
483 const Vector3I & u, const Vector3I & v) const;
484
485
486 // ----------------------- Interface --------------------------------------
487 public:
488
493 void selfDisplay ( std::ostream & out ) const;
494
499 bool isValid() const;
500
501 // ------------------------- Protected Datas ------------------------------
502 private:
503 // ------------------------- Private Datas --------------------------------
504 private:
505
507 mutable Integer _m_a;
509 mutable Integer _m_b;
511 mutable Integer _m_a0;
513 mutable Integer _m_a1;
515 mutable Integer _m_q;
517 mutable Integer _m_r;
521 mutable std::vector<Integer> _m_bezout[ 4 ];
523 mutable Vector2I _m_v;
529 mutable Integer _m_c0;
531 mutable Integer _m_c1;
533 mutable Integer _m_c2;
534
535 // ------------------------- Hidden services ------------------------------
536 protected:
537
538
539 // ------------------------- Internals ------------------------------------
540 private:
541
542 }; // end of class IntegerComputer
543
544
551 template <typename TInteger>
552 std::ostream&
553 operator<< ( std::ostream & out, const IntegerComputer<TInteger> & object );
554
555} // namespace DGtal
556
557
559// Includes inline functions.
560#include "DGtal/arithmetic/IntegerComputer.ih"
561
562// //
564
565#endif // !defined IntegerComputer_h
566
567#undef IntegerComputer_RECURSES
568#endif // else defined(IntegerComputer_RECURSES)
Aim: This class gathers several types and methods to make computation with integers.
Integer getCFrac(std::vector< Integer > &quotients, IntegerParamType a, IntegerParamType b) const
SpaceND< 3, Integer >::Vector Vector3I
void reduce(Vector3I &p) const
static Integer staticGcd(IntegerParamType a, IntegerParamType b)
void getGcd(Integer &g, IntegerParamType a, IntegerParamType b) const
static Integer max(IntegerParamType a, IntegerParamType b, IntegerParamType c)
NumberTraits< TInteger >::SignedVersion Integer
Integer crossProduct(const Vector2I &u, const Vector2I &v) const
static bool isPositiveOrZero(IntegerParamType a)
Integer getCFrac(OutputIterator outIt, IntegerParamType a, IntegerParamType b) const
IntegerComputer< TInteger > Self
static bool isZero(IntegerParamType a)
static Integer min(IntegerParamType a, IntegerParamType b, IntegerParamType c)
static Integer abs(IntegerParamType a)
std::vector< Integer > _m_bezout[4]
Integer ceilDiv(IntegerParamType na, IntegerParamType nb) const
NumberTraits< TInteger >::UnsignedVersion UnsignedInteger
void reduce(Vector2I &p) const
SpaceND< 2, Integer >::Vector Vector2I
static bool isNegativeOrZero(IntegerParamType a)
Integer dotProduct(const Vector2I &u, const Vector2I &v) const
SpaceND< 2, Integer >::Point Point2I
static bool isNotZero(IntegerParamType a)
BOOST_CONCEPT_ASSERT((concepts::CInteger< Integer >))
void getDotProduct(Integer &dp, const Vector2I &u, const Vector2I &v) const
Point2I convergent(const std::vector< Integer > &quotients, unsigned int k) const
Vector2I extendedEuclid(IntegerParamType a, IntegerParamType b, IntegerParamType c) const
void getCrossProduct(Integer &cp, const Vector2I &u, const Vector2I &v) const
static Integer min(IntegerParamType a, IntegerParamType b)
void getCoefficientIntersection(Integer &fl, Integer &ce, const Vector2I &p, const Vector2I &u, const Vector2I &N, IntegerParamType c) const
void selfDisplay(std::ostream &out) const
NumberTraits< UnsignedInteger >::ParamType UnsignedIntegerParamType
NumberTraits< Integer >::ParamType IntegerParamType
void getDotProduct(Integer &dp, const Vector3I &u, const Vector3I &v) const
void getValidBezout(Vector2I &v, const Point2I &A, const Vector2I &u, const Vector2I &N, IntegerParamType c, const Vector2I &N2, IntegerParamType c2, bool compute_v=true) const
static bool isPositive(IntegerParamType a)
void getFloorCeilDiv(Integer &fl, Integer &ce, IntegerParamType na, IntegerParamType nb) const
IntegerComputer(const Self &other)
void getEuclideanDiv(Integer &q, Integer &r, IntegerParamType a, IntegerParamType b) const
static bool isNegative(IntegerParamType a)
BOOST_CONCEPT_ASSERT((concepts::CIntegralNumber< UnsignedInteger >))
Integer dotProduct(const Vector3I &u, const Vector3I &v) const
Integer gcd(IntegerParamType a, IntegerParamType b) const
SpaceND< 3, Integer >::Point Point3I
static Integer max(IntegerParamType a, IntegerParamType b)
Integer floorDiv(IntegerParamType na, IntegerParamType nb) const
BOOST_CONCEPT_ASSERT((concepts::CUnsignedNumber< UnsignedInteger >))
Self & operator=(const Self &other)
PointVector< dim, Integer > Point
Points in DGtal::SpaceND.
Definition SpaceND.h:110
PointVector< dim, Integer > Vector
Vectors in DGtal::SpaceND.
Definition SpaceND.h:113
DGtal is the top-level namespace which contains all DGtal functions and types.
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
boost::call_traits< T >::param_type ParamType
Aim: Concept checking for Integer Numbers. More precisely, this concept is a refinement of both CEucl...
Definition CInteger.h:88
Aim: Concept checking for Integral Numbers. Models of this concept should be listed in NumberTraits c...
Aim: Concept checking for Unsigned numbers. Models of this concept should be listed in NumberTraits c...