(Dual)Expr::simplify(double tolerance) added
authoralpar
Fri, 04 Nov 2005 16:21:41 +0000
changeset 17715faaa9880d4d
parent 1770 657de7e5043c
child 1772 dd1e0c442fe0
(Dual)Expr::simplify(double tolerance) added
lemon/lp_base.h
     1.1 --- a/lemon/lp_base.h	Fri Nov 04 16:18:51 2005 +0000
     1.2 +++ b/lemon/lp_base.h	Fri Nov 04 16:21:41 2005 +0000
     1.3 @@ -293,6 +293,16 @@
     1.4  	}
     1.5        }
     1.6  
     1.7 +      ///Removes the coefficients closer to zero than \c tolerance.
     1.8 +      void simplify(double &tolerance) {
     1.9 +	for (Base::iterator i=Base::begin(); i!=Base::end();) {
    1.10 +	  Base::iterator j=i;
    1.11 +	  ++j;
    1.12 +	  if (std::fabs((*i).second)<tolerance) Base::erase(i);
    1.13 +	  j=i;
    1.14 +	}
    1.15 +      }
    1.16 +
    1.17        ///Sets all coefficients and the constant component to 0.
    1.18        void clear() {
    1.19  	Base::clear();
    1.20 @@ -499,6 +509,17 @@
    1.21  	}
    1.22        }
    1.23  
    1.24 +      ///Removes the coefficients closer to zero than \c tolerance.
    1.25 +      void simplify(double &tolerance) {
    1.26 +	for (Base::iterator i=Base::begin(); i!=Base::end();) {
    1.27 +	  Base::iterator j=i;
    1.28 +	  ++j;
    1.29 +	  if (std::fabs((*i).second)<tolerance) Base::erase(i);
    1.30 +	  j=i;
    1.31 +	}
    1.32 +      }
    1.33 +
    1.34 +
    1.35        ///Sets all coefficients to 0.
    1.36        void clear() {
    1.37  	Base::clear();