DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
CPositiveIrreducibleFraction.h
1
16
17
#pragma once
18
30
31
#if defined(CPositiveIrreducibleFraction_RECURSES)
32
#error Recursive header files inclusion detected in CPositiveIrreducibleFraction.h
33
#else
// defined(CPositiveIrreducibleFraction_RECURSES)
35
#define CPositiveIrreducibleFraction_RECURSES
36
37
#if !defined CPositiveIrreducibleFraction_h
39
#define CPositiveIrreducibleFraction_h
40
42
// Inclusions
43
#include <iostream>
44
#include <vector>
45
#include "DGtal/base/CBackInsertable.h"
46
#include "DGtal/base/CConstSinglePassRange.h"
47
#include "DGtal/kernel/CInteger.h"
49
50
namespace
DGtal
51
{
52
53
namespace
concepts
54
{
55
57
// class CPositiveIrreducibleFraction
160
template
<
typename
T>
161
struct
CPositiveIrreducibleFraction
162
:
boost::CopyConstructible
<T>,
boost::DefaultConstructible
<T>,
boost::Assignable
<T>,
CBackInsertable
<T>,
CConstSinglePassRange
<T>
163
164
{
165
// ----------------------- Concept checks ------------------------------
166
public
:
167
typedef
typename
T::Integer
Integer
;
168
typedef
typename
T::Quotient
Quotient
;
169
typedef
typename
T::value_type
value_type
;
170
typedef
typename
T::Value
Value
;
171
typedef
typename
T::ConstIterator
ConstIterator
;
172
typedef
typename
T::const_iterator
const_iterator
;
173
174
BOOST_CONCEPT_ASSERT
((
concepts::CInteger< Integer >
));
175
BOOST_CONCEPT_ASSERT
((
concepts::CInteger< Quotient >
));
176
BOOST_STATIC_ASSERT
((
concepts::ConceptUtils::SameType
<
value_type
, std::pair<Quotient,Quotient> >::value ));
177
BOOST_STATIC_ASSERT
((
concepts::ConceptUtils::SameType<value_type, Value >::value
));
178
179
BOOST_CONCEPT_USAGE
(
CPositiveIrreducibleFraction
)
180
{
181
concepts::ConceptUtils::sameType
(
myX
, T(
myP
,
myQ
) );
182
myX
.push_back(
myValue
);
183
myX
.pushBack(
myValue
);
184
checkConstConstraints
();
185
}
186
void
checkConstConstraints
()
const
187
{
188
concepts::ConceptUtils::sameType
(
myP
,
myX
.p() );
189
concepts::ConceptUtils::sameType
(
myQ
,
myX
.q() );
190
concepts::ConceptUtils::sameType
(
myU
,
myX
.u() );
191
concepts::ConceptUtils::sameType
(
myU
,
myX
.k() );
192
concepts::ConceptUtils::sameType
(
myBool
,
myX
.null() );
193
concepts::ConceptUtils::sameType
(
myX
,
myX
.left() );
194
concepts::ConceptUtils::sameType
(
myX
,
myX
.right() );
195
concepts::ConceptUtils::sameType
(
myBool
,
myX
.even() );
196
concepts::ConceptUtils::sameType
(
myBool
,
myX
.odd() );
197
concepts::ConceptUtils::sameType
(
myX
,
myX
.father() );
198
concepts::ConceptUtils::sameType
(
myX
,
myX
.father(
myU
) );
199
concepts::ConceptUtils::sameType
(
myX
,
myX
.previousPartial() );
200
concepts::ConceptUtils::sameType
(
myX
,
myX
.inverse() );
201
concepts::ConceptUtils::sameType
(
myX
,
myX
.partial(
myU
) );
202
concepts::ConceptUtils::sameType
(
myX
,
myX
.reduced(
myU
) );
203
myX
.getSplit(
myF1
,
myF2
);
204
myX
.getSplitBerstel(
myF1
,
myN1
,
myF2
,
myN2
);
205
myX
.getCFrac(
myQuots
);
206
concepts::ConceptUtils::sameType
(
myBool
,
myX
.equals(
myP
,
myQ
) );
207
concepts::ConceptUtils::sameType
(
myBool
,
myX
.lessThan(
myP
,
myQ
) );
208
concepts::ConceptUtils::sameType
(
myBool
,
myX
.moreThan(
myP
,
myQ
) );
209
concepts::ConceptUtils::sameType
(
myBool
,
myX
==
myY
);
210
concepts::ConceptUtils::sameType
(
myBool
,
myX
!=
myY
);
211
concepts::ConceptUtils::sameType
(
myBool
,
myX
<
myY
);
212
concepts::ConceptUtils::sameType
(
myBool
,
myX
>
myY
);
213
concepts::ConceptUtils::sameType
(
myIterator
,
myX
.begin() );
214
concepts::ConceptUtils::sameType
(
myIterator
,
myX
.end() );
215
}
216
// ------------------------- Private Data --------------------------------
217
private
:
218
T
myX
;
// do not require T to be default constructible.
219
T
myY
;
// do not require T to be default constructible.
220
Integer
myP
;
221
Integer
myQ
;
222
Quotient
myU
;
223
bool
myBool
;
224
mutable
Quotient
myN1
;
225
mutable
Quotient
myN2
;
226
mutable
T
myF1
;
227
mutable
T
myF2
;
228
mutable
std::vector<Quotient>
myQuots
;
229
std::pair<Quotient,Quotient>
myValue
;
230
ConstIterator
myIterator
;
231
// ------------------------- Internals ------------------------------------
232
private
:
233
234
};
// end of concept CPositiveIrreducibleFraction
235
236
}
// namespace concepts
237
238
}
// namespace DGtal
239
240
// //
242
243
#endif
// !defined CPositiveIrreducibleFraction_h
244
245
#undef CPositiveIrreducibleFraction_RECURSES
246
#endif
// else defined(CPositiveIrreducibleFraction_RECURSES)
DGtal::concepts::ConceptUtils::sameType
void sameType(const T &, const T &)
Definition
ConceptUtils.h:117
DGtal::concepts
Aim: Gathers several functions useful for concept checks.
Definition
CPositiveIrreducibleFraction.h:54
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
DGtal::concepts::CBackInsertable
Aim: Represents types for which a std::back_insert_iterator can be constructed with std::back_inserte...
Definition
CBackInsertable.h:95
DGtal::concepts::CConstSinglePassRange
Aim: Defines the concept describing a const single pass range.
Definition
CConstSinglePassRange.h:93
DGtal::concepts::CInteger
Aim: Concept checking for Integer Numbers. More precisely, this concept is a refinement of both CEucl...
Definition
CInteger.h:88
DGtal::concepts::CPositiveIrreducibleFraction
Aim: Defines positive irreducible fractions, i.e. fraction p/q, p and q non-negative integers,...
Definition
CPositiveIrreducibleFraction.h:164
DGtal::concepts::CPositiveIrreducibleFraction::myU
Quotient myU
Definition
CPositiveIrreducibleFraction.h:222
DGtal::concepts::CPositiveIrreducibleFraction::myBool
bool myBool
Definition
CPositiveIrreducibleFraction.h:223
DGtal::concepts::CPositiveIrreducibleFraction::Integer
T::Integer Integer
Definition
CPositiveIrreducibleFraction.h:167
DGtal::concepts::CPositiveIrreducibleFraction::checkConstConstraints
void checkConstConstraints() const
Definition
CPositiveIrreducibleFraction.h:186
DGtal::concepts::CPositiveIrreducibleFraction::const_iterator
T::const_iterator const_iterator
Definition
CPositiveIrreducibleFraction.h:172
DGtal::concepts::CPositiveIrreducibleFraction::myN1
Quotient myN1
Definition
CPositiveIrreducibleFraction.h:224
DGtal::concepts::CPositiveIrreducibleFraction::myX
T myX
Definition
CPositiveIrreducibleFraction.h:218
DGtal::concepts::CPositiveIrreducibleFraction::myQuots
std::vector< Quotient > myQuots
Definition
CPositiveIrreducibleFraction.h:228
DGtal::concepts::CPositiveIrreducibleFraction::myP
Integer myP
Definition
CPositiveIrreducibleFraction.h:220
DGtal::concepts::CPositiveIrreducibleFraction::value_type
T::value_type value_type
Definition
CPositiveIrreducibleFraction.h:169
DGtal::concepts::CPositiveIrreducibleFraction::myValue
std::pair< Quotient, Quotient > myValue
Definition
CPositiveIrreducibleFraction.h:229
DGtal::concepts::CPositiveIrreducibleFraction::myF1
T myF1
Definition
CPositiveIrreducibleFraction.h:226
DGtal::concepts::CPositiveIrreducibleFraction::Quotient
T::Quotient Quotient
Definition
CPositiveIrreducibleFraction.h:168
DGtal::concepts::CPositiveIrreducibleFraction::myQ
Integer myQ
Definition
CPositiveIrreducibleFraction.h:221
DGtal::concepts::CPositiveIrreducibleFraction::Value
T::Value Value
Definition
CPositiveIrreducibleFraction.h:170
DGtal::concepts::CPositiveIrreducibleFraction::BOOST_CONCEPT_ASSERT
BOOST_CONCEPT_ASSERT((concepts::CInteger< Integer >))
DGtal::concepts::CPositiveIrreducibleFraction::ConstIterator
T::ConstIterator ConstIterator
Definition
CPositiveIrreducibleFraction.h:171
DGtal::concepts::CPositiveIrreducibleFraction::myIterator
ConstIterator myIterator
Definition
CPositiveIrreducibleFraction.h:230
DGtal::concepts::CPositiveIrreducibleFraction::BOOST_CONCEPT_ASSERT
BOOST_CONCEPT_ASSERT((concepts::CInteger< Quotient >))
DGtal::concepts::CPositiveIrreducibleFraction::myF2
T myF2
Definition
CPositiveIrreducibleFraction.h:227
DGtal::concepts::CPositiveIrreducibleFraction::myY
T myY
Definition
CPositiveIrreducibleFraction.h:219
DGtal::concepts::CPositiveIrreducibleFraction::BOOST_STATIC_ASSERT
BOOST_STATIC_ASSERT((concepts::ConceptUtils::SameType< value_type, Value >::value))
DGtal::concepts::CPositiveIrreducibleFraction::myN2
Quotient myN2
Definition
CPositiveIrreducibleFraction.h:225
DGtal::concepts::CPositiveIrreducibleFraction::BOOST_CONCEPT_USAGE
BOOST_CONCEPT_USAGE(CPositiveIrreducibleFraction)
Definition
CPositiveIrreducibleFraction.h:179
DGtal::concepts::CPositiveIrreducibleFraction::BOOST_STATIC_ASSERT
BOOST_STATIC_ASSERT((concepts::ConceptUtils::SameType< value_type, std::pair< Quotient, Quotient > >::value))
DGtal::concepts::ConceptUtils::SameType
Definition
ConceptUtils.h:107
DGtal::concepts::ConceptUtils::SameType::value
static const bool value
Definition
ConceptUtils.h:107
boost::Assignable
Go to http://www.sgi.com/tech/stl/Assignable.html.
Definition
Boost.dox:32
boost::CopyConstructible
Go to http://www.sgi.com/tech/stl/CopyConstructible.html.
Definition
Boost.dox:34
boost::DefaultConstructible
Go to http://www.sgi.com/tech/stl/DefaultConstructible.html.
Definition
Boost.dox:30
src
DGtal
arithmetic
CPositiveIrreducibleFraction.h
Generated on
for DGtal by
1.18.0