# HG changeset patch # User deba # Date 1128085959 0 # Node ID 6be54bcc14ecb936012b5c24b4108ae676a4363c # Parent 7db44a7ab93990d685c4eca68d1fbd8ef4eb758b Handling C x A -> A multiplication diff -r 7db44a7ab939 -r 6be54bcc14ec lemon/maps.h --- a/lemon/maps.h Fri Sep 30 13:10:42 2005 +0000 +++ b/lemon/maps.h Fri Sep 30 13:12:39 2005 +0000 @@ -333,10 +333,10 @@ /// ConstMap c_tmp(v); /// AddMap > sh(x,v); ///\endcode - template + template class ShiftMap : public MapBase { typename SmartConstReference::Type m; - typename M::Value v; + C v; public: typedef MapBase Parent; typedef typename Parent::Key Key; @@ -347,8 +347,8 @@ ///Constructor ///\param _m is the undelying map ///\param _v is the shift value - ShiftMap(const M &_m, const Value &_v ) : m(_m), v(_v) {}; - Value operator[](Key k) const {return m[k]+v;} + ShiftMap(const M &_m, const C &_v ) : m(_m), v(_v) {}; + Value operator[](Key k) const {return m[k] + v;} }; ///Returns an \ref ShiftMap class @@ -356,9 +356,9 @@ ///This function just returns an \ref ShiftMap class. ///\relates ShiftMap ///\todo A better name is required. - template - inline ShiftMap shiftMap(const M &m,const typename M::Value &v) { - return ShiftMap(m,v); + template + inline ShiftMap shiftMap(const M &m,const C &v) { + return ShiftMap(m,v); } ///Difference of two maps @@ -426,7 +426,7 @@ ///Scales a maps with a constant. ///This \ref concept::ReadMap "read only map" returns the value of the - ///given map multiplied with a constant value. + ///given map multiplied from the left side with a constant value. ///Its \c Key and \c Value is inherited from \c M. /// ///Actually, @@ -438,10 +438,10 @@ /// ConstMap c_tmp(v); /// MulMap > sc(x,v); ///\endcode - template + template class ScaleMap : public MapBase { typename SmartConstReference::Type m; - typename M::Value v; + C v; public: typedef MapBase Parent; typedef typename Parent::Key Key; @@ -452,8 +452,8 @@ ///Constructor ///\param _m is the undelying map ///\param _v is the scaling value - ScaleMap(const M &_m,const Value &_v ) : m(_m), v(_v) {}; - Value operator[](Key k) const {return m[k]*v;} + ScaleMap(const M &_m, const C &_v ) : m(_m), v(_v) {}; + Value operator[](Key k) const {return v * m[k];} }; ///Returns an \ref ScaleMap class @@ -461,9 +461,9 @@ ///This function just returns an \ref ScaleMap class. ///\relates ScaleMap ///\todo A better name is required. - template - inline ScaleMap scaleMap(const M &m,const typename M::Value &v) { - return ScaleMap(m,v); + template + inline ScaleMap scaleMap(const M &m,const C &v) { + return ScaleMap(m,v); } ///Quotient of two maps @@ -857,10 +857,6 @@ return NotMap(m); } - - - - /// @} }