DGtal 1.4.0
Loading...
Searching...
No Matches
testArithmeticDSS-benchmark.cpp File Reference
#include <cstdlib>
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/kernel/CPointPredicate.h"
#include "DGtal/arithmetic/IntegerComputer.h"
#include "DGtal/arithmetic/SternBrocot.h"
#include "DGtal/arithmetic/Pattern.h"
#include "DGtal/arithmetic/StandardDSLQ0.h"
#include "DGtal/geometry/curves/ArithmeticalDSSComputer.h"
Include dependency graph for testArithmeticDSS-benchmark.cpp:

Go to the source code of this file.

Functions

template<typename DSL >
bool checkSubArithmeticDSS (const DSL &D, const typename DSL::Point &A, const typename DSL::Point &B)
 
template<typename Fraction >
bool testSubStandardDSLQ0 (unsigned int nbtries, typename Fraction::Integer moda, typename Fraction::Integer modb, typename Fraction::Integer modx)
 
int main (int argc, char **argv)
 

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 SternBrocot.

This file is part of the DGtal library.

Definition in file testArithmeticDSS-benchmark.cpp.

Function Documentation

◆ checkSubArithmeticDSS()

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

Definition at line 50 of file testArithmeticDSS-benchmark.cpp.

53{
54 typedef typename DSL::Integer Integer;
55 typedef typename DSL::ConstIterator ConstIterator;
57
58 ConstIterator it = D.begin( A );
59 ConstIterator it_end = D.end( B );
60 ADSS dss;
61 dss.init( it );
62 while ( ( dss.end() != it_end )
63 && ( dss.extendFront() ) ) {}
64 std::cout << D.a() << " " << D.b() << " " << D.mu() << " "
65 << dss.a() << " " << dss.b() << " " << dss.mu() << " "
66 << A[0] << " " << A[1] << " " << B[0] << " " << B[1]
67 << std::endl;
68
69 return true;
70}
Aim: This class is a wrapper around ArithmeticalDSS that is devoted to the dynamic recognition of dig...
ConstIterator begin() const
MyDigitalSurface::ConstIterator ConstIterator

References DGtal::ArithmeticalDSSComputer< TIterator, TInteger, adjacency >::begin().

Referenced by testSubStandardDSLQ0().

◆ main()

int main ( int argc,
char ** argv )

Definition at line 147 of file testArithmeticDSS-benchmark.cpp.

148{
150 typedef SB::Fraction Fraction;
151 typedef Fraction::Integer Integer;
152 unsigned int nbtries = ( argc > 1 ) ? atoi( argv[ 1 ] ) : 10000;
153 Integer moda = ( argc > 2 ) ? atoll( argv[ 2 ] ) : 12000;
154 Integer modb = ( argc > 3 ) ? atoll( argv[ 3 ] ) : 12000;
155 Integer modx = ( argc > 4 ) ? atoll( argv[ 4 ] ) : 1000;
156 testSubStandardDSLQ0<Fraction>( nbtries, moda, modb, modx );
157 return 0;
158}
Aim: The Stern-Brocot tree is the tree of irreducible fractions. This class allows to construct it pr...
Definition SternBrocot.h:78
bool testSubStandardDSLQ0()

References testSubStandardDSLQ0().

◆ testSubStandardDSLQ0()

template<typename Fraction >
bool testSubStandardDSLQ0 ( unsigned int nbtries,
typename Fraction::Integer moda,
typename Fraction::Integer modb,
typename Fraction::Integer modx )

Definition at line 109 of file testArithmeticDSS-benchmark.cpp.

113{
114 typedef StandardDSLQ0<Fraction> DSL;
115 typedef typename Fraction::Integer Integer;
116 typedef typename DSL::Point Point;
118
119 std::cout << "# a b mu a1 b1 mu1 Ax Ay Bx By" << std::endl;
120 for ( unsigned int i = 0; i < nbtries; ++i )
121 {
122 Integer a( rand() % moda + 1 );
123 Integer b( rand() % modb + 1 );
124 if ( ic.gcd( a, b ) == 1 )
125 {
126 for ( Integer mu = 0; mu < 5; ++mu )
127 {
128 DSL D( a, b, rand() % (moda+modb) );
129 for ( Integer x = 0; x < 10; ++x )
130 {
131 Integer x1 = rand() % modx;
132 Integer x2 = x1 + 1 + ( rand() % modx );
133 Point A = D.lowestY( x1 );
134 Point B = D.lowestY( x2 );
136 }
137 }
138 }
139 }
140 return true;
141}
Aim: This class gathers several types and methods to make computation with integers.
Integer gcd(IntegerParamType a, IntegerParamType b) const
Aim: Represents a digital straight line with slope in the first quadrant (Q0: x >= 0,...
bool checkSubArithmeticDSS(const DSL &D, const typename DSL::Point &A, const typename DSL::Point &B)
MyPointD Point

References checkSubArithmeticDSS(), and DGtal::IntegerComputer< TInteger >::gcd().