DGtal  1.5.beta
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().

◆ main()

int main ( int  argc,
char **  argv 
)
Examples
arithmetic/approximation.cpp, arithmetic/convergents-biginteger.cpp, arithmetic/convergents.cpp, arithmetic/extended-euclid.cpp, arithmetic/fraction.cpp, arithmetic/lower-integer-convex-hull.cpp, arithmetic/pattern.cpp, dec/exampleDECSurface.cpp, dec/exampleDiscreteExteriorCalculusChladni.cpp, dec/exampleDiscreteExteriorCalculusSolve.cpp, dec/exampleDiscreteExteriorCalculusUsage.cpp, dec/exampleHeatLaplace.cpp, dec/examplePropagation.cpp, doc-examples/demo-kernel-1.cpp, doc-examples/kernelDomain.cpp, doc-examples/range.cpp, examples/tutorial-examples/polyhedralizer.cpp, geometry/curves/convex-and-concave-parts.cpp, geometry/curves/estimation/exampleCurvature.cpp, geometry/curves/estimation/exampleLMST2D.cpp, geometry/curves/estimation/exampleLMST3D.cpp, geometry/curves/estimation/exampleLMST3DBy2D.cpp, geometry/curves/exampleAlphaThickSegment.cpp, geometry/curves/exampleAlphaThickSegmentNoisy.cpp, geometry/curves/exampleAlphaThickSegmentTgtCover.cpp, geometry/curves/exampleArithDSS3d.cpp, geometry/curves/exampleArithmeticalDSL.cpp, geometry/curves/exampleArithmeticalDSS.cpp, geometry/curves/exampleArithmeticalDSSComputer.cpp, geometry/curves/exampleDSLSubsegment.cpp, geometry/curves/exampleDigitalConvexity.cpp, geometry/curves/exampleFrechetShortcut.cpp, geometry/curves/exampleGridCurve2d.cpp, geometry/curves/exampleGridCurve3d-2.cpp, geometry/curves/exampleGridCurve3d.cpp, geometry/curves/exampleNaive3DDSSComputer.cpp, geometry/curves/exampleRationalConvexity.cpp, geometry/curves/greedy-dss-decomposition.cpp, geometry/curves/greedyAlphaThickDecomposition.cpp, geometry/meshes/curvature-comparator-ii-cnc-3d.cpp, geometry/meshes/curvature-measures-icnc-3d.cpp, geometry/meshes/curvature-measures-icnc-XY-3d.cpp, geometry/meshes/curvature-measures-nc-3d.cpp, geometry/meshes/curvature-measures-nc-XY-3d.cpp, geometry/meshes/digpoly-curvature-measures-cnc-3d.cpp, geometry/meshes/digpoly-curvature-measures-cnc-XY-3d.cpp, geometry/meshes/obj-curvature-measures-icnc-3d.cpp, geometry/meshes/obj-curvature-measures-icnc-XY-3d.cpp, geometry/meshes/vol-curvature-measures-icnc-3d.cpp, geometry/meshes/vol-curvature-measures-icnc-XY-3d.cpp, geometry/surfaces/dvcm-2d-curvature.cpp, geometry/surfaces/dvcm-3d.cpp, geometry/surfaces/greedy-plane-segmentation-ex2.cpp, geometry/surfaces/greedy-plane-segmentation.cpp, geometry/tools/checkLatticeBallQuickHull.cpp, geometry/tools/determinant/exampleInHalfPlane.cpp, geometry/tools/exampleAlphaShape.cpp, geometry/tools/exampleConvexHull2D.cpp, geometry/tools/exampleLatticeBallDelaunay2D.cpp, geometry/tools/exampleLatticeBallDelaunay3D.cpp, geometry/tools/exampleLatticeBallQuickHull3D.cpp, geometry/tools/examplePreimage.cpp, geometry/tools/exampleQuickHull3D.cpp, geometry/tools/exampleRationalBallDelaunay3D.cpp, geometry/tools/exampleRationalBallQuickHull3D.cpp, geometry/volumes/checkFullConvexityTheorems.cpp, geometry/volumes/digitalPolyhedronBuilder3D.cpp, geometry/volumes/distance/distancetransform2D.cpp, geometry/volumes/distance/distancetransform3D.cpp, geometry/volumes/distance/exampleFMM2D.cpp, geometry/volumes/distance/exampleFMM3D.cpp, geometry/volumes/distance/toricdomainvolumetric.cpp, geometry/volumes/distance/voronoimap2D.cpp, geometry/volumes/dvcm-2d.cpp, geometry/volumes/exampleBoundedLatticePolytopeCount2D.cpp, geometry/volumes/exampleBoundedLatticePolytopeCount3D.cpp, geometry/volumes/exampleBoundedLatticePolytopeCount4D.cpp, geometry/volumes/fullConvexityAnalysis3D.cpp, geometry/volumes/fullConvexityCollapsiblePoints2D.cpp, geometry/volumes/fullConvexityLUT2D.cpp, geometry/volumes/fullConvexityShortestPaths3D.cpp, geometry/volumes/fullConvexitySphereGeodesics.cpp, geometry/volumes/fullConvexityThinning3D.cpp, geometry/volumes/pConvexity-benchmark.cpp, geometry/volumes/standardDigitalPolyhedronBuilder3D.cpp, graph/graphTraversal.cpp, graph/volDistanceTraversal.cpp, images/exampleConstImageAdapter.cpp, images/exampleImageFactoryFromHDF5.cpp, images/exampleRigidtransformation2d.cpp, images/exampleRigidtransformation3d.cpp, images/exampleTiledImage.cpp, images/extract2DImagesFrom3D.cpp, images/extract2DImagesFrom3DandVisu.cpp, images/extract2DSlicesImagesFrom3D.cpp, images/imageBasicSubsampling.cpp, images/raw2HDF5.cpp, io/boards/dgtalBoard2D-1-points.cpp, io/boards/dgtalBoard2D-2-sets.cpp, io/boards/dgtalBoard2D-3-custom-classes.cpp, io/boards/dgtalBoard2D-3-custom-points.cpp, io/boards/dgtalBoard2D-4-colormaps.cpp, io/boards/dgtalBoard3D-1-points.cpp, io/boards/dgtalBoard3D-2-ks.cpp, io/boards/dgtalBoard3D-6-clipping.cpp, io/boards/dgtalBoard3DTo2D-1-points.cpp, io/boards/dgtalBoard3DTo2D-2-sets.cpp, io/boards/dgtalBoard3DTo2D-2bis-sets.cpp, io/boards/dgtalBoard3DTo2D-3-objects.cpp, io/boards/dgtalBoard3DTo2D-4-modes.cpp, io/boards/dgtalBoard3DTo2D-5-custom.cpp, io/boards/dgtalBoard3DTo2D-6.cpp, io/boards/dgtalBoard3DTo2D-KSCell.cpp, io/boards/exampleBezierCurve.cpp, io/boards/logoDGtal.cpp, io/digitalSetFromPointList.cpp, io/digitalSetFromVol.cpp, io/display3DToOFF.cpp, io/meshFromOFF.cpp, io/viewDualSurface.cpp, io/viewers/demo-kernel-2.cpp, io/viewers/viewer3D-1-points.cpp, io/viewers/viewer3D-10-interaction.cpp, io/viewers/viewer3D-11-extension.cpp, io/viewers/viewer3D-2-sets.cpp, io/viewers/viewer3D-3-objects.cpp, io/viewers/viewer3D-4-modes.cpp, io/viewers/viewer3D-4bis-illustrationMode.cpp, io/viewers/viewer3D-5-custom.cpp, io/viewers/viewer3D-6-clipping.cpp, io/viewers/viewer3D-7-planes.cpp, io/viewers/viewer3D-7-stdplane.cpp, io/viewers/viewer3D-7bis-planes.cpp, io/viewers/viewer3D-7bis-stdplane.cpp, io/viewers/viewer3D-8-2DSliceImages.cpp, io/viewers/viewer3D-8bis-2Dimages.cpp, io/viewers/viewer3D-9-3Dimages.cpp, math/polynomial-derivative.cpp, math/polynomial-read.cpp, math/polynomial2-derivative.cpp, shapes/exampleEuclideanShapesDecorator.cpp, shapes/exampleMeshVoxelizer.cpp, shapes/exampleSurfaceMesh.cpp, shapes/mesh3DConstructionAndVisualisation.cpp, shapes/viewMarchingCubes.cpp, shapes/viewPolygonalMarchingCubes.cpp, topology/3dBorderExtraction.cpp, topology/3dBorderExtractionImg.cpp, topology/3dKSSurfaceExtraction.cpp, topology/area-estimation-with-digital-surface.cpp, topology/area-estimation-with-indexed-digital-surface.cpp, topology/ctopo-1-3d.cpp, topology/ctopo-1.cpp, topology/ctopo-1s-3d.cpp, topology/ctopo-2-3d.cpp, topology/ctopo-2.cpp, topology/ctopo-fillContours.cpp, topology/cubical-complex-collapse.cpp, topology/cubical-complex-illustrations.cpp, topology/digitalSetToCubicalComplexes2D.cpp, topology/digitalSurfaceSlice.cpp, topology/frontierAndBoundary.cpp, topology/generateSimplicityTables2D.cpp, topology/generateSimplicityTables3D.cpp, topology/homotopicThinning3D.cpp, topology/khalimskySpaceScanner.cpp, topology/trackImplicitPolynomialSurfaceToOFF.cpp, topology/volBreadthFirstTraversal.cpp, topology/volMarchingCubes.cpp, topology/volScanBoundary.cpp, topology/volToOFF.cpp, topology/volTrackBoundary.cpp, tutorial-examples/2DSliceImageFromVol.cpp, tutorial-examples/AreaSurfaceEstimation-final.cpp, tutorial-examples/FMMErosion.cpp, tutorial-examples/freemanChainFromImage.cpp, tutorial-examples/polyhedralizer.cpp, and tutorial-examples/volDTGranulo.cpp.

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

◆ 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 );
135  checkSubArithmeticDSS<DSL>( D, A, B );
136  }
137  }
138  }
139  }
140  return true;
141 }
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().