DGtal  1.5.beta
testStandardDSLQ0-LrSB-reversedSmartDSS-benchmark.cpp File Reference
#include <cstdlib>
#include <iostream>
#include <map>
#include "DGtal/base/Common.h"
#include "DGtal/kernel/CPointPredicate.h"
#include "DGtal/arithmetic/IntegerComputer.h"
#include "DGtal/arithmetic/LighterSternBrocot.h"
#include "DGtal/arithmetic/Pattern.h"
#include "DGtal/arithmetic/StandardDSLQ0.h"
Include dependency graph for testStandardDSLQ0-LrSB-reversedSmartDSS-benchmark.cpp:

Go to the source code of this file.

Functions

template<typename DSL >
bool checkSubStandardDSLQ0 (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 testStandardDSLQ0-LrSB-reversedSmartDSS-benchmark.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 50 of file testStandardDSLQ0-LrSB-reversedSmartDSS-benchmark.cpp.

53 {
54  DSL S = D.reversedSmartDSS( A, B );
55  std::cout << D.a() << " " << D.b() << " " << D.mu() << " "
56  << S.a() << " " << S.b() << " " << S.mu() << " "
57  << A[0] << " " << A[1] << " " << B[0] << " " << B[1]
58  << std::endl;
59  return true;
60 }

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 104 of file testStandardDSLQ0-LrSB-reversedSmartDSS-benchmark.cpp.

105 {
107  typedef SB::Fraction Fraction;
108  typedef Fraction::Integer Integer;
109  unsigned int nbtries = ( argc > 1 ) ? atoi( argv[ 1 ] ) : 10000;
110  Integer moda = ( argc > 2 ) ? atoll( argv[ 2 ] ) : 12000;
111  Integer modb = ( argc > 3 ) ? atoll( argv[ 3 ] ) : 12000;
112  Integer modx = ( argc > 4 ) ? atoll( argv[ 4 ] ) : 1000;
113  testSubStandardDSLQ0<Fraction>( nbtries, moda, modb, modx );
114  return 0;
115 }
Aim: The Stern-Brocot tree is the tree of irreducible fractions. This class allows to construct it pr...

◆ testSubStandardDSLQ0()

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

Definition at line 63 of file testStandardDSLQ0-LrSB-reversedSmartDSS-benchmark.cpp.

67 {
68  typedef StandardDSLQ0<Fraction> DSL;
69  typedef typename Fraction::Integer Integer;
70  typedef typename DSL::Point Point;
72 
73  std::cout << "# a b mu a1 b1 mu1 Ax Ay Bx By" << std::endl;
74  for ( unsigned int i = 0; i < nbtries; ++i )
75  {
76  Integer a( rand() % moda + 1 );
77  Integer b( rand() % modb + 1 );
78  if ( ic.gcd( a, b ) == 1 )
79  {
80  for ( Integer mu = 0; mu < 5; ++mu )
81  {
82  DSL D( a, b, rand() % (moda+modb) );
83  for ( Integer x = 0; x < 10; ++x )
84  {
85  Integer x1 = rand() % modx;
86  Integer x2 = x1 + 1 + ( rand() % modx );
87  Point A = D.lowestY( x1 );
88  Point B = D.lowestY( x2 );
89  checkSubStandardDSLQ0<DSL>( D, A, B );
90  }
91  }
92  }
93  }
94  return true;
95 }
Integer gcd(IntegerParamType a, IntegerParamType b) const
Aim: Represents a digital straight line with slope in the first quadrant (Q0: x >= 0,...
Definition: StandardDSLQ0.h:80
MyPointD Point
Definition: testClone2.cpp:383

References DGtal::IntegerComputer< TInteger >::gcd().