Changes in / [22:45f8b617339e:21:40d6f625e549] in lemon-main
- Files:
-
- 3 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
.hgignore
r9 r3 6 6 *.o 7 7 .#.* 8 *.log9 *.lo10 *.tar.*11 8 Makefile.in 12 9 aclocal.m4 … … 23 20 lemon/stamp-h2 24 21 doc/Doxyfile 25 .dirstamp 26 .libs/* 27 .deps/* 22 lemon/.dirstamp 23 lemon/.libs/* 28 24 29 25 syntax: regexp 30 ^doc/html/.* 31 ^autom4te.cache/.* 32 ^build-aux/.* 33 ^objs.*/.* 34 ^test/[a-z_]*$ 26 html/.* 27 autom4te.cache/.* 28 build-aux/.* 29 objs.*/.* -
lemon/Makefile.am
r10 r8 8 8 9 9 lemon_libemon_la_SOURCES = \ 10 lemon/base.cc \ 11 lemon/random.cc 12 10 lemon/base.cc 13 11 14 12 lemon_libemon_la_CXXFLAGS = $(GLPK_CFLAGS) $(CPLEX_CFLAGS) $(SOPLEX_CXXFLAGS) … … 17 15 lemon_HEADERS += \ 18 16 lemon/dim2.h \ 19 lemon/random.h \20 17 lemon/list_graph.h \ 21 18 lemon/tolerance.h -
lemon/bits/invalid.h
r13 r7 25 25 namespace lemon { 26 26 27 /// \brief Dummy type to make it easier to create invalid iterators.27 /// \brief Dummy type to make it easier to make invalid iterators. 28 28 /// 29 29 /// See \ref INVALID for the usage. … … 35 35 }; 36 36 37 /// \briefInvalid iterators.38 ///37 /// Invalid iterators. 38 39 39 /// \ref Invalid is a global type that converts to each iterator 40 40 /// in such a way that the value of the target iterator will be invalid. -
lemon/dim2.h
r15 r8 35 35 /// the rectangular bounding box of a set of 36 36 /// \ref lemon::dim2::Point "dim2::Point"'s. 37 /// 38 ///\author Attila Bernath 39 37 40 38 41 namespace lemon { … … 60 63 typedef T Value; 61 64 62 ///First co ordinate65 ///First co-ordinate 63 66 T x; 64 ///Second co ordinate67 ///Second co-ordinate 65 68 T y; 66 69 … … 73 76 ///The dimension of the vector. 74 77 75 ///Th e dimension of the vector.76 /// This function always returns 2.78 ///This class give back always 2. 79 /// 77 80 int size() const { return 2; } 78 81 … … 136 139 } 137 140 138 ///Return the neg ative of the vector141 ///Return the neg of the vectors 139 142 Point<T> operator-() const { 140 143 Point<T> b=*this; … … 173 176 }; 174 177 175 ///Return a Point176 177 ///Return a Point.178 ///Return an Point 179 180 ///Return an Point 178 181 ///\relates Point 179 182 template <typename T> … … 184 187 ///Return a vector multiplied by a scalar 185 188 186 ///Return a vector multiplied by a scalar .189 ///Return a vector multiplied by a scalar 187 190 ///\relates Point 188 191 template<typename T> Point<T> operator*(const T &u,const Point<T> &x) { … … 192 195 ///Read a plainvector from a stream 193 196 194 ///Read a plainvector from a stream .197 ///Read a plainvector from a stream 195 198 ///\relates Point 196 199 /// … … 220 223 ///Write a plainvector to a stream 221 224 222 ///Write a plainvector to a stream .225 ///Write a plainvector to a stream 223 226 ///\relates Point 224 227 /// … … 232 235 ///Rotate by 90 degrees 233 236 234 ///Returns theparameter rotated by 90 degrees in positive direction.237 ///Returns its parameter rotated by 90 degrees in positive direction. 235 238 ///\relates Point 236 239 /// … … 243 246 ///Rotate by 180 degrees 244 247 245 ///Returns theparameter rotated by 180 degrees.248 ///Returns its parameter rotated by 180 degrees. 246 249 ///\relates Point 247 250 /// … … 254 257 ///Rotate by 270 degrees 255 258 256 ///Returns theparameter rotated by 90 degrees in negative direction.259 ///Returns its parameter rotated by 90 degrees in negative direction. 257 260 ///\relates Point 258 261 /// … … 269 272 /// A class to calculate or store the bounding box of plainvectors. 270 273 /// 274 ///\author Attila Bernath 271 275 template<typename T> 272 276 class BoundingBox { … … 283 287 ///Construct an instance from two points 284 288 285 ///Construct an instance from two points. 286 ///\param a The bottom left corner. 287 ///\param b The top right corner. 288 ///\warning The coordinates of the bottom left corner must be no more 289 ///than those of the top right one. 289 ///Construct an instance from two points 290 ///\warning The coordinates of the bottom-left corner must be no more 291 ///than those of the top-right one 290 292 BoundingBox(Point<T> a,Point<T> b) 291 293 { … … 297 299 ///Construct an instance from four numbers 298 300 299 ///Construct an instance from four numbers. 300 ///\param l The left side of the box. 301 ///\param b The bottom of the box. 302 ///\param r The right side of the box. 303 ///\param t The top of the box. 304 ///\warning The left side must be no more than the right side and 305 ///bottom must be no more than the top. 301 ///Construct an instance from four numbers 302 ///\warning The coordinates of the bottom-left corner must be no more 303 ///than those of the top-right one 306 304 BoundingBox(T l,T b,T r,T t) 307 305 { … … 311 309 } 312 310 313 ///Return \c true if the bounding box is empty. 314 315 ///Return \c true if the bounding box is empty (i.e. return \c false 316 ///if at least one point was added to the box or the coordinates of 317 ///the box were set). 318 ///The coordinates of an empty bounding box are not defined. 311 ///Were any points added? 319 312 bool empty() const { 320 313 return _empty; … … 337 330 338 331 ///Set the bottom left corner. 339 ///It should only be used for non-empty box.332 ///It should only bee used for non-empty box. 340 333 void bottomLeft(Point<T> p) { 341 334 bottom_left = p; … … 353 346 354 347 ///Set the top right corner. 355 ///It should only be used for non-empty box.348 ///It should only bee used for non-empty box. 356 349 void topRight(Point<T> p) { 357 350 top_right = p; … … 369 362 370 363 ///Set the bottom right corner. 371 ///It should only be used for non-empty box.364 ///It should only bee used for non-empty box. 372 365 void bottomRight(Point<T> p) { 373 366 top_right.x = p.x; … … 386 379 387 380 ///Set the top left corner. 388 ///It should only be used for non-empty box.381 ///It should only bee used for non-empty box. 389 382 void topLeft(Point<T> p) { 390 383 top_right.y = p.y; … … 403 396 404 397 ///Set the bottom of the box. 405 ///It should only be used for non-empty box.398 ///It should only bee used for non-empty box. 406 399 void bottom(T t) { 407 400 bottom_left.y = t; … … 419 412 420 413 ///Set the top of the box. 421 ///It should only be used for non-empty box.414 ///It should only bee used for non-empty box. 422 415 void top(T t) { 423 416 top_right.y = t; … … 435 428 436 429 ///Set the left side of the box. 437 ///It should only be used for non-empty box.430 ///It should only bee used for non-empty box 438 431 void left(T t) { 439 432 bottom_left.x = t; … … 451 444 452 445 ///Set the right side of the box. 453 ///It should only be used for non-empty box.446 ///It should only bee used for non-empty box 454 447 void right(T t) { 455 448 top_right.x = t; … … 473 466 474 467 ///Checks whether a point is inside a bounding box 475 bool inside(const Point<T>& u) const{468 bool inside(const Point<T>& u){ 476 469 if (_empty) 477 470 return false; … … 483 476 484 477 ///Increments a bounding box with a point 485 486 ///Increments a bounding box with a point.487 ///488 478 BoundingBox& add(const Point<T>& u){ 489 479 if (_empty){ … … 500 490 } 501 491 502 ///Increments a bounding box to contain another bounding box 503 504 ///Increments a bounding box to contain another bounding box. 505 /// 492 ///Increments a bounding to contain another bounding box 506 493 BoundingBox& add(const BoundingBox &u){ 507 494 if ( !u.empty() ){ … … 513 500 514 501 ///Intersection of two bounding boxes 515 516 ///Intersection of two bounding boxes. 517 /// 518 BoundingBox operator&(const BoundingBox& u) const { 502 BoundingBox operator &(const BoundingBox& u){ 519 503 BoundingBox b; 520 if (this->_empty || u._empty) { 521 b._empty = true; 522 } else { 523 b.bottom_left.x = std::max(this->bottom_left.x,u.bottom_left.x); 524 b.bottom_left.y = std::max(this->bottom_left.y,u.bottom_left.y); 525 b.top_right.x = std::min(this->top_right.x,u.top_right.x); 526 b.top_right.y = std::min(this->top_right.y,u.top_right.y); 527 b._empty = b.bottom_left.x > b.top_right.x || 528 b.bottom_left.y > b.top_right.y; 529 } 504 b.bottom_left.x=std::max(this->bottom_left.x,u.bottom_left.x); 505 b.bottom_left.y=std::max(this->bottom_left.y,u.bottom_left.y); 506 b.top_right.x=std::min(this->top_right.x,u.top_right.x); 507 b.top_right.y=std::min(this->top_right.y,u.top_right.y); 508 b._empty = this->_empty || u._empty || 509 b.bottom_left.x>top_right.x && b.bottom_left.y>top_right.y; 530 510 return b; 531 511 } … … 534 514 535 515 536 ///Map of x-coordinates of a \ref Point "Point"-map537 538 ///\ingroup maps 539 ///Map of x-coordinates of a \ref Point "Point"-map.516 ///Map of x-coordinates of a dim2::Point<>-map 517 518 ///\ingroup maps 519 ///Map of x-coordinates of a dim2::Point<>-map 540 520 /// 541 521 template<class M> … … 591 571 ///Returns a \ref ConstXMap class 592 572 593 ///This function just returns a \ref ConstXMap class.573 ///This function just returns an \ref ConstXMap class. 594 574 /// 595 575 ///\ingroup maps … … 601 581 } 602 582 603 ///Map of y-coordinates of a \ref Point "Point"-map583 ///Map of y-coordinates of a dim2::Point<>-map 604 584 605 585 ///\ingroup maps 606 ///Map of y-coordinates of a \ref Point "Point"-map.586 ///Map of y-coordinates of a dim2::Point<>-map 607 587 /// 608 588 template<class M> … … 620 600 }; 621 601 622 ///Returns a \ref YMap class623 624 ///This function just returns a \ref YMap class.602 ///Returns an \ref YMap class 603 604 ///This function just returns an \ref YMap class. 625 605 /// 626 606 ///\ingroup maps … … 658 638 ///Returns a \ref ConstYMap class 659 639 660 ///This function just returns a \ref ConstYMap class.640 ///This function just returns an \ref ConstYMap class. 661 641 /// 662 642 ///\ingroup maps … … 670 650 671 651 ///\brief Map of the \ref Point::normSquare() "normSquare()" 672 ///of a \ref Point "Point"-map652 ///of an \ref Point "Point"-map 673 653 /// 674 654 ///Map of the \ref Point::normSquare() "normSquare()" 675 ///of a \ref Point "Point"-map.655 ///of an \ref Point "Point"-map 676 656 ///\ingroup maps 677 657 /// … … 691 671 ///Returns a \ref NormSquareMap class 692 672 693 ///This function just returns a \ref NormSquareMap class.673 ///This function just returns an \ref NormSquareMap class. 694 674 /// 695 675 ///\ingroup maps -
lemon/tolerance.h
r16 r7 49 49 ///\sa Tolerance<long double> 50 50 ///\sa Tolerance<int> 51 #if defined __GNUC__ && !defined __STRICT_ANSI__52 51 ///\sa Tolerance<long long int> 53 #endif54 52 ///\sa Tolerance<unsigned int> 55 #if defined __GNUC__ && !defined __STRICT_ANSI__56 53 ///\sa Tolerance<unsigned long long int> 57 #endif58 54 59 55 template<class T> … … 135 131 bool negative(Value a) const { return -_epsilon>a; } 136 132 ///Returns \c true if \c a is \e surely non-zero 137 bool nonZero(Value a) const { return positive(a)||negative(a); } 133 bool nonZero(Value a) const { return positive(a)||negative(a); }; 138 134 139 135 ///@} … … 186 182 bool negative(Value a) const { return -_epsilon>a; } 187 183 ///Returns \c true if \c a is \e surely non-zero 188 bool nonZero(Value a) const { return positive(a)||negative(a); } 184 bool nonZero(Value a) const { return positive(a)||negative(a); }; 189 185 190 186 ///@} … … 237 233 bool negative(Value a) const { return -_epsilon>a; } 238 234 ///Returns \c true if \c a is \e surely non-zero 239 bool nonZero(Value a) const { return positive(a)||negative(a); } 235 bool nonZero(Value a) const { return positive(a)||negative(a); }; 240 236 241 237 ///@} … … 270 266 static bool negative(Value a) { return 0>a; } 271 267 ///Returns \c true if \c a is \e surely non-zero 272 static bool nonZero(Value a) { return a!=0; } 268 static bool nonZero(Value a) { return a!=0; }; 273 269 274 270 ///@} … … 303 299 static bool negative(Value) { return false; } 304 300 ///Returns \c true if \c a is \e surely non-zero 305 static bool nonZero(Value a) { return a!=0; } 301 static bool nonZero(Value a) { return a!=0; }; 306 302 307 303 ///@} … … 337 333 static bool negative(Value a) { return 0>a; } 338 334 ///Returns \c true if \c a is \e surely non-zero 339 static bool nonZero(Value a) { return a!=0;} 335 static bool nonZero(Value a) { return a!=0;}; 340 336 341 337 ///@} … … 370 366 static bool negative(Value) { return false; } 371 367 ///Returns \c true if \c a is \e surely non-zero 372 static bool nonZero(Value a) { return a!=0;} 368 static bool nonZero(Value a) { return a!=0;}; 373 369 374 370 ///@} … … 407 403 static bool negative(Value a) { return 0>a; } 408 404 ///Returns \c true if \c a is \e surely non-zero 409 static bool nonZero(Value a) { return a!=0;} 405 static bool nonZero(Value a) { return a!=0;}; 410 406 411 407 ///@} … … 442 438 static bool negative(Value) { return false; } 443 439 ///Returns \c true if \c a is \e surely non-zero 444 static bool nonZero(Value a) { return a!=0;} 440 static bool nonZero(Value a) { return a!=0;}; 445 441 446 442 ///@} -
test/Makefile.am
r10 r8 4 4 noinst_HEADERS += \ 5 5 test/test_tools.h 6 6 7 7 check_PROGRAMS += \ 8 8 test/dim_test \ 9 test/random_test \10 9 test/test_tools_fail \ 11 10 test/test_tools_pass 12 11 13 12 TESTS += $(check_PROGRAMS) 14 13 XFAIL_TESTS += test/test_tools_fail$(EXEEXT) 15 14 16 15 test_dim_test_SOURCES = test/dim_test.cc 17 test_random_test_SOURCES = test/random_test.cc18 16 test_test_tools_fail_SOURCES = test/test_tools_fail.cc 19 17 test_test_tools_pass_SOURCES = test/test_tools_pass.cc -
test/dim_test.cc
r14 r8 23 23 using namespace std; 24 24 using namespace lemon; 25 26 25 int main() 27 26 { 28 cout << "Testing classes 'dim2::Point' and 'dim2::BoundingBox'." << endl; 27 28 cout << "Testing classes `dim2::Point' and `dim2::BoundingBox'." << endl; 29 29 30 30 typedef dim2::Point<int> Point; 31 32 Point p;33 check( p.size()==2, "Wrong vector initialization.");31 32 Point seged; 33 check(seged.size()==2, "Wrong vector addition"); 34 34 35 35 Point a(1,2); 36 36 Point b(3,4); 37 check(a[0]==1 && a[1]==2, "Wrong vector initialization.");38 37 39 p = a+b; 40 check(p.x==4 && p.y==6, "Wrong vector addition."); 38 check(a[0]==1 && a[1]==2, "Wrong vector addition"); 41 39 42 p = a-b;43 check( p.x==-2 && p.y==-2, "Wrong vector subtraction.");40 seged = a+b; 41 check(seged.x==4 && seged.y==6, "Wrong vector addition"); 44 42 45 check(a.normSquare()==5,"Wrong vector norm calculation."); 46 check(a*b==11, "Wrong vector scalar product."); 43 seged = a-b; 44 check(seged.x==-2 && seged.y==-2, "a-b"); 45 46 check(a.normSquare()==5,"Wrong norm calculation"); 47 check(a*b==11, "a*b"); 47 48 48 49 int l=2; 49 p= a*l;50 check( p.x==2 && p.y==4, "Wrong vector multiplication by a scalar.");50 seged = a*l; 51 check(seged.x==2 && seged.y==4, "a*l"); 51 52 52 p= b/l;53 check( p.x==1 && p.y==2, "Wrong vector division by a scalar.");53 seged = b/l; 54 check(seged.x==1 && seged.y==2, "b/l"); 54 55 55 56 typedef dim2::BoundingBox<int> BB; 56 BB box1; 57 check(box1.empty(), "It should be empty."); 57 BB doboz1; 58 check(doboz1.empty(), "It should be empty."); 59 60 doboz1.add(a); 61 check(!doboz1.empty(), "It should not be empty."); 62 doboz1.add(b); 58 63 59 box1.add(a); 60 check(!box1.empty(), "It should not be empty."); 61 box1.add(b); 64 check(doboz1.bottomLeft().x==1 && 65 doboz1.bottomLeft().y==2 && 66 doboz1.topRight().x==3 && 67 doboz1.topRight().y==4, 68 "added points to box"); 62 69 63 check(box1.bottomLeft().x==1 && 64 box1.bottomLeft().y==2 && 65 box1.topRight().x==3 && 66 box1.topRight().y==4, 67 "Wrong addition of points to box."); 70 seged.x=2;seged.y=3; 71 check(doboz1.inside(seged),"It should be inside."); 68 72 69 p.x=2; p.y=3;70 check( box1.inside(p),"It should be inside.");73 seged.x=1;seged.y=3; 74 check(doboz1.inside(seged),"It should be inside."); 71 75 72 p.x=1; p.y=3;73 check( box1.inside(p), "It shouldbe inside.");76 seged.x=0;seged.y=3; 77 check(!doboz1.inside(seged),"It should not be inside."); 74 78 75 p.x=0; p.y=3; 76 check(!box1.inside(p), "It should not be inside."); 77 78 BB box2(p); 79 check(!box2.empty(), 79 BB doboz2(seged); 80 check(!doboz2.empty(), 80 81 "It should not be empty. Constructed from 1 point."); 81 82 82 box2.add(box1);83 check( box2.inside(p),83 doboz2.add(doboz1); 84 check(doboz2.inside(seged), 84 85 "It should be inside. Incremented a box with another one."); 85 86 return 0;87 86 }
Note: See TracChangeset
for help on using the changeset viewer.