lemon/lp_base.h
changeset 2115 4cd528a30ec1
parent 2026 8d49961ec50f
child 2144 cd8897f67c26
equal deleted inserted replaced
28:0430ef28e5dd 29:43c8d7f8d173
   294       void simplify() {
   294       void simplify() {
   295 	for (Base::iterator i=Base::begin(); i!=Base::end();) {
   295 	for (Base::iterator i=Base::begin(); i!=Base::end();) {
   296 	  Base::iterator j=i;
   296 	  Base::iterator j=i;
   297 	  ++j;
   297 	  ++j;
   298 	  if ((*i).second==0) Base::erase(i);
   298 	  if ((*i).second==0) Base::erase(i);
   299 	  j=i;
   299 	  i=j;
   300 	}
   300 	}
   301       }
   301       }
   302 
   302 
   303       ///Removes the coefficients closer to zero than \c tolerance.
   303       ///Removes the coefficients closer to zero than \c tolerance.
   304       void simplify(double &tolerance) {
   304       void simplify(double &tolerance) {
   305 	for (Base::iterator i=Base::begin(); i!=Base::end();) {
   305 	for (Base::iterator i=Base::begin(); i!=Base::end();) {
   306 	  Base::iterator j=i;
   306 	  Base::iterator j=i;
   307 	  ++j;
   307 	  ++j;
   308 	  if (std::fabs((*i).second)<tolerance) Base::erase(i);
   308 	  if (std::fabs((*i).second)<tolerance) Base::erase(i);
   309 	  j=i;
   309 	  i=j;
   310 	}
   310 	}
   311       }
   311       }
   312 
   312 
   313       ///Sets all coefficients and the constant component to 0.
   313       ///Sets all coefficients and the constant component to 0.
   314       void clear() {
   314       void clear() {
   511       void simplify() {
   511       void simplify() {
   512 	for (Base::iterator i=Base::begin(); i!=Base::end();) {
   512 	for (Base::iterator i=Base::begin(); i!=Base::end();) {
   513 	  Base::iterator j=i;
   513 	  Base::iterator j=i;
   514 	  ++j;
   514 	  ++j;
   515 	  if ((*i).second==0) Base::erase(i);
   515 	  if ((*i).second==0) Base::erase(i);
   516 	  j=i;
   516 	  i=j;
   517 	}
   517 	}
   518       }
   518       }
   519 
   519 
   520       ///Removes the coefficients closer to zero than \c tolerance.
   520       ///Removes the coefficients closer to zero than \c tolerance.
   521       void simplify(double &tolerance) {
   521       void simplify(double &tolerance) {
   522 	for (Base::iterator i=Base::begin(); i!=Base::end();) {
   522 	for (Base::iterator i=Base::begin(); i!=Base::end();) {
   523 	  Base::iterator j=i;
   523 	  Base::iterator j=i;
   524 	  ++j;
   524 	  ++j;
   525 	  if (std::fabs((*i).second)<tolerance) Base::erase(i);
   525 	  if (std::fabs((*i).second)<tolerance) Base::erase(i);
   526 	  j=i;
   526 	  i=j;
   527 	}
   527 	}
   528       }
   528       }
   529 
   529 
   530 
   530 
   531       ///Sets all coefficients to 0.
   531       ///Sets all coefficients to 0.