lemon/lp_base.h
changeset 1768 1e2e0238e7c8
parent 1612 64f983f5a7d5
child 1771 5faaa9880d4d
equal deleted inserted replaced
14:1fc031b61af1 15:16fc7f6031dc
   301 
   301 
   302       ///\e
   302       ///\e
   303       Expr &operator+=(const Expr &e) {
   303       Expr &operator+=(const Expr &e) {
   304 	for (Base::const_iterator j=e.begin(); j!=e.end(); ++j)
   304 	for (Base::const_iterator j=e.begin(); j!=e.end(); ++j)
   305 	  (*this)[j->first]+=j->second;
   305 	  (*this)[j->first]+=j->second;
   306 	///\todo it might be speeded up using "hints"
       
   307 	const_comp+=e.const_comp;
   306 	const_comp+=e.const_comp;
   308 	return *this;
   307 	return *this;
   309       }
   308       }
   310       ///\e
   309       ///\e
   311       Expr &operator-=(const Expr &e) {
   310       Expr &operator-=(const Expr &e) {
   507 
   506 
   508       ///\e
   507       ///\e
   509       DualExpr &operator+=(const DualExpr &e) {
   508       DualExpr &operator+=(const DualExpr &e) {
   510 	for (Base::const_iterator j=e.begin(); j!=e.end(); ++j)
   509 	for (Base::const_iterator j=e.begin(); j!=e.end(); ++j)
   511 	  (*this)[j->first]+=j->second;
   510 	  (*this)[j->first]+=j->second;
   512 	///\todo it might be speeded up using "hints"
       
   513 	return *this;
   511 	return *this;
   514       }
   512       }
   515       ///\e
   513       ///\e
   516       DualExpr &operator-=(const DualExpr &e) {
   514       DualExpr &operator-=(const DualExpr &e) {
   517 	for (Base::const_iterator j=e.begin(); j!=e.end(); ++j)
   515 	for (Base::const_iterator j=e.begin(); j!=e.end(); ++j)
   999   ///
   997   ///
  1000   inline LpSolverBase::Expr operator+(const LpSolverBase::Expr &a,
   998   inline LpSolverBase::Expr operator+(const LpSolverBase::Expr &a,
  1001 				      const LpSolverBase::Expr &b) 
   999 				      const LpSolverBase::Expr &b) 
  1002   {
  1000   {
  1003     LpSolverBase::Expr tmp(a);
  1001     LpSolverBase::Expr tmp(a);
  1004     tmp+=b; ///\todo Doesn't STL have some special 'merge' algorithm?
  1002     tmp+=b;
  1005     return tmp;
  1003     return tmp;
  1006   }
  1004   }
  1007   ///\e
  1005   ///\e
  1008   
  1006   
  1009   ///\relates LpSolverBase::Expr
  1007   ///\relates LpSolverBase::Expr
  1010   ///
  1008   ///
  1011   inline LpSolverBase::Expr operator-(const LpSolverBase::Expr &a,
  1009   inline LpSolverBase::Expr operator-(const LpSolverBase::Expr &a,
  1012 				      const LpSolverBase::Expr &b) 
  1010 				      const LpSolverBase::Expr &b) 
  1013   {
  1011   {
  1014     LpSolverBase::Expr tmp(a);
  1012     LpSolverBase::Expr tmp(a);
  1015     tmp-=b; ///\todo Doesn't STL have some special 'merge' algorithm?
  1013     tmp-=b;
  1016     return tmp;
  1014     return tmp;
  1017   }
  1015   }
  1018   ///\e
  1016   ///\e
  1019   
  1017   
  1020   ///\relates LpSolverBase::Expr
  1018   ///\relates LpSolverBase::Expr
  1021   ///
  1019   ///
  1022   inline LpSolverBase::Expr operator*(const LpSolverBase::Expr &a,
  1020   inline LpSolverBase::Expr operator*(const LpSolverBase::Expr &a,
  1023 				      const LpSolverBase::Value &b) 
  1021 				      const LpSolverBase::Value &b) 
  1024   {
  1022   {
  1025     LpSolverBase::Expr tmp(a);
  1023     LpSolverBase::Expr tmp(a);
  1026     tmp*=b; ///\todo Doesn't STL have some special 'merge' algorithm?
  1024     tmp*=b;
  1027     return tmp;
  1025     return tmp;
  1028   }
  1026   }
  1029   
  1027   
  1030   ///\e
  1028   ///\e
  1031   
  1029   
  1033   ///
  1031   ///
  1034   inline LpSolverBase::Expr operator*(const LpSolverBase::Value &a,
  1032   inline LpSolverBase::Expr operator*(const LpSolverBase::Value &a,
  1035 				      const LpSolverBase::Expr &b) 
  1033 				      const LpSolverBase::Expr &b) 
  1036   {
  1034   {
  1037     LpSolverBase::Expr tmp(b);
  1035     LpSolverBase::Expr tmp(b);
  1038     tmp*=a; ///\todo Doesn't STL have some special 'merge' algorithm?
  1036     tmp*=a;
  1039     return tmp;
  1037     return tmp;
  1040   }
  1038   }
  1041   ///\e
  1039   ///\e
  1042   
  1040   
  1043   ///\relates LpSolverBase::Expr
  1041   ///\relates LpSolverBase::Expr
  1044   ///
  1042   ///
  1045   inline LpSolverBase::Expr operator/(const LpSolverBase::Expr &a,
  1043   inline LpSolverBase::Expr operator/(const LpSolverBase::Expr &a,
  1046 				      const LpSolverBase::Value &b) 
  1044 				      const LpSolverBase::Value &b) 
  1047   {
  1045   {
  1048     LpSolverBase::Expr tmp(a);
  1046     LpSolverBase::Expr tmp(a);
  1049     tmp/=b; ///\todo Doesn't STL have some special 'merge' algorithm?
  1047     tmp/=b;
  1050     return tmp;
  1048     return tmp;
  1051   }
  1049   }
  1052   
  1050   
  1053   ///\e
  1051   ///\e
  1054   
  1052   
  1182   ///
  1180   ///
  1183   inline LpSolverBase::DualExpr operator+(const LpSolverBase::DualExpr &a,
  1181   inline LpSolverBase::DualExpr operator+(const LpSolverBase::DualExpr &a,
  1184 				      const LpSolverBase::DualExpr &b) 
  1182 				      const LpSolverBase::DualExpr &b) 
  1185   {
  1183   {
  1186     LpSolverBase::DualExpr tmp(a);
  1184     LpSolverBase::DualExpr tmp(a);
  1187     tmp+=b; ///\todo Doesn't STL have some special 'merge' algorithm?
  1185     tmp+=b;
  1188     return tmp;
  1186     return tmp;
  1189   }
  1187   }
  1190   ///\e
  1188   ///\e
  1191   
  1189   
  1192   ///\relates LpSolverBase::DualExpr
  1190   ///\relates LpSolverBase::DualExpr
  1193   ///
  1191   ///
  1194   inline LpSolverBase::DualExpr operator-(const LpSolverBase::DualExpr &a,
  1192   inline LpSolverBase::DualExpr operator-(const LpSolverBase::DualExpr &a,
  1195 				      const LpSolverBase::DualExpr &b) 
  1193 				      const LpSolverBase::DualExpr &b) 
  1196   {
  1194   {
  1197     LpSolverBase::DualExpr tmp(a);
  1195     LpSolverBase::DualExpr tmp(a);
  1198     tmp-=b; ///\todo Doesn't STL have some special 'merge' algorithm?
  1196     tmp-=b;
  1199     return tmp;
  1197     return tmp;
  1200   }
  1198   }
  1201   ///\e
  1199   ///\e
  1202   
  1200   
  1203   ///\relates LpSolverBase::DualExpr
  1201   ///\relates LpSolverBase::DualExpr
  1204   ///
  1202   ///
  1205   inline LpSolverBase::DualExpr operator*(const LpSolverBase::DualExpr &a,
  1203   inline LpSolverBase::DualExpr operator*(const LpSolverBase::DualExpr &a,
  1206 				      const LpSolverBase::Value &b) 
  1204 				      const LpSolverBase::Value &b) 
  1207   {
  1205   {
  1208     LpSolverBase::DualExpr tmp(a);
  1206     LpSolverBase::DualExpr tmp(a);
  1209     tmp*=b; ///\todo Doesn't STL have some special 'merge' algorithm?
  1207     tmp*=b;
  1210     return tmp;
  1208     return tmp;
  1211   }
  1209   }
  1212   
  1210   
  1213   ///\e
  1211   ///\e
  1214   
  1212   
  1216   ///
  1214   ///
  1217   inline LpSolverBase::DualExpr operator*(const LpSolverBase::Value &a,
  1215   inline LpSolverBase::DualExpr operator*(const LpSolverBase::Value &a,
  1218 				      const LpSolverBase::DualExpr &b) 
  1216 				      const LpSolverBase::DualExpr &b) 
  1219   {
  1217   {
  1220     LpSolverBase::DualExpr tmp(b);
  1218     LpSolverBase::DualExpr tmp(b);
  1221     tmp*=a; ///\todo Doesn't STL have some special 'merge' algorithm?
  1219     tmp*=a;
  1222     return tmp;
  1220     return tmp;
  1223   }
  1221   }
  1224   ///\e
  1222   ///\e
  1225   
  1223   
  1226   ///\relates LpSolverBase::DualExpr
  1224   ///\relates LpSolverBase::DualExpr
  1227   ///
  1225   ///
  1228   inline LpSolverBase::DualExpr operator/(const LpSolverBase::DualExpr &a,
  1226   inline LpSolverBase::DualExpr operator/(const LpSolverBase::DualExpr &a,
  1229 				      const LpSolverBase::Value &b) 
  1227 				      const LpSolverBase::Value &b) 
  1230   {
  1228   {
  1231     LpSolverBase::DualExpr tmp(a);
  1229     LpSolverBase::DualExpr tmp(a);
  1232     tmp/=b; ///\todo Doesn't STL have some special 'merge' algorithm?
  1230     tmp/=b;
  1233     return tmp;
  1231     return tmp;
  1234   }
  1232   }
  1235   
  1233   
  1236 
  1234 
  1237 } //namespace lemon
  1235 } //namespace lemon