206 unsigned int nbok = 0;
216 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
220 typedef typename DSS::ConstIterator I;
225 for (I it = dss.begin(), itEnd = dss.end();
226 ( (it != itEnd)&&(res)&&(c<100) );
233 trace.
info() <<
" : " << c <<
" points " << std::endl;
236 if ( (res)&&(c == (dss.omega()+1))
237 &&(*dss.begin() == dss.back())
238 &&(*--dss.end() == dss.front()) )
242 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
247 typedef typename DSS::ConstReverseIterator I;
250 for (I it = dss.rbegin(), itEnd = dss.rend();
251 ( (it != itEnd)&&(res)&&(c<100) );
258 trace.
info() <<
" : " << c <<
" points " << std::endl;
261 if ( (res)&&(c == (dss.omega()+1))
262 &&(*dss.rbegin() == dss.front())
263 &&(*--dss.rend() == dss.back()) )
267 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
290 typename DSS::Point newPointToFront,
291 typename DSS::Point newPointToBack,
292 unsigned int& nbok,
unsigned int& nb,
293 const unsigned short int& code = 0)
299 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
301 trace.
info() <<
"to front " << newPointToFront << std::endl;
302 if (dss.isExtendableFront( newPointToFront ) == code)
305 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
310 if ( (!mdss.extendFront(newPointToFront)) )
316 if ( (mdss.extendFront(newPointToFront))&&(mdss.isValid()) )
319 std::cerr << mdss.isValid() << std::endl;
322 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
324 trace.
info() <<
"to back " << newPointToBack << std::endl;
325 if (dss.isExtendableBack( newPointToBack ) == code)
328 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
333 if ( (!mdss.extendBack(newPointToBack)) )
339 if ( (mdss.extendBack(newPointToBack))&&(mdss.isValid()) )
342 std::cerr << mdss.isValid() << std::endl;
345 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
425 typedef typename DSS::Point
Point;
426 typedef typename DSS::Vector
Vector;
428 unsigned int nbok = 0;
435 trace.
info() <<
"not connected point" << std::endl;
442 trace.
info() <<
"not compatible second step" << std::endl;
449 trace.
info() <<
"a third step" << std::endl;
456 trace.
info() <<
"strongly exterior" << std::endl;
463 trace.
info() <<
"confounded points" << std::endl;
470 trace.
info() <<
"strongly interior points" << std::endl;
473 dss0.Uf(), dss0.Ul(),
474 dss0.Lf(), dss0.Ll() );
480 trace.
info() <<
"weakly interior points on the left" << std::endl;
485 newPointToBack+dss0.steps().second,
486 newPointToFront-dss0.steps().second,
487 dss0.Uf(), dss0.Ul(),
488 dss0.Lf(), dss0.Ll()+
Vector(8,5) );
489 extensionTest( dss, newPointToFront, newPointToBack, nbok, nb, 5 );
494 trace.
info() <<
"weakly exterior points on the left" << std::endl;
496 Point newPointToBack = dss0.Uf()+dss0.shift()-
Vector(8,5);
497 Point newPointToFront = dss0.Ll()-dss0.shift()+
Vector(8,5);
499 newPointToBack+dss0.steps().second,
500 newPointToFront-dss0.steps().second,
501 dss0.Uf(), dss0.Ul(),
502 dss0.Lf()-
Vector(8,5), dss0.Ll() );
503 extensionTest( dss, newPointToFront, newPointToBack, nbok, nb, 7 );
508 trace.
info() <<
"weakly interior points on the right" << std::endl;
513 newPointToBack+dss0.steps().first,
514 newPointToFront-dss0.steps().first,
515 dss0.Uf(), dss0.Ul(),
516 dss0.Lf()-
Vector(8,5), dss0.Ll() );
517 extensionTest( dss, newPointToFront, newPointToBack, nbok, nb, 6 );
522 trace.
info() <<
"weakly exterior points on the right" << std::endl;
524 Point newPointToBack = dss0.Lf()-
Vector(8,5)-dss0.shift();
525 Point newPointToFront = dss0.Ul()+
Vector(8,5)+dss0.shift();
527 newPointToBack+dss0.steps().first,
528 newPointToFront-dss0.steps().first,
529 dss0.Uf(), dss0.Ul(),
530 dss0.Lf(), dss0.Ll()+
Vector(8,5) );
531 extensionTest( dss, newPointToFront, newPointToBack, nbok, nb, 8 );
536 trace.
info() <<
"first step" << std::endl;
543 trace.
info() <<
"first step repetition" << std::endl;
550 trace.
info() <<
"second step (above)" << std::endl;
552 DSS dss(
Point(0,0),
Point(2,1) - dss0.steps().second);
553 Point newPointToBack =
Point(0,0) - dss0.steps().second;
559 trace.
info() <<
"second step (below)" << std::endl;
562 DSS dss(
Point(0,0),
Point(2,-1) - dss0a.steps().first);
563 Point newPointToBack =
Point(0,0) - dss0a.steps().first;
574 trace.
info() <<
"upper leaning points" << std::endl;
581 trace.
info() <<
"lower leaning points" << std::endl;
583 Point first = dss0.Lf();
585 DSS dss(5, 8, first, last,
593 trace.
info() <<
"upper leaning points (repetitions)" << std::endl;
600 trace.
info() <<
"lower leaning points (repetitions)" << std::endl;
602 Point first = dss0.Lf();
604 DSS dss(5, 8, first, last,
612 trace.
info() <<
"no change" << std::endl;
614 typename DSS::ConstIterator itb = dss0.begin();
616 typename DSS::ConstIterator ite = dss0.end();
618 DSS dss(dss0.a(), dss0.b(), *itb, *ite,
619 dss0.Uf(), dss0.Ul(), dss0.Lf(), dss0.Ll() );
625 trace.
info() <<
"one point" << std::endl;
632 trace.
info() <<
"two points" << std::endl;
639 trace.
info() <<
"from two steps to one step" << std::endl;
661 unsigned int nbok = 0;
667 <<
", front pos: " << dss.position( dss.front() )
668 <<
", back pos: " << dss.position( dss.back() ) << std::endl;
669 if ( dss.position( dss.front() )
670 > dss.position( dss.back() ) )
674 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
683 if ( mdss.extendFront(mdss.front()-dss.shift()+dss.steps().first) )
687 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
690 if ( !mdss.extendFront(mdss.front()-dss.shift()) )
694 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
698 if ( !mdss.extendFront(mdss.front()-dss.shift()-dss.steps().first) )
702 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
707 if ( mdss.extendBack(mdss.back()+dss.shift()-dss.steps().first) )
711 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
714 if ( !mdss.extendBack(mdss.back()+dss.shift()) )
718 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
722 if ( !mdss.extendBack(mdss.back()+dss.shift()+dss.steps().first) )
726 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
745 typedef typename DSS::Point
Point;
747 unsigned int nbok = 0;
758 DSS dss( dss0.begin(), dss0.end() );
761 if ( (dss0.isValid())
764 && (dss.Lf() == dss.Ll())
765 && (dss.Uf() == dss.back())
766 && (dss.Ul() == dss.front())
767 && (dss.back() != dss.front()) )
770 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
778 DSS rdss( rdss0.begin(), rdss0.end() );
781 if ( (rdss0.isValid())
784 && (rdss.Uf() == rdss.Ul())
785 && (rdss.Lf() == rdss.back())
786 && (rdss.Ll() == rdss.front())
787 && (rdss.back() != rdss.front())
791 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
813 typename DSS::Position x,
typename DSS::Position y)
815 typename DSS::DSL dsl = aDSS.dsl();
816 DSS dss0( dsl.begin(dsl.getPoint(x)), dsl.end(dsl.getPoint(y)) );
817 DSS dss1( dsl, dsl.getPoint(x), dsl.getPoint(y) );
818 DSS dss2( aDSS, dsl.getPoint(x), dsl.getPoint(y) );
819 return ( (dss0 == dss1)&&(dss0 == dss2) );
835 unsigned int nbok = 0;
841 for (
typename DSL::Integer mu = 0; ( (mu-1 >= -aDSL.omega())&&(nbok == nb) ); --mu)
845 typedef typename DSL::Point
Point;
846 typedef typename DSL::Coordinate Coordinate;
847 typedef typename DSL::Integer
Integer;
850 Point startingPoint = aDSL.getPoint(0);
851 ASSERT( aDSL(startingPoint) );
852 Point endingPoint = aDSL.getPoint(2*aDSL.patternLength()+1);
853 ASSERT( aDSL(endingPoint) );
855 DSS dss = DSS(aDSL.begin(startingPoint), aDSL.end(endingPoint));
857 for (
typename DSL::Position l = 0; ( (l <= 2*aDSL.patternLength())&&(nbok == nb) ); ++l)
861 for (
typename DSL::Position k = 0; ( (k <= l)&&(nbok == nb) ); ++k)
883 unsigned int nbok = 0;
886 typedef DSS::Point
Point;
900 DSS DSS1(1,2,
Point(2,2),
Point(6,4),
Point(2,2),
Point(6,4),
Point(3,2),
Point(5,3));
901 DSS DSS2(3,5,
Point(-2,-1),
Point(9,6),
Point(2,2),
Point(7,5),
Point(0,0),
Point(5,3));
902 DSS res=DSS1.computeUnion(DSS2);
904 nbok +=(res==DSS2)?1:0;
908 DSS1 = DSS(2,1,
Point(2,2),
Point(4,6),
Point(2,3),
Point(3,5),
Point(2,2),
Point(4,6));
909 assert(DSS1.isValid());
910 DSS2 = DSS(5,3,
Point(-1,-2),
Point(6,9),
Point(0,0),
Point(3,5),
Point(2,2),
Point(5,7));
911 assert(DSS2.isValid());
912 res = DSS1.computeUnion(DSS2);
914 nbok +=(res==DSS2)?1:0;
918 DSS1 = DSS(2,-1,
Point(-2,2),
Point(-4,6),
Point(-2,2),
Point(-4,6),
Point(-2,3),
Point(-3,5));
919 assert(DSS1.isValid());
920 DSS2 = DSS(5,-3,
Point(1,-2),
Point(-6,9),
Point(-2,2),
Point(-5,7),
Point(0,0),
Point(-3,5));
921 assert(DSS2.isValid());
922 res = DSS1.computeUnion(DSS2);
924 nbok +=(res==DSS2)?1:0;
928 DSS1 = DSS(1,-2,
Point(-2,2),
Point(-6,4),
Point(-3,2),
Point(-5,3),
Point(-2,2),
Point(-6,4));
929 assert(DSS1.isValid());
930 DSS2 = DSS(3,-5,
Point(2,-1),
Point(-9,6),
Point(0,0),
Point(-5,3),
Point(-2,2),
Point(-7,5));
931 assert(DSS2.isValid());
932 res = DSS1.computeUnion(DSS2);
934 nbok +=(res==DSS2)?1:0;
938 DSS1 = DSS(-1,-2,
Point(-2,-2),
Point(-6,-4),
Point(-2,-2),
Point(-6,-4),
Point(-3,-2),
Point(-5,-3));
939 assert(DSS1.isValid());
940 DSS2 = DSS(-3,-5,
Point(2,1),
Point(-9,-6),
Point(-2,-2),
Point(-7,-5),
Point(0,0),
Point(-5,-3));
941 assert(DSS2.isValid());
942 res = DSS1.computeUnion(DSS2);
944 nbok +=(res==DSS2)?1:0;
954 DSS1 = DSS(3,5,
Point(-2,-1),
Point(9,6),
Point(2,2),
Point(7,5),
Point(0,0),
Point(5,3));
955 DSS2 = DSS(1,2,
Point(2,2),
Point(6,4),
Point(2,2),
Point(6,4),
Point(3,2),
Point(5,3));
956 res = DSS1.computeUnion(DSS2);
958 nbok +=(res==DSS1)?1:0;
966 trace.
info() <<
"octant 0 - no new leaning points\n";
967 DSS1 = DSS(3,7,
Point(1,3),
Point(12,7),
Point(3,4),
Point(10,7),
Point(5,4),
Point(12,7));
968 DSS2 = DSS(1,2,
Point(14,8),
Point(16,9),
Point(15,9),
Point(15,9),
Point(14,8),
Point(16,9));
969 res = DSS1.computeUnion(DSS2);
971 nbok +=(res==DSS(3,7,
Point(1,3),
Point(16,9),
Point(3,4),
Point(10,7),
Point(5,4),
Point(12,7)))?1:0;
972 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
975 trace.
info() <<
"octant 0 - new leaning points in DSS2\n";
976 DSS1 = DSS(3,7,
Point(1,3),
Point(10,7),
Point(3,4),
Point(10,7),
Point(5,4),
Point(5,4));
977 DSS2 = DSS(1,2,
Point(12,7),
Point(17,10),
Point(13,8),
Point(17,10),
Point(12,7),
Point(16,9));
978 res = DSS1.computeUnion(DSS2);
980 nbok +=(res==DSS(3,7,
Point(1,3),
Point(17,10),
Point(3,4),
Point(17,10),
Point(5,4),
Point(12,7)))?1:0;
981 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
984 trace.
info() <<
"octant 0 - new leaning points between DSS1 and DSS2\n";
985 DSS1 = DSS(3,7,
Point(1,3),
Point(10,7),
Point(3,4),
Point(10,7),
Point(5,4),
Point(5,4));
986 DSS2 = DSS(1,2,
Point(13,8),
Point(15,9),
Point(13,8),
Point(15,9),
Point(14,8),
Point(14,8));
987 res = DSS1.computeUnion(DSS2);
989 nbok +=(res==DSS(3,7,
Point(1,3),
Point(15,9),
Point(3,4),
Point(10,7),
Point(5,4),
Point(12,7)))?1:0;
990 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
1006 DSS1 = DSS(1,5,
Point(0,1),
Point(5,2),
Point(1,2),
Point(1,2),
Point(0,1),
Point(5,2));
1007 DSS2 = DSS(1,4,
Point(9,2),
Point(14,3),
Point(11,3),
Point(11,3),
Point(10,2),
Point(14,3));
1008 res = DSS1.computeUnion(DSS2);
1010 nbok +=(res==DSS(1,10,
Point(0,1),
Point(14,3),
Point(1,2),
Point(11,3),
Point(0,1),
Point(10,2)))?1:0;
1011 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
1021 DSS1 = DSS(1,5,
Point(0,1),
Point(5,2),
Point(1,2),
Point(1,2),
Point(0,1),
Point(5,2));
1022 DSS2 = DSS(1,4,
Point(9,2),
Point(14,3),
Point(11,3),
Point(11,3),
Point(10,2),
Point(14,3));
1023 res = DSS1.computeUnion(DSS2);
1025 nbok +=(res==DSS(1,10,
Point(0,1),
Point(14,3),
Point(1,2),
Point(11,3),
Point(0,1),
Point(10,2)))?1:0;
1026 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
1029 DSS1 = DSS(1,6,
Point(0,1),
Point(6,2),
Point(1,2),
Point(1,2),
Point(0,1),
Point(6,2));
1030 DSS2 = DSS(0,1,
Point(13,3),
Point(18,3),
Point(13,3),
Point(18,3),
Point(13,3),
Point(18,3));
1031 res = DSS1.computeUnion(DSS2);
1033 nbok +=(res==DSS(1,9,
Point(0,1),
Point(18,3),
Point(1,2),
Point(10,3),
Point(0,1),
Point(18,3)))?1:0;
1034 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
1039 DSS1 = DSS(6,-1,
Point(-1,0),
Point(-2,6),
Point(-2,1),
Point(-2,1),
Point(-1,0),
Point(-2,6));
1040 DSS2 = DSS(1,0,
Point(-3,13),
Point(-3,18),
Point(-3,13),
Point(-3,18),
Point(-3,13),
Point(-3,18));
1041 res = DSS1.computeUnion(DSS2);
1043 nbok +=(res==DSS(9,-1,
Point(-1,0),
Point(-3,18),
Point(-2,1),
Point(-3,10),
Point(-1,0),
Point(-3,18)))?1:0;
1044 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
1057 trace.
info() <<
"DSS1 and DSS2 are not in the same octant\n";
1059 DSS1 = DSS(1,3,
Point(0,0),
Point(3,1),
Point(0,0),
Point(3,1),
Point(2,0),
Point(2,0));
1060 DSS2 = DSS(1,-3,
Point(6,2),
Point(9,1),
Point(6,2),
Point(9,1),
Point(8,2),
Point(8,2));
1061 res = DSS1.computeUnion(DSS2);
1063 nbok +=(res==DSS(
Point(0,0)))?1:0;
1064 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
1068 trace.
info() <<
"DSS1 and DSS2 are in the same octant and connected\n";
1070 DSS1 = DSS(1,3,
Point(0,0),
Point(4,2),
Point(1,1),
Point(4,2),
Point(0,0),
Point(3,1));
1071 DSS2 = DSS(1,5,
Point(4,2),
Point(9,3),
Point(4,2),
Point(9,3),
Point(8,2),
Point(8,2));
1072 res = DSS1.computeUnion(DSS2);
1074 nbok +=(res==DSS(
Point(0,0)))?1:0;
1075 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
1080 trace.
info() <<
"DSS1 and DSS1 are in the same octant, not connected but easy case anyway\n";
1082 DSS1 = DSS(-3,-1,
Point(0,0),
Point(-2,-5),
Point(0,0),
Point(-1,-3),
Point(-1,-1),
Point(-2,-4));
1083 DSS2 = DSS(-3,-1,
Point(-2,-8),
Point(-3,-11),
Point(-2,-10),
Point(-2,-10),
Point(-2,-8),
Point(-3,-11));
1084 res = DSS1.computeUnion(DSS2);
1086 nbok +=(res==DSS(
Point(0,0)))?1:0;
1087 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
1091 trace.
info() <<
"DSS1 and DSS2 are in the same octant but not connected\n";
1093 DSS1 = DSS(-3,-1,
Point(0,0),
Point(-2,-5),
Point(0,0),
Point(-1,-3),
Point(-1,-1),
Point(-2,-4));
1094 DSS2 = DSS(-3,-1,
Point(-5,-8),
Point(-6,-11),
Point(-5,-10),
Point(-5,-10),
Point(-5,-8),
Point(-6,-11));
1095 res = DSS1.computeUnion(DSS2);
1097 nbok +=(res==DSS(
Point(0,0)))?1:0;
1098 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
1122 typedef typename DSS::DSL DSL;
1123 typedef typename DSS::Point
Point;
1124 typedef typename DSS::Integer
Integer;
1125 typedef typename DSS::Vector
Vector;
1127 unsigned int nb = 0;
1128 unsigned int nbok = 0;
1129 unsigned int nbEasy = 0;
1134 trace.
emphase() <<
"Adjacency: " << adjacency << std::endl;
1136 for (
unsigned int i = 0; i < nbtries; ++i )
1139 Integer b( rand() % modb + 1 );
1141 while(ic.
gcd(a,b) !=1)
1145 a = a*((rand()%2==0)?1:-1);
1146 b = b*((rand()%2==0)?1:-1);
1148 if ( ic.
gcd( a, b ) == 1 )
1151 for (
unsigned int j = 0; j < 5; ++j )
1154 Integer mu = rand() % (2*modb);
1155 DSL baseDSL(a,b,-mu);
1157 for (
Integer x = 0; x < 10; ++x )
1159 Integer elemMove = (b>0)?1:-1;
1165 Integer x2 = x1 + (modx + (rand() % modx))*elemMove;
1178 Integer x3 = x1 + (rand() % (2*modb))*elemMove;
1181 Integer x4 = x3 + modx*elemMove;
1184 if(baseDSL.shift()[1] < 0)
1200 aDSL = DSL(b,-a,-mu);
1219 DSS DSSres = DSS1.computeUnion(DSS2);
1224 if(abs(aDSL.a())<=abs(aDSL.b()))
1235 DSS DSSGroundTruth(DSS1);
1236 if(aDSL.before(B,D))
1239 typename DSS::ConstIterator itbegin = aDSL.begin(B);
1240 typename DSS::ConstIterator itend = aDSL.end(D);
1241 typename DSS::ConstIterator it = itbegin++;
1244 DSSGroundTruth.extendFront(*it);
1249 if(DSSres != DSSGroundTruth)
1252 trace.
info() <<
"DSS1 " << DSS1 <<
"\n" <<
"DSS2 " << DSS2 << std::endl;
1254 trace.
info() << DSSGroundTruth << std::endl;
1257 nbok+=(DSSres == DSSGroundTruth)?1:0;
1264 if((aDSL.beforeOrEqual(DSSres.Uf(),B) && !aDSL.isInDSL(DSSres.Uf())) || (!aDSL.before(DSSres.Uf(),C) && !aDSL.isInDSL(DSSres.Uf())))
1266 if((aDSL.beforeOrEqual(DSSres.Ul(),B) && !aDSL.isInDSL(DSSres.Ul())) || (!aDSL.before(DSSres.Ul(),C) && !aDSL.isInDSL(DSSres.Ul())))
1268 if((aDSL.beforeOrEqual(DSSres.Lf(),B) && !aDSL.isInDSL(DSSres.Lf())) || (!aDSL.before(DSSres.Lf(),C) && !aDSL.isInDSL(DSSres.Lf())))
1270 if((aDSL.beforeOrEqual(DSSres.Ll(),B) && !aDSL.isInDSL(DSSres.Ll())) || (!aDSL.before(DSSres.Ll(),C) && !aDSL.isInDSL(DSSres.Ll())))
1273 if(error || !DSSres.isValid() || DSSres==DSS(
Point(0,0)))
1276 trace.
info() <<
"DSS1 " << DSS1 <<
"\n" <<
"DSS2 " << DSS2 << std::endl;
1278 trace.
info() <<
"--------------------------------\n";
1293 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
1294 << nbEasy <<
" easy cases." << std::endl;
1363 for (
int i = 0; i < argc; ++i )
1369#ifdef WITH_BIGINTEGER
1379 typedef DSS8::Point
Point;
1407 typedef DSS4::Point
Point;
1427 typedef DSS8::Point
Point;
1443 typedef DSS4::Point
Point;
1454#ifdef WITH_BIGINTEGER
1461#ifdef WITH_BIGINTEGER
1489#ifdef WITH_BIGINTEGER
1510 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << endl;