DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
CPositiveIrreducibleFraction.h
1 
17 #pragma once
18 
31 #if defined(CPositiveIrreducibleFraction_RECURSES)
32 #error Recursive header files inclusion detected in CPositiveIrreducibleFraction.h
33 #else // defined(CPositiveIrreducibleFraction_RECURSES)
34 
35 #define CPositiveIrreducibleFraction_RECURSES
36 
37 #if !defined CPositiveIrreducibleFraction_h
38 
39 #define CPositiveIrreducibleFraction_h
40 
42 // Inclusions
43 #include <iostream>
44 #include <vector>
45 #include "DGtal/base/Common.h"
46 #include "DGtal/base/CBackInsertable.h"
47 #include "DGtal/base/CConstSinglePassRange.h"
48 #include "DGtal/kernel/CInteger.h"
49 #include "DGtal/kernel/CSignedInteger.h"
51 
52 namespace DGtal
53 {
54 
56 // class CPositiveIrreducibleFraction
159 template <typename T>
161  : boost::CopyConstructible<T>, boost::DefaultConstructible<T>, boost::Assignable<T>, DGtal::CBackInsertable<T>, DGtal::CConstSinglePassRange<T>
162 
163 {
164  // ----------------------- Concept checks ------------------------------
165 public:
166  typedef typename T::Integer Integer;
167  typedef typename T::Quotient Quotient;
168  typedef typename T::value_type value_type;
169  typedef typename T::Value Value;
170  typedef typename T::ConstIterator ConstIterator;
171  typedef typename T::const_iterator const_iterator;
172 
175  BOOST_STATIC_ASSERT(( ConceptUtils::SameType<value_type, std::pair<Quotient,Quotient> >::value ));
177 
179  {
180  ConceptUtils::sameType( myX, T( myP, myQ ) );
181  myX.push_back( myValue );
182  myX.pushBack( myValue );
184  }
186  {
191  ConceptUtils::sameType( myBool, myX.null() );
192  ConceptUtils::sameType( myX, myX.left() );
193  ConceptUtils::sameType( myX, myX.right() );
194  ConceptUtils::sameType( myBool, myX.even() );
196  ConceptUtils::sameType( myX, myX.father() );
197  ConceptUtils::sameType( myX, myX.father( myU ) );
198  ConceptUtils::sameType( myX, myX.previousPartial() );
199  ConceptUtils::sameType( myX, myX.inverse() );
200  ConceptUtils::sameType( myX, myX.partial( myU ) );
201  ConceptUtils::sameType( myX, myX.reduced( myU ) );
202  myX.getSplit( myF1, myF2 );
203  myX.getSplitBerstel( myF1, myN1, myF2, myN2 );
204  myX.getCFrac( myQuots );
205  ConceptUtils::sameType( myBool, myX.equals( myP, myQ ) );
206  ConceptUtils::sameType( myBool, myX.lessThan( myP, myQ ) );
207  ConceptUtils::sameType( myBool, myX.moreThan( myP, myQ ) );
209  ConceptUtils::sameType( myBool, myX != myY );
210  ConceptUtils::sameType( myBool, myX < myY );
211  ConceptUtils::sameType( myBool, myX > myY );
212  ConceptUtils::sameType( myIterator, myX.begin() );
213  ConceptUtils::sameType( myIterator, myX.end() );
214  }
215  // ------------------------- Private Datas --------------------------------
216 private:
217  T myX; // do not require T to be default constructible.
218  T myY; // do not require T to be default constructible.
222  bool myBool;
223  mutable Quotient myN1;
224  mutable Quotient myN2;
225  mutable T myF1;
226  mutable T myF2;
227  mutable std::vector<Quotient> myQuots;
228  std::pair<Quotient,Quotient> myValue;
230  // ------------------------- Internals ------------------------------------
231 private:
232 
233 }; // end of concept CPositiveIrreducibleFraction
234 
235 } // namespace DGtal
236 
237 // //
239 
240 #endif // !defined CPositiveIrreducibleFraction_h
241 
242 #undef CPositiveIrreducibleFraction_RECURSES
243 #endif // else defined(CPositiveIrreducibleFraction_RECURSES)