DGtal 2.1.0
Loading...
Searching...
No Matches
testLighterSternBrocot.cpp File Reference
#include <cstdlib>
#include <iostream>
#include <vector>
#include <iterator>
#include <map>
#include "DGtal/base/Common.h"
#include "DGtal/kernel/CPointPredicate.h"
#include "DGtal/arithmetic/CPositiveIrreducibleFraction.h"
#include "DGtal/arithmetic/IntegerComputer.h"
#include "DGtal/arithmetic/LighterSternBrocot.h"
#include "DGtal/arithmetic/LightSternBrocot.h"
#include "DGtal/arithmetic/Pattern.h"
#include "DGtal/arithmetic/StandardDSLQ0.h"
#include "DGtal/geometry/curves/ArithmeticalDSSComputer.h"
Include dependency graph for testLighterSternBrocot.cpp:

Go to the source code of this file.

Functions

template<typename Quotient >
bool equalCFrac (const std::vector< Quotient > &c1, const std::vector< Quotient > &c2)
 
template<typename SB >
bool testReducedFraction ()
 
template<typename SB >
bool testInitFraction ()
 
template<typename SB >
bool testPattern ()
 
template<typename Fraction >
bool testStandardDSLQ0 ()
 
template<typename DSL >
bool checkSubStandardDSLQ0 (const DSL &D, const typename DSL::Point &A, const typename DSL::Point &B)
 
template<typename Fraction >
bool testSubStandardDSLQ0 ()
 
bool testLighterSternBrocot ()
 
template<typename SB >
bool testContinuedFraction ()
 
template<typename SB >
bool testContinuedFractions ()
 
template<typename LSB >
bool testTrivial (const string &lsb)
 
template<typename SB >
bool testAncestors ()
 
int main (int, char **)
 

Detailed Description

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Author
Jacques-Olivier Lachaud (jacqu.nosp@m.es-o.nosp@m.livie.nosp@m.r.la.nosp@m.chaud.nosp@m.@uni.nosp@m.v-sav.nosp@m.oie..nosp@m.fr ) Laboratory of Mathematics (CNRS, UMR 5127), University of Savoie, France
Date
2012/03/05

Functions for testing class LighterSternBrocot.

This file is part of the DGtal library.

Definition in file testLighterSternBrocot.cpp.

Function Documentation

◆ checkSubStandardDSLQ0()

template<typename DSL >
bool checkSubStandardDSLQ0 ( const DSL &  D,
const typename DSL::Point A,
const typename DSL::Point B 
)

Definition at line 620 of file testLighterSternBrocot.cpp.

623{
624 typedef typename DSL::Integer Integer;
625 typedef typename DSL::ConstIterator ConstIterator;
627
628 DSL S = D.reversedSmartDSS( A, B );
629 ConstIterator it = D.begin( A );
630 ConstIterator it_end = D.end( B );
631 ADSS dss;
632 dss.init( it );
633 while ( ( dss.end() != it_end )
634 && ( dss.extendFront() ) ) {}
635 bool ok = S.a() == dss.a()
636 && S.b() == dss.b()
637 && S.mu() == dss.mu();
638 if ( ! ok )
639 {
640 trace.info() << "-------------------------------------------------------"
641 << std::endl;
642 trace.info() << "D = " << D // << " U1=" << U1 << " U2=" << U2
643 << " " << D.pattern().rE() << endl;
644 trace.info() << "S(" << A << "," << B << ") = "
645 << S << " " << S.pattern() << endl;
646 trace.info() << "ArithDSS = " << dss << std::endl;
647 }
648 // if ( ok )
649 // trace.info() << "========================== OK =========================";
650 // else
651 // trace.info() << "eeeeeeeeeeeeeeeeeeeeeeeeee KO eeeeeeeeeeeeeeeeeeeeeeeee";
652 // std::cerr << std::endl;
653 return ok;
654}
Aim: This class is a wrapper around ArithmeticalDSS that is devoted to the dynamic recognition of dig...
ConstIterator begin() const
std::ostream & info()
MyDigitalSurface::ConstIterator ConstIterator
Trace trace

References DGtal::ArithmeticalDSSComputer< TIterator, TInteger, adjacency >::begin(), DGtal::Trace::info(), and DGtal::trace.

◆ equalCFrac()

template<typename Quotient >
bool equalCFrac ( const std::vector< Quotient > &  c1,
const std::vector< Quotient > &  c2 
)

Definition at line 56 of file testLighterSternBrocot.cpp.

57{
58 auto s = c1.size() < c2.size() ? c1.size() : c2.size();
59 if ( ( s != c1.size() ) && ( c1.back() != NumberTraits<Quotient>::ONE ) )
60 return false;
61 if ( ( s != c2.size() ) && ( c2.back() != NumberTraits<Quotient>::ONE ) )
62 return false;
63 for ( unsigned int i = 0; i < s; ++i )
64 {
65 Quotient q1 = c1[ i ];
66 if ( ( s != c1.size() ) && ( i == s - 1 ) ) q1 += c1.back();
67 Quotient q2 = c2[ i ];
68 if ( ( s != c2.size() ) && ( i == s - 1 ) ) q2 += c2.back();
69 if ( q1 != q2 ) return false;
70 }
71 return true;
72}
Aim: The traits class for all models of Cinteger.

Referenced by testContinuedFraction().

◆ main()

int main ( int  ,
char **   
)

Definition at line 850 of file testLighterSternBrocot.cpp.

851{
856 typedef SB::Fraction Fraction;
857 typedef Fraction::ConstIterator ConstIterator;
858
860 BOOST_CONCEPT_ASSERT(( boost::InputIterator< ConstIterator > ));
861
862 testTrivial<SB>( "LrSB" );
863 testTrivial<SB2>( "LSB" );
864 testTrivial<SB3>( "SB" );
865
866 trace.beginBlock ( "Testing class LighterSternBrocot" );
867 bool res = testLighterSternBrocot()
868 && testPattern<SB>()
869 && testSubStandardDSLQ0<Fraction>()
870 && testContinuedFractions<SB>()
871 && testAncestors<SB>();
872 trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
873 trace.endBlock();
874
875 return res ? 0 : 1;
876}
Aim: The Stern-Brocot tree is the tree of irreducible fractions. This class allows to construct it pr...
Aim: The Stern-Brocot tree is the tree of irreducible fractions. This class allows to construct it pr...
Aim: The Stern-Brocot tree is the tree of irreducible fractions. This class allows to construct it pr...
Definition SternBrocot.h:78
void beginBlock(const std::string &keyword="")
std::ostream & emphase()
double endBlock()
std::int32_t int32_t
signed 32-bit integer.
Definition BasicTypes.h:71
std::int64_t int64_t
signed 94-bit integer.
Definition BasicTypes.h:73
Aim: Defines positive irreducible fractions, i.e. fraction p/q, p and q non-negative integers,...
Go to http://www.sgi.com/tech/stl/InputIterator.html.
Definition Boost.dox:36
bool testLighterSternBrocot()

