COIN-OR::LEMON - Graph Library

Changeset 1691:6be54bcc14ec in lemon-0.x


Ignore:
Timestamp:
09/30/05 15:12:39 (14 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2217
Message:

Handling C x A -> A multiplication

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/maps.h

    r1679 r1691  
    334334  ///  AddMap<X, ConstMap<X::Key, X::Value> > sh(x,v);
    335335  ///\endcode
    336   template<typename M, typename NC = False>
     336  template<typename M, typename C = typename M::Value, typename NC = False>
    337337  class ShiftMap : public MapBase<typename M::Key, typename M::Value, NC> {
    338338    typename SmartConstReference<M>::Type m;
    339     typename M::Value v;
     339    C v;
    340340  public:
    341341    typedef MapBase<typename M::Key, typename M::Value, NC> Parent;
     
    348348    ///\param _m is the undelying map
    349349    ///\param _v is the shift value
    350     ShiftMap(const M &_m, const Value &_v ) : m(_m), v(_v) {};
    351     Value operator[](Key k) const {return m[k]+v;}
     350    ShiftMap(const M &_m, const C &_v ) : m(_m), v(_v) {};
     351    Value operator[](Key k) const {return m[k] + v;}
    352352  };
    353353 
     
    357357  ///\relates ShiftMap
    358358  ///\todo A better name is required.
    359   template<typename M>
    360   inline ShiftMap<M, True> shiftMap(const M &m,const typename M::Value &v) {
    361     return ShiftMap<M, True>(m,v);
     359  template<typename M, typename C>
     360  inline ShiftMap<M, C, True> shiftMap(const M &m,const C &v) {
     361    return ShiftMap<M, C, True>(m,v);
    362362  }
    363363
     
    427427
    428428  ///This \ref concept::ReadMap "read only map" returns the value of the
    429   ///given map multiplied with a constant value.
     429  ///given map multiplied from the left side with a constant value.
    430430  ///Its \c Key and \c Value is inherited from \c M.
    431431  ///
     
    439439  ///  MulMap<X, ConstMap<X::Key, X::Value> > sc(x,v);
    440440  ///\endcode
    441   template<typename M, typename NC = False>
     441  template<typename M, typename C = typename M::Value, typename NC = False>
    442442  class ScaleMap : public MapBase<typename M::Key, typename M::Value, NC> {
    443443    typename SmartConstReference<M>::Type m;
    444     typename M::Value v;
     444    C v;
    445445  public:
    446446    typedef MapBase<typename M::Key, typename M::Value, NC> Parent;
     
    453453    ///\param _m is the undelying map
    454454    ///\param _v is the scaling value
    455     ScaleMap(const M &_m,const Value &_v ) : m(_m), v(_v) {};
    456     Value operator[](Key k) const {return m[k]*v;}
     455    ScaleMap(const M &_m, const C &_v ) : m(_m), v(_v) {};
     456    Value operator[](Key k) const {return v * m[k];}
    457457  };
    458458 
     
    462462  ///\relates ScaleMap
    463463  ///\todo A better name is required.
    464   template<typename M>
    465   inline ScaleMap<M, True> scaleMap(const M &m,const typename M::Value &v) {
    466     return ScaleMap<M, True>(m,v);
     464  template<typename M, typename C>
     465  inline ScaleMap<M, C, True> scaleMap(const M &m,const C &v) {
     466    return ScaleMap<M, C, True>(m,v);
    467467  }
    468468
     
    858858  }
    859859
    860 
    861 
    862 
    863 
    864860  /// @}
    865861}
Note: See TracChangeset for help on using the changeset viewer.