Changeset 1097:c91e765266d7 in lemon0.x
 Timestamp:
 01/26/05 16:54:06 (18 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@1496
 Location:
 src/work/marci/lp
 Files:

 2 added
 2 edited
Legend:
 Unmodified
 Added
 Removed

src/work/marci/lp/lp_solver_wrapper_3.h
r1081 r1097 9 9 // #include <stdio.h> 10 10 #include <stdlib.h> 11 #include <iostream> 12 #include <map> 11 13 // #include <stdio> 12 14 //#include <stdlib> … … 157 159 }; 158 160 161 template <typename _Col, typename _Value> 162 class Expr; 163 164 template <typename _Col, typename _Value> 165 class SmallExpr { 166 template <typename _C, typename _V> 167 friend class Expr; 168 protected: 169 _Col col; 170 _Value value; 171 public: 172 SmallExpr(_Col _col) : col(_col), value(1) { 173 } 174 SmallExpr& operator *= (_Value _value) { 175 value*=_value; 176 return *this; 177 } 178 // template <typename _C, typename _V> 179 // friend SmallExpr<_C, _V> operator* (_V _value, 180 // const SmallExpr<_C, _V>& expr); 181 template <typename _C, typename _V> 182 friend std::ostream& operator<<(std::ostream& os, 183 const SmallExpr<_C, _V>& expr); 184 }; 185 186 template <typename _Col, typename _Value> 187 SmallExpr<_Col, _Value> 188 operator* (_Value value, 189 const SmallExpr<_Col, _Value>& expr) { 190 SmallExpr<_Col, _Value> tmp; 191 tmp=expr; 192 tmp*=value; 193 return tmp; 194 } 195 196 template <typename _Col, typename _Value> 197 std::ostream& operator<<(std::ostream& os, 198 const SmallExpr<_Col, _Value>& expr) { 199 os << expr.value << "*" << expr.col; 200 return os; 201 } 202 203 template <typename _Col, typename _Value> 204 class Expr { 205 protected: 206 typedef 207 typename std::map<_Col, _Value> Data; 208 Data data; 209 public: 210 Expr() { } 211 Expr(SmallExpr<_Col, _Value> expr) { 212 data.insert(std::make_pair(expr.col, expr.value)); 213 } 214 // Expr(_Col col) { 215 // data.insert(std::make_pair(col, 1)); 216 // } 217 Expr& operator*=(_Value _value) { 218 for (typename Data::iterator i=data.begin(); 219 i!=data.end(); ++i) { 220 (*i).second *= _value; 221 } 222 return *this; 223 } 224 Expr& operator+=(SmallExpr<_Col, _Value> expr) { 225 typename Data::iterator i=data.find(expr.col); 226 if (i==data.end()) { 227 data.insert(std::make_pair(expr.col, expr.value)); 228 } else { 229 (*i).second+=expr.value; 230 } 231 return *this; 232 } 233 // template <typename _C, typename _V> 234 // friend Expr<_C, _V> operator*(_V _value, const Expr<_C, _V>& expr); 235 template <typename _C, typename _V> 236 friend std::ostream& operator<<(std::ostream& os, 237 const Expr<_C, _V>& expr); 238 }; 239 240 template <typename _Col, typename _Value> 241 Expr<_Col, _Value> operator*(_Value _value, 242 const Expr<_Col, _Value>& expr) { 243 Expr<_Col, _Value> tmp; 244 tmp=expr; 245 tmp*=_value; 246 return tmp; 247 } 248 249 template <typename _Col, typename _Value> 250 std::ostream& operator<<(std::ostream& os, 251 const Expr<_Col, _Value>& expr) { 252 for (typename Expr<_Col, _Value>::Data::const_iterator i= 253 expr.data.begin(); 254 i!=expr.data.end(); ++i) { 255 os << (*i).second << "*" << (*i).first << " "; 256 } 257 return os; 258 } 259 159 260 /*! \e 160 261 */ 
src/work/marci/lp/makefile
r1075 r1097 6 6 LDFLAGS = lglpk#lcplex lm lpthread lilocplex L/usr/local/cplex/cplex75/lib/i86_linux2_glibc2.2_gcc3.0/static_mt# L$(GLPKROOT)/lib 7 7 8 BINARIES = cplex_1max_flow_by_lp# sample sample2 sample11 sample158 BINARIES = expression_test max_flow_by_lp# sample sample2 sample11 sample15 9 9 10 10 #include ../makefile
Note: See TracChangeset
for help on using the changeset viewer.