References DGtal::Trace::beginBlock(), DGtal::Trace::emphase(), DGtal::Trace::endBlock(), testLighterSternBrocot(), and DGtal::trace.

◆ testAncestors()

template<typename SB >
bool testAncestors ( )

Bug report of I. Sivignon.

Definition at line 828 of file testLighterSternBrocot.cpp.

829{
830 typedef typename SB::Fraction Fraction;
831 typedef StandardDSLQ0<Fraction> DSL;
832 typedef typename DSL::Point Point;
833
834 // Instanciation d'un DSL
835 DSL D(1077,1495,6081);
836
837 // Definition du sous-segment [AB] et calcul des caractéristiques
838 Point A(3,-3);
839 Point B(4,-2);
840 ASSERT( D( A ) && "Point A belongs to D." );
841 ASSERT( D( B ) && "Point A belongs to D." );
842 DSL D1 = D.reversedSmartDSS(A,B); // may raise an assert.
843 std::cerr << D1 << std::endl;
844 return D1.slope() == Fraction( 1, 1 );
845}
Aim: Represents a digital straight line with slope in the first quadrant (Q0: x >= 0,...
MyPointD Point

◆ testContinuedFraction()

template<typename SB >
bool testContinuedFraction ( )

Definition at line 737 of file testLighterSternBrocot.cpp.

738{
739 typedef typename SB::Quotient Quotient;
740 typedef typename SB::Fraction::ConstIterator ConstIterator;
741 typedef typename SB::Fraction Fraction;
742
743 Fraction f;
744 std::vector<Quotient> quotients;
745 std::vector<Quotient> qcfrac;
746 std::back_insert_iterator< Fraction > itout =
747 std::back_inserter( f );
748 unsigned int size = ( rand() % 20 ) + 10;
749 for ( unsigned int i = 0; i < size; ++i )
750 {
751 Quotient q = ( i == 0 )
752 ? ( rand() % 5 )
753 : ( rand() % 5 ) + 1;
754 *itout++ = std::make_pair( q, (Quotient) i );
755 quotients.push_back( q );
756 }
757 for ( ConstIterator it = f.begin(), it_end = f.end();
758 it != it_end; ++it )
759 qcfrac.push_back( (*it).first );
760 // f.getCFrac( qcfrac );
761 bool ok = equalCFrac( quotients, qcfrac );
762
763 trace.info() << ( ok ? "(OK)" : "(ERR)" );
764 for ( unsigned int i = 0; i < quotients.size(); ++i )
765 std::cerr << " " << quotients[ i ];
766 trace.info() << std::endl;
767 trace.info() << " f=";
768 f.selfDisplay( std::cerr );
769 trace.info() << std::endl;
770 return ok;
771}
bool equalCFrac(const std::vector< Quotient > &c1, const std::vector< Quotient > &c2)

References equalCFrac(), DGtal::Trace::info(), and DGtal::trace.

◆ testContinuedFractions()

template<typename SB >
bool testContinuedFractions ( )

Definition at line 774 of file testLighterSternBrocot.cpp.

775{
776 unsigned int nbtests = 1000;
777 unsigned int nbok = 0;
778 unsigned int nb = 0;
779 trace.beginBlock ( "Testing block: continued fraction." );
780 for ( unsigned int i = 0; i < nbtests; ++i )
781 {
782 ++nb; nbok += testContinuedFraction<SB>() ? 1 : 0;
783 trace.info() << "(" << nbok << "/" << nb << ")"
784 << " continued fractions." << std::endl;
785 }
786 trace.endBlock();
787 return nbok == nb;
788}

References DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), DGtal::Trace::info(), and DGtal::trace.

◆ testInitFraction()

template<typename SB >
bool testInitFraction ( )

Definition at line 127 of file testLighterSternBrocot.cpp.

128{
129 typedef typename SB::Integer Integer;
130 typedef typename SB::Fraction Fraction;
131 unsigned int nbok = 0;
132 unsigned int nb = 0;
133 Integer p = ( rand() % 10000 ) + 1;
134 Integer q = ( rand() % 10000 ) + 1;
135 trace.beginBlock ( "Testing block: init fraction." );
136 trace.info() << "Init p / q = " << p << " / " << q << std::endl;
138 Integer g = ic.gcd( p, q );
139 p /= g;
140 q /= g;
141 Fraction f1 = SB::fraction( p, q );
142 trace.info() << "p / q = " << p << " / " << q << std::endl;
143 trace.info() << "f1 = ";
144 SB::display( trace.info(), f1 );
145 trace.info() << std::endl;
146 nbok += ( ( p == f1.p() ) && ( q == f1.q() ) ) ? 1 : 0;
147 ++nb;
148 trace.info() << "(" << nbok << "/" << nb << ") "
149 << "( ( p == f1.p() ) && ( q == f1.q() ) )"
150 << std::endl;
151 trace.info() << "- nbFractions = " << SB::instance().nbFractions << std::endl;
152 trace.endBlock();
153
154 return nbok == nb;
155}
Aim: This class gathers several types and methods to make computation with integers.
Integer gcd(IntegerParamType a, IntegerParamType b) const

References DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), DGtal::IntegerComputer< TInteger >::gcd(), DGtal::Trace::info(), and DGtal::trace.

◆ testLighterSternBrocot()

bool testLighterSternBrocot ( )

Example of a test. To be completed.

Definition at line 703 of file testLighterSternBrocot.cpp.

704{
705 unsigned int nbtests = 10;
706 unsigned int nbok = 0;
707 unsigned int nb = 0;
710 trace.beginBlock ( "Testing block: init fractions." );
711 for ( unsigned int i = 0; i < nbtests; ++i )
712 {
713 nbok += testInitFraction<SB>() ? 1 : 0;
714 nb++;
715 }
716 trace.info() << "(" << nbok << "/" << nb << ") init fractions." << endl;
717 trace.endBlock();
718
719 trace.beginBlock ( "Testing block: reduced fractions." );
720 for ( unsigned int i = 0; i < nbtests; ++i )
721 {
722 nbok += testReducedFraction<SB>() ? 1 : 0;
723 nb++;
724 }
725 trace.info() << "(" << nbok << "/" << nb << ") reduced fractions." << endl;
726 trace.endBlock();
727
728 trace.beginBlock ( "Testing block: number of fractions." );
729 trace.info() << "- nbFractions = " << SB::instance().nbFractions << endl;
730 trace.endBlock();
731
732 return nbok == nb;
733}
boost::multiprecision::number< boost::multiprecision::cpp_int_backend<>, boost::multiprecision::et_off > BigInteger
Definition BasicTypes.h:75

References DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), DGtal::Trace::info(), and DGtal::trace.

Referenced by main().

◆ testPattern()

template<typename SB >
bool testPattern ( )

Definition at line 158 of file testLighterSternBrocot.cpp.

159{
160 typedef typename SB::Integer Integer;
161 typedef typename SB::Quotient Quotient;
162 typedef typename SB::Fraction Fraction;
163 typedef Pattern<Fraction> MyPattern;
164 typedef typename MyPattern::Vector2I Vector2I;
165 unsigned int nbok = 0;
166 unsigned int nb = 0;
167 Integer p = ( rand() % 10000 ) + 1;
168 Integer q = ( rand() % 10000 ) + 1;
169 MyPattern pattern( p*6, q*6 );
170 trace.info() << pattern << endl;
171
172 // ODD PATTERN
173 trace.beginBlock ( "Testing block: Smallest covering subpatterns of ODD pattern." );
174 MyPattern pat_odd( 5, 12 );
175 trace.info() << "ODD " << pat_odd << " " << pat_odd.rE() << endl;
176 MyPattern sp;
177 Quotient np;
178 Vector2I start;
179
180 // Left Subpatterns
181 pat_odd.getSmallestCoveringSubpattern( sp, np, start,
182 0, 17 );
183 trace.info() << "sub(0,17) = " << sp << " " << sp.rE() << "^" << np << endl;
184 ++nb; nbok += sp.slope() == SB::fraction( 5, 12 ) ? 1 : 0;
185 pat_odd.getSmallestCoveringSubpattern( sp, np, start,
186 1, 17 );
187 trace.info() << "sub(1,17) = " << sp << " " << sp.rE() << "^" << np << endl;
188 ++nb; nbok += sp.slope() == SB::fraction( 5, 12 ) ? 1 : 0;
189 pat_odd.getSmallestCoveringSubpattern( sp, np, start,
190 7, 17 );
191 trace.info() << "sub(7,17) = " << sp << " " << sp.rE() << "^" << np << endl;
192 ++nb; nbok += sp.slope() == SB::fraction( 3, 7 ) ? 1 : 0;
193 pat_odd.getSmallestCoveringSubpattern( sp, np, start,
194 8, 17 );
195 trace.info() << "sub(8,17) = " << sp << " " << sp.rE() << "^" << np << endl;
196 ++nb; nbok += sp.slope() == SB::fraction( 3, 7 ) ? 1 : 0;
197 pat_odd.getSmallestCoveringSubpattern( sp, np, start,
198 13, 17 );
199 trace.info() << "sub(13,17) = " << sp << " " << sp.rE() << "^" << np << endl;
200 ++nb; nbok += sp.slope() == SB::fraction( 3, 7 ) ? 1 : 0;
201 pat_odd.getSmallestCoveringSubpattern( sp, np, start,
202 14, 17 );
203 trace.info() << "sub(14,17) = " << sp << " " << sp.rE() << "^" << np << endl;
204 ++nb; nbok += sp.slope() == SB::fraction( 1, 2 ) ? 1 : 0;
205 pat_odd.getSmallestCoveringSubpattern( sp, np, start,
206 15, 17 );
207 trace.info() << "sub(15,17) = " << sp << " " << sp.rE() << "^" << np << endl;
208 ++nb; nbok += sp.slope() == SB::fraction( 1, 2 ) ? 1 : 0;
209
210 trace.info() << "(" << nbok << "/" << nb << ") covering left Subpatterns." << endl;
211
212 // Right Subpatterns
213 pat_odd.getSmallestCoveringSubpattern( sp, np, start,
214 0, 16 );
215 trace.info() << "sub(0,16) = " << sp << " " << sp.rE() << "^" << np << endl;
216 ++nb; nbok += sp.slope() == SB::fraction( 5, 12 ) ? 1 : 0;
217 pat_odd.getSmallestCoveringSubpattern( sp, np, start,
218 0, 15 );
219 trace.info() << "sub(0,15) = " << sp << " " << sp.rE() << "^" << np << endl;
220 ++nb; nbok += sp.slope() == SB::fraction( 5, 12 ) ? 1 : 0;
221 pat_odd.getSmallestCoveringSubpattern( sp, np, start,
222 0, 14 );
223 trace.info() << "sub(0,14) = " << sp << " " << sp.rE() << "^" << np << endl;
224 ++nb; nbok += sp.slope() == SB::fraction( 2, 5 ) && np == 2 ? 1 : 0;
225 pat_odd.getSmallestCoveringSubpattern( sp, np, start,
226 0, 8 );
227 trace.info() << "sub(0,8) = " << sp << " " << sp.rE() << "^" << np << endl;
228 ++nb; nbok += sp.slope() == SB::fraction( 2, 5 ) && np == 2 ? 1 : 0;
229 pat_odd.getSmallestCoveringSubpattern( sp, np, start,
230 0, 7 );
231 trace.info() << "sub(0,7) = " << sp << " " << sp.rE() << "^" << np << endl;
232 ++nb; nbok += sp.slope() == SB::fraction( 2, 5 ) && np == 1 ? 1 : 0;
233 pat_odd.getSmallestCoveringSubpattern( sp, np, start,
234 0, 1 );
235 trace.info() << "sub(0,1) = " << sp << " " << sp.rE() << "^" << np << endl;
236 ++nb; nbok += sp.slope() == SB::fraction( 2, 5 ) && np == 1 ? 1 : 0;
237
238 trace.info() << "(" << nbok << "/" << nb << ") covering right Subpatterns." << endl;
239
240 // Middle Subpatterns
241 pat_odd.getSmallestCoveringSubpattern( sp, np, start,
242 1, 16 );
243 trace.info() << "sub(1,16) = " << sp << " " << sp.rE() << "^" << np << endl;
244 ++nb; nbok += sp.slope() == SB::fraction( 5, 12 ) ? 1 : 0;
245 pat_odd.getSmallestCoveringSubpattern( sp, np, start,
246 2, 14 );
247 trace.info() << "sub(2,14) = " << sp << " " << sp.rE() << "^" << np << endl;
248 ++nb; nbok += sp.slope() == SB::fraction( 2, 5 ) && np == 2 ? 1 : 0;
249 pat_odd.getSmallestCoveringSubpattern( sp, np, start,
250 7, 15 );
251 trace.info() << "sub(7,15) = " << sp << " " << sp.rE() << "^" << np << endl;
252 ++nb; nbok += sp.slope() == SB::fraction( 3, 7 ) && np == 1 ? 1 : 0;
253 pat_odd.getSmallestCoveringSubpattern( sp, np, start,
254 7, 14 );
255 trace.info() << "sub(7,14) = " << sp << " " << sp.rE() << "^" << np << endl;
256 ++nb; nbok += sp.slope() == SB::fraction( 2, 5 ) && np == 1 ? 1 : 0;
257 pat_odd.getSmallestCoveringSubpattern( sp, np, start,
258 3, 6 );
259 trace.info() << "sub(3,6) = " << sp << " " << sp.rE() << "^" << np << endl;
260 ++nb; nbok += sp.slope() == SB::fraction( 2, 5 ) && np == 1 ? 1 : 0;
261 pat_odd.getSmallestCoveringSubpattern( sp, np, start,
262 6, 8 );
263 trace.info() << "sub(6,8) = " << sp << " " << sp.rE() << "^" << np << endl;
264 ++nb; nbok += sp.slope() == SB::fraction( 2, 5 ) && np == 2 ? 1 : 0;
265 pat_odd.getSmallestCoveringSubpattern( sp, np, start,
266 8, 12 );
267 trace.info() << "sub(8,12) = " << sp << " " << sp.rE() << "^" << np << endl;
268 ++nb; nbok += sp.slope() == SB::fraction( 2, 5 ) && np == 1 ? 1 : 0;
269 pat_odd.getSmallestCoveringSubpattern( sp, np, start,
270 15, 16 );
271 trace.info() << "sub(15,16) = " << sp << " " << sp.rE() << "^" << np << endl;
272 ++nb; nbok += sp.slope() == SB::fraction( 1, 2 ) && np == 1 ? 1 : 0;
273
274 trace.info() << "(" << nbok << "/" << nb << ") covering middle Subpatterns." << endl;
275 trace.endBlock();
276
277 // EVEN PATTERN
278 trace.beginBlock ( "Testing block: Smallest covering subpatterns of EVEN pattern." );
279 MyPattern pat_even( 12, 17 );
280 trace.info() << "EVEN " << pat_even << " " << pat_even.rE() << endl;
281
282 // Left Subpatterns
283 pat_even.getSmallestCoveringSubpattern( sp, np, start,
284 0, 29 );
285 trace.info() << "sub(0,29) = " << sp << " " << sp.rE() << "^" << np << endl;
286 ++nb; nbok += sp.slope() == SB::fraction( 12, 17 ) ? 1 : 0;
287 pat_even.getSmallestCoveringSubpattern( sp, np, start,
288 0, 25 );
289 trace.info() << "sub(0,25) = " << sp << " " << sp.rE() << "^" << np << endl;
290 ++nb; nbok += sp.slope() == SB::fraction( 12, 17 ) ? 1 : 0;
291 pat_even.getSmallestCoveringSubpattern( sp, np, start,
292 0, 17 );
293 trace.info() << "sub(0,17) = " << sp << " " << sp.rE() << "^" << np << endl;
294 ++nb; nbok += sp.slope() == SB::fraction( 7, 10 ) ? 1 : 0;
295 pat_even.getSmallestCoveringSubpattern( sp, np, start,
296 0, 6 );
297 trace.info() << "sub(0,6) = " << sp << " " << sp.rE() << "^" << np << endl;
298 ++nb; nbok += sp.slope() == SB::fraction( 7, 10 ) ? 1 : 0;
299 pat_even.getSmallestCoveringSubpattern( sp, np, start,
300 0, 5 );
301 trace.info() << "sub(0,5) = " << sp << " " << sp.rE() << "^" << np << endl;
302 ++nb; nbok += sp.slope() == SB::fraction( 2, 3 ) ? 1 : 0;
303 trace.info() << "(" << nbok << "/" << nb << ") covering left Subpatterns." << endl;
304
305 // Right Subpatterns
306 pat_even.getSmallestCoveringSubpattern( sp, np, start,
307 4, 29 );
308 trace.info() << "sub(4,29) = " << sp << " " << sp.rE() << "^" << np << endl;
309 ++nb; nbok += sp.slope() == SB::fraction( 12, 17 ) ? 1 : 0;
310 pat_even.getSmallestCoveringSubpattern( sp, np, start,
311 5, 29 );
312 trace.info() << "sub(5,29) = " << sp << " " << sp.rE() << "^" << np << endl;
313 ++nb; nbok += sp.slope() == SB::fraction( 5, 7 ) && np == 2 ? 1 : 0;
314 pat_even.getSmallestCoveringSubpattern( sp, np, start,
315 16, 29 );
316 trace.info() << "sub(16,29) = " << sp << " " << sp.rE() << "^" << np << endl;
317 ++nb; nbok += sp.slope() == SB::fraction( 5, 7 ) && np == 2 ? 1 : 0;
318 pat_even.getSmallestCoveringSubpattern( sp, np, start,
319 17, 29 );
320 trace.info() << "sub(17,29) = " << sp << " " << sp.rE() << "^" << np << endl;
321 ++nb; nbok += sp.slope() == SB::fraction( 5, 7 ) && np == 1 ? 1 : 0;
322 trace.info() << "(" << nbok << "/" << nb << ") covering right Subpatterns." << endl;
323
324 // Middle Subpatterns
325 pat_even.getSmallestCoveringSubpattern( sp, np, start,
326 1, 27 );
327 trace.info() << "sub(1,27) = " << sp << " " << sp.rE() << "^" << np << endl;
328 ++nb; nbok += sp.slope() == SB::fraction( 12, 17 ) ? 1 : 0;
329 pat_even.getSmallestCoveringSubpattern( sp, np, start,
330 5, 24 );
331 trace.info() << "sub(5,24) = " << sp << " " << sp.rE() << "^" << np << endl;
332 ++nb; nbok += sp.slope() == SB::fraction( 5, 7 ) && np == 2 ? 1 : 0;
333 pat_even.getSmallestCoveringSubpattern( sp, np, start,
334 4, 17 );
335 trace.info() << "sub(4,17) = " << sp << " " << sp.rE() << "^" << np << endl;
336 ++nb; nbok += sp.slope() == SB::fraction( 7, 10 ) && np == 1 ? 1 : 0;
337 pat_even.getSmallestCoveringSubpattern( sp, np, start,
338 5, 17 );
339 trace.info() << "sub(5,17) = " << sp << " " << sp.rE() << "^" << np << endl;
340 ++nb; nbok += sp.slope() == SB::fraction( 5, 7 ) && np == 1 ? 1 : 0;
341 pat_even.getSmallestCoveringSubpattern( sp, np, start,
342 7, 12 );
343 trace.info() << "sub(7,12) = " << sp << " " << sp.rE() << "^" << np << endl;
344 ++nb; nbok += sp.slope() == SB::fraction( 5, 7 ) && np == 1 ? 1 : 0;
345 pat_even.getSmallestCoveringSubpattern( sp, np, start,
346 1, 4 );
347 trace.info() << "sub(1,4) = " << sp << " " << sp.rE() << "^" << np << endl;
348 ++nb; nbok += sp.slope() == SB::fraction( 2, 3 ) && np == 1 ? 1 : 0;
349 pat_even.getSmallestCoveringSubpattern( sp, np, start,
350 18, 25 );
351 trace.info() << "sub(18,20) = " << sp << " " << sp.rE() << "^" << np << endl;
352 ++nb; nbok += sp.slope() == SB::fraction( 5, 7 ) && np == 1 ? 1 : 0;
353 trace.info() << "(" << nbok << "/" << nb << ") covering middle Subpatterns." << endl;
354 trace.endBlock();
355
356
357 // GREATEST INCLUDED SUBPATTERN
358 // ODD PATTERN
359 trace.beginBlock ( "Testing block: greatest included subpatterns of ODD pattern." );
360 trace.info() << "ODD " << pat_odd << " " << pat_odd.rE() << endl;
361
362 // Left Subpatterns
363 pat_odd.getGreatestIncludedSubpattern( sp, np, start,
364 0, 17 );
365 trace.info() << "sub(0,17) = " << sp << " " << sp.rE() << "^" << np << endl;
366 ++nb; nbok += sp.slope() == SB::fraction( 5, 12 ) ? 1 : 0;
367 pat_odd.getGreatestIncludedSubpattern( sp, np, start,
368 1, 17 );
369 trace.info() << "sub(1,17) = " << sp << " " << sp.rE() << "^" << np << endl;
370 ++nb; nbok += sp.slope() == SB::fraction( 3, 7 ) ? 1 : 0;
371 pat_odd.getGreatestIncludedSubpattern( sp, np, start,
372 7, 17 );
373 trace.info() << "sub(7,17) = " << sp << " " << sp.rE() << "^" << np << endl;
374 ++nb; nbok += sp.slope() == SB::fraction( 3, 7 ) ? 1 : 0;
375 pat_odd.getGreatestIncludedSubpattern( sp, np, start,
376 8, 17 );
377 trace.info() << "sub(8,17) = " << sp << " " << sp.rE() << "^" << np << endl;
378 ++nb; nbok += sp.slope() == SB::fraction( 1, 2 ) ? 1 : 0;
379 pat_odd.getGreatestIncludedSubpattern( sp, np, start,
380 13, 17 );
381 trace.info() << "sub(13,17) = " << sp << " " << sp.rE() << "^" << np << endl;
382 ++nb; nbok += sp.slope() == SB::fraction( 1, 2 ) ? 1 : 0;
383 pat_odd.getGreatestIncludedSubpattern( sp, np, start,
384 14, 17 );
385 trace.info() << "sub(14,17) = " << sp << " " << sp.rE() << "^" << np << endl;
386 ++nb; nbok += sp.slope() == SB::fraction( 1, 2 ) ? 1 : 0;
387 pat_odd.getGreatestIncludedSubpattern( sp, np, start,
388 15, 17 );
389 trace.info() << "sub(15,17) = " << sp << " " << sp.rE() << "^" << np << endl;
390 ++nb; nbok += sp.slope() == Fraction() ? 1 : 0;
391
392 trace.info() << "(" << nbok << "/" << nb << ") covering left Subpatterns." << endl;
393
394 // Right Subpatterns
395 pat_odd.getGreatestIncludedSubpattern( sp, np, start,
396 0, 15 );
397 trace.info() << "sub(0,15) = " << sp << " " << sp.rE() << "^" << np << endl;
398 ++nb; nbok += sp.slope() == SB::fraction( 2, 5 ) && np == 2 ? 1 : 0;
399 pat_odd.getGreatestIncludedSubpattern( sp, np, start,
400 0, 14 );
401 trace.info() << "sub(0,14) = " << sp << " " << sp.rE() << "^" << np << endl;
402 ++nb; nbok += sp.slope() == SB::fraction( 2, 5 ) && np == 2 ? 1 : 0;
403 pat_odd.getGreatestIncludedSubpattern( sp, np, start,
404 0, 13 );
405 trace.info() << "sub(0,13) = " << sp << " " << sp.rE() << "^" << np << endl;
406 ++nb; nbok += sp.slope() == SB::fraction( 2, 5 ) && np == 1 ? 1 : 0;
407 pat_odd.getGreatestIncludedSubpattern( sp, np, start,
408 0, 7 );
409 trace.info() << "sub(0,7) = " << sp << " " << sp.rE() << "^" << np << endl;
410 ++nb; nbok += sp.slope() == SB::fraction( 2, 5 ) && np == 1 ? 1 : 0;
411 pat_odd.getGreatestIncludedSubpattern( sp, np, start,
412 0, 6 );
413 trace.info() << "sub(0,6) = " << sp << " " << sp.rE() << "^" << np << endl;
414 ++nb; nbok += sp.slope() == Fraction() ? 1 : 0;
415 pat_odd.getGreatestIncludedSubpattern( sp, np, start,
416 0, 1 );
417 trace.info() << "sub(0,1) = " << sp << " " << sp.rE() << "^" << np << endl;
418 ++nb; nbok += sp.slope() == Fraction() ? 1 : 0;
419
420 trace.info() << "(" << nbok << "/" << nb << ") covering right Subpatterns." << endl;
421
422 // Middle Subpatterns
423 pat_odd.getGreatestIncludedSubpattern( sp, np, start,
424 1, 16 );
425 trace.info() << "sub(1,16) = " << sp << " " << sp.rE() << "^" << np << endl;
426 ++nb; nbok += sp.slope() == SB::fraction( 2, 5 ) ? 1 : 0;
427 pat_odd.getGreatestIncludedSubpattern( sp, np, start,
428 2, 14 );
429 trace.info() << "sub(2,14) = " << sp << " " << sp.rE() << "^" << np << endl;
430 ++nb; nbok += sp.slope() == SB::fraction( 2, 5 ) && np == 1 ? 1 : 0;
431 pat_odd.getGreatestIncludedSubpattern( sp, np, start,
432 7, 15 );
433 trace.info() << "sub(7,15) = " << sp << " " << sp.rE() << "^" << np << endl;
434 ++nb; nbok += sp.slope() == SB::fraction( 2, 5 ) && np == 1 ? 1 : 0;
435 pat_odd.getGreatestIncludedSubpattern( sp, np, start,
436 7, 14 );
437 trace.info() << "sub(7,14) = " << sp << " " << sp.rE() << "^" << np << endl;
438 ++nb; nbok += sp.slope() == SB::fraction( 2, 5 ) && np == 1 ? 1 : 0;
439 pat_odd.getGreatestIncludedSubpattern( sp, np, start,
440 3, 6 );
441 trace.info() << "sub(3,6) = " << sp << " " << sp.rE() << "^" << np << endl;
442 ++nb; nbok += sp.slope() == Fraction() ? 1 : 0;
443 pat_odd.getGreatestIncludedSubpattern( sp, np, start,
444 6, 8 );
445 trace.info() << "sub(6,8) = " << sp << " " << sp.rE() << "^" << np << endl;
446 ++nb; nbok += sp.slope() == Fraction() ? 1 : 0;
447 pat_odd.getGreatestIncludedSubpattern( sp, np, start,
448 8, 12 );
449 trace.info() << "sub(8,12) = " << sp << " " << sp.rE() << "^" << np << endl;
450 ++nb; nbok += sp.slope() == Fraction() ? 1 : 0;
451 pat_odd.getGreatestIncludedSubpattern( sp, np, start,
452 15, 16 );
453 trace.info() << "sub(15,16) = " << sp << " " << sp.rE() << "^" << np << endl;
454 ++nb; nbok += sp.slope() == Fraction() ? 1 : 0;
455
456 trace.info() << "(" << nbok << "/" << nb << ") covering middle Subpatterns." << endl;
457 trace.endBlock();
458
459 // EVEN PATTERN
460 trace.beginBlock ( "Testing block: Greatest included subpatterns of EVEN pattern." );
461 trace.info() << "EVEN " << pat_even << " " << pat_even.rE() << endl;
462
463 // Left Subpatterns
464 pat_even.getGreatestIncludedSubpattern( sp, np, start,
465 0, 29 );
466 trace.info() << "sub(0,29) = " << sp << " " << sp.rE() << "^" << np << endl;
467 ++nb; nbok += sp.slope() == SB::fraction( 12, 17 ) ? 1 : 0;
468 pat_even.getGreatestIncludedSubpattern( sp, np, start,
469 0, 25 );
470 trace.info() << "sub(0,25) = " << sp << " " << sp.rE() << "^" << np << endl;
471 ++nb; nbok += sp.slope() == SB::fraction( 7, 10 ) ? 1 : 0;
472 pat_even.getGreatestIncludedSubpattern( sp, np, start,
473 0, 17 );
474 trace.info() << "sub(0,17) = " << sp << " " << sp.rE() << "^" << np << endl;
475 ++nb; nbok += sp.slope() == SB::fraction( 7, 10 ) ? 1 : 0;
476 pat_even.getGreatestIncludedSubpattern( sp, np, start,
477 0, 16 );
478 trace.info() << "sub(0,16) = " << sp << " " << sp.rE() << "^" << np << endl;
479 ++nb; nbok += sp.slope() == SB::fraction( 2, 3 ) ? 1 : 0;
480 pat_even.getGreatestIncludedSubpattern( sp, np, start,
481 0, 6 );
482 trace.info() << "sub(0,6) = " << sp << " " << sp.rE() << "^" << np << endl;
483 ++nb; nbok += sp.slope() == SB::fraction( 2, 3 ) ? 1 : 0;
484 pat_even.getGreatestIncludedSubpattern( sp, np, start,
485 0, 5 );
486 trace.info() << "sub(0,5) = " << sp << " " << sp.rE() << "^" << np << endl;
487 ++nb; nbok += sp.slope() == SB::fraction( 2, 3 ) ? 1 : 0;
488 pat_even.getGreatestIncludedSubpattern( sp, np, start,
489 0, 4 );
490 trace.info() << "sub(0,4) = " << sp << " " << sp.rE() << "^" << np << endl;
491 ++nb; nbok += sp.slope() == Fraction() ? 1 : 0;
492 trace.info() << "(" << nbok << "/" << nb << ") covering left Subpatterns." << endl;
493
494 // Right Subpatterns
495 pat_even.getGreatestIncludedSubpattern( sp, np, start,
496 4, 29 );
497 trace.info() << "sub(4,29) = " << sp << " " << sp.rE() << "^" << np << endl;
498 ++nb; nbok += sp.slope() == SB::fraction( 5, 7 ) && np == 2 ? 1 : 0;
499 pat_even.getGreatestIncludedSubpattern( sp, np, start,
500 5, 29 );
501 trace.info() << "sub(5,29) = " << sp << " " << sp.rE() << "^" << np << endl;
502 ++nb; nbok += sp.slope() == SB::fraction( 5, 7 ) && np == 2 ? 1 : 0;
503 pat_even.getGreatestIncludedSubpattern( sp, np, start,
504 16, 29 );
505 trace.info() << "sub(16,29) = " << sp << " " << sp.rE() << "^" << np << endl;
506 ++nb; nbok += sp.slope() == SB::fraction( 5, 7 ) && np == 1 ? 1 : 0;
507 pat_even.getGreatestIncludedSubpattern( sp, np, start,
508 17, 29 );
509 trace.info() << "sub(17,29) = " << sp << " " << sp.rE() << "^" << np << endl;
510 ++nb; nbok += sp.slope() == SB::fraction( 5, 7 ) && np == 1 ? 1 : 0;
511 pat_even.getGreatestIncludedSubpattern( sp, np, start,
512 18, 29 );
513 trace.info() << "sub(18,29) = " << sp << " " << sp.rE() << "^" << np << endl;
514 ++nb; nbok += sp.slope() == Fraction() ? 1 : 0;
515 trace.info() << "(" << nbok << "/" << nb << ") covering right Subpatterns." << endl;
516
517 // Middle Subpatterns
518 pat_even.getGreatestIncludedSubpattern( sp, np, start,
519 1, 27 );
520 trace.info() << "sub(1,27) = " << sp << " " << sp.rE() << "^" << np << endl;
521 ++nb; nbok += sp.slope() == SB::fraction( 5, 7 ) && np == 1 ? 1 : 0;
522 pat_even.getGreatestIncludedSubpattern( sp, np, start,
523 5, 24 );
524 trace.info() << "sub(5,24) = " << sp << " " << sp.rE() << "^" << np << endl;
525 ++nb; nbok += sp.slope() == SB::fraction( 5, 7 ) && np == 1 ? 1 : 0;
526 pat_even.getGreatestIncludedSubpattern( sp, np, start,
527 4, 17 );
528 trace.info() << "sub(4,17) = " << sp << " " << sp.rE() << "^" << np << endl;
529 ++nb; nbok += sp.slope() == SB::fraction( 5, 7 ) && np == 1 ? 1 : 0;
530 pat_even.getGreatestIncludedSubpattern( sp, np, start,
531 5, 17 );
532 trace.info() << "sub(5,17) = " << sp << " " << sp.rE() << "^" << np << endl;
533 ++nb; nbok += sp.slope() == SB::fraction( 5, 7 ) && np == 1 ? 1 : 0;
534 pat_even.getGreatestIncludedSubpattern( sp, np, start,
535 7, 16 );
536 trace.info() << "sub(5,16) = " << sp << " " << sp.rE() << "^" << np << endl;
537 ++nb; nbok += sp.slope() == Fraction() ? 1 : 0;
538 pat_even.getGreatestIncludedSubpattern( sp, np, start,
539 1, 4 );
540 trace.info() << "sub(1,4) = " << sp << " " << sp.rE() << "^" << np << endl;
541 ++nb; nbok += sp.slope() == Fraction() ? 1 : 0;
542 pat_even.getGreatestIncludedSubpattern( sp, np, start,
543 18, 25 );
544 trace.info() << "sub(18,20) = " << sp << " " << sp.rE() << "^" << np << endl;
545 ++nb; nbok += sp.slope() == Fraction() ? 1 : 0;
546 trace.info() << "(" << nbok << "/" << nb << ") covering middle Subpatterns." << endl;
547 trace.endBlock();
548
549 trace.info() << "Odd pattern " << pat_odd << endl;
550 trace.info() << " U(0)=" << pat_odd.U( 0 )
551 << " L(0)=" << pat_odd.L( 0 )
552 << " U(1)=" << pat_odd.U( 1 )
553 << " L(1)=" << pat_odd.L( 1 ) << endl;
554
555 trace.info() << "Even pattern " << pat_even << endl;
556 trace.info() << " U(0)=" << pat_even.U( 0 )
557 << " L(0)=" << pat_even.L( 0 )
558 << " U(1)=" << pat_even.U( 1 )
559 << " L(1)=" << pat_even.L( 1 ) << endl;
560
561 return nbok == nb;
562}
Aim: This class represents a pattern, i.e. the path between two consecutive upper leaning points on a...
Definition Pattern.h:79

References DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), DGtal::Trace::info(), and DGtal::trace.

◆ testReducedFraction()

template<typename SB >
bool testReducedFraction ( )

Definition at line 75 of file testLighterSternBrocot.cpp.

76{
77 typedef typename SB::Integer Integer;
78 typedef typename SB::Quotient Quotient;
79 typedef typename SB::Fraction Fraction;
80 unsigned int nbok = 0;
81 unsigned int nb = 0;
82 Integer p = ( rand() % 10000 ) + 1;
83 Integer q = ( rand() % 10000 ) + 1;
84 trace.beginBlock ( "Testing block: reduced fraction." );
86 Integer g = ic.gcd( p, q );
87 p /= g;
88 q /= g;
90 Quotient sp = (Quotient)NumberTraits<Integer>::castToInt64_t( p );
91 Quotient sq = (Quotient)NumberTraits<Integer>::castToInt64_t( q );
92 std::vector<Quotient> cf1;
93 ics.getCFrac( cf1, sp, sq );
94 Fraction f1 = SB::fraction( p, q );
95 std::vector<Quotient> cf1_bis;
96 f1.getCFrac( cf1_bis );
97 bool ok = equalCFrac<Quotient>( cf1, cf1_bis );
98 trace.info() << " - p / q = " << p << " / " << q << std::endl;
99 trace.info() << " - f1 = ";
100 SB::display( trace.info(), f1 );
101 trace.info() << std::endl;
102 ++nb; nbok += ok ? 1 : 0;
103 trace.info() << "(" << nbok << "/" << nb << ") "
104 << " cfrac"
105 << std::endl;
106 const auto depth = cf1.size();
107 for ( unsigned int k = 1; k < depth; ++k )
108 {
109 std::vector<Quotient> cf1_red;
110 Fraction fr = f1.reduced( k );
111 fr.getCFrac( cf1_red );
112 cf1.resize( depth - k );
113 ok = equalCFrac<Quotient>( cf1, cf1_red );
114 ++nb; nbok += ok ? 1 : 0;
115 trace.info() << "(" << nbok << "/" << nb << ") "
116 << "reduced(" << k << ")=";
117 SB::display( trace.info(), fr );
118 std::cerr << std::endl;
119 }
120
121 //trace.info() << "- nbFractions = " << SB::instance().nbFractions << std::endl;
122 trace.endBlock();
123 return nbok == nb;
124}
Integer getCFrac(std::vector< Integer > &quotients, IntegerParamType a, IntegerParamType b) const

References DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), DGtal::IntegerComputer< TInteger >::gcd(), DGtal::IntegerComputer< TInteger >::getCFrac(), DGtal::Trace::info(), and DGtal::trace.

◆ testStandardDSLQ0()

template<typename Fraction >
bool testStandardDSLQ0 ( )

Definition at line 565 of file testLighterSternBrocot.cpp.

566{
567 typedef StandardDSLQ0<Fraction> DSL;
568 typedef typename Fraction::Integer Integer;
569 typedef typename DSL::Point Point;
570 typedef typename DSL::Vector2I Vector2I;
571
572 BOOST_CONCEPT_ASSERT(( concepts::CPointPredicate< DSL > ));
573 unsigned int nbok = 0;
574 unsigned int nb = 0;
575
576 for ( Integer mu = -5; mu < 30; ++mu )
577 {
578 DSL D1( 5, 12, mu );
579 trace.info() << "DSL D1=" << D1 << endl;
580 Point U = D1.U();
581 Point L = D1.L();
582 trace.info() << "- U=" << U << " r(U)=" << D1.r( U )
583 << ", L=" << L << " r(L)=" << D1.r( L ) << endl;
584 ++nb; nbok += D1.r( U ) == D1.mu() ? 1 : 0;
585 ++nb; nbok += D1.r( L ) == D1.mup() ? 1 : 0;
586 }
587
588 DSL D2( 12, 17, 5 );
589 for ( Integer x = -5; x < 30; ++x )
590 {
591 Point P = D2.lowestY( x );
592 ++nb; nbok += D2( P ) && ( ! D2( P - Vector2I(0,1) ) ) ? 1 : 0;
593 trace.info() << "(" << nbok << "/" << nb << ") "
594 << "D2(P) && ! D2(P-y) P=" << P << " r(P)=" << D2.r( P )
595 << endl;
596 P = D2.uppermostY( x );
597 ++nb; nbok += D2( P ) && ( ! D2( P + Vector2I(0,1) ) ) ? 1 : 0;
598 trace.info() << "(" << nbok << "/" << nb << ") "
599 << "D2(P) && ! D2(P+y) P=" << P << " r(P)=" << D2.r( P )
600 << endl;
601 }
602 for ( Integer y = -5; y < 30; ++y )
603 {
604 Point P = D2.lowestX( y );
605 ++nb; nbok += D2( P ) && ( ! D2( P - Vector2I(1,0) ) ) ? 1 : 0;
606 trace.info() << "(" << nbok << "/" << nb << ") "
607 << "D2(P) && ! D2(P-x) P=" << P << " r(P)=" << D2.r( P )
608 << endl;
609 P = D2.uppermostX( y );
610 ++nb; nbok += D2( P ) && ( ! D2( P + Vector2I(1,0) ) ) ? 1 : 0;
611 trace.info() << "(" << nbok << "/" << nb << ") "
612 << "D2(P) && ! D2(P+x) P=" << P << " r(P)=" << D2.r( P )
613 << endl;
614 }
615
616 return nbok == nb;
617}
Aim: Defines a predicate on a point.

References DGtal::Trace::info(), DGtal::L, and DGtal::trace.

◆ testSubStandardDSLQ0()

template<typename Fraction >
bool testSubStandardDSLQ0 ( )

Definition at line 657 of file testLighterSternBrocot.cpp.

658{
659 typedef StandardDSLQ0<Fraction> DSL;
660 typedef typename Fraction::Integer Integer;
661 typedef typename DSL::Point Point;
663 unsigned int nbok = 0;
664 unsigned int nb = 0;
665
666 trace.beginBlock( "Check ReversedSmartDSS == ArithmeticDSS" );
667 for ( unsigned int i = 0; i < 100; ++i )
668 {
669 Integer a( rand() % 12000 + 1 );
670 Integer b( rand() % 12000 + 1 );
671 if ( ic.gcd( a, b ) == 1 )
672 {
673 trace.info() << "(" << i << ")"
674 << " Test DSL has slope " << a << "/" << b << std::endl;
675 for ( Integer mu = 0; mu < 5; ++mu )
676 {
677 DSL D( a, b, rand() % 10000 );
678 for ( Integer x = 0; x < 10; ++x )
679 {
680 Integer x1 = rand() % 1000;
681 Integer x2 = x1 + 1 + ( rand() % 1000 );
682 Point A = D.lowestY( x1 );
683 Point B = D.lowestY( x2 );
684 ++nb; nbok += checkSubStandardDSLQ0<DSL>( D, A, B ) ? 1 : 0;
685 if ( nb != nbok )
686 trace.info() << "(" << nbok << "/" << nb << ") correct reversedSmartDSS."
687 << std::endl;
688 if ( nbok != nb ) assert(false);
689 }
690 }
691 }
692 }
693 trace.info() << "(" << nbok << "/" << nb << ") correct reversedSmartDSS."
694 << std::endl;
695 trace.endBlock();
696 return nbok == nb;
697}

References DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), DGtal::IntegerComputer< TInteger >::gcd(), DGtal::Trace::info(), and DGtal::trace.

◆ testTrivial()

template<typename LSB >
bool testTrivial ( const string &  lsb)

Definition at line 792 of file testLighterSternBrocot.cpp.

793{
794 typedef typename LSB::Fraction Fraction;
796
797 std::cerr << "SB = " << lsb << std::endl;
798 {
799 Pattern pat( 2, 3 );
800 std::cerr << "pat = " << pat.rE() << " depth=" << pat.slope().k()
801 << std::endl;
802 Pattern spat = pat.previousPattern();
803 std::cerr << "spat= " << spat.rE() << " depth=" << spat.slope().k()
804 << std::endl;
805 Pattern sspat = spat.previousPattern();
806 std::cerr << "sspat= " << sspat.rE() << " depth=" << sspat.slope().k()
807 << std::endl;
808 }
809 {
810 Pattern pat( 3, 2 );
811 std::cerr << "pat = " << pat.rE() << " depth=" << pat.slope().k()
812 << std::endl;
813 Pattern spat = pat.previousPattern();
814 std::cerr << "spat= " << spat.rE() << " depth=" << spat.slope().k()
815 << std::endl;
816 Pattern sspat = spat.previousPattern();
817 std::cerr << "sspat= " << sspat.rE() << " depth=" << sspat.slope().k()
818 << std::endl;
819 }
820 return true;
821}
Fraction slope() const
Pattern previousPattern() const
std::string rE() const

References DGtal::Pattern< TFraction >::previousPattern(), DGtal::Pattern< TFraction >::rE(), and DGtal::Pattern< TFraction >::slope().