331 ///is equivalent with |
331 ///is equivalent with |
332 ///\code |
332 ///\code |
333 /// ConstMap<X::Key, X::Value> c_tmp(v); |
333 /// ConstMap<X::Key, X::Value> c_tmp(v); |
334 /// AddMap<X, ConstMap<X::Key, X::Value> > sh(x,v); |
334 /// AddMap<X, ConstMap<X::Key, X::Value> > sh(x,v); |
335 ///\endcode |
335 ///\endcode |
336 template<typename M, typename NC = False> |
336 template<typename M, typename C = typename M::Value, typename NC = False> |
337 class ShiftMap : public MapBase<typename M::Key, typename M::Value, NC> { |
337 class ShiftMap : public MapBase<typename M::Key, typename M::Value, NC> { |
338 typename SmartConstReference<M>::Type m; |
338 typename SmartConstReference<M>::Type m; |
339 typename M::Value v; |
339 C v; |
340 public: |
340 public: |
341 typedef MapBase<typename M::Key, typename M::Value, NC> Parent; |
341 typedef MapBase<typename M::Key, typename M::Value, NC> Parent; |
342 typedef typename Parent::Key Key; |
342 typedef typename Parent::Key Key; |
343 typedef typename Parent::Value Value; |
343 typedef typename Parent::Value Value; |
344 |
344 |
345 ///Constructor |
345 ///Constructor |
346 |
346 |
347 ///Constructor |
347 ///Constructor |
348 ///\param _m is the undelying map |
348 ///\param _m is the undelying map |
349 ///\param _v is the shift value |
349 ///\param _v is the shift value |
350 ShiftMap(const M &_m, const Value &_v ) : m(_m), v(_v) {}; |
350 ShiftMap(const M &_m, const C &_v ) : m(_m), v(_v) {}; |
351 Value operator[](Key k) const {return m[k]+v;} |
351 Value operator[](Key k) const {return m[k] + v;} |
352 }; |
352 }; |
353 |
353 |
354 ///Returns an \ref ShiftMap class |
354 ///Returns an \ref ShiftMap class |
355 |
355 |
356 ///This function just returns an \ref ShiftMap class. |
356 ///This function just returns an \ref ShiftMap class. |
357 ///\relates ShiftMap |
357 ///\relates ShiftMap |
358 ///\todo A better name is required. |
358 ///\todo A better name is required. |
359 template<typename M> |
359 template<typename M, typename C> |
360 inline ShiftMap<M, True> shiftMap(const M &m,const typename M::Value &v) { |
360 inline ShiftMap<M, C, True> shiftMap(const M &m,const C &v) { |
361 return ShiftMap<M, True>(m,v); |
361 return ShiftMap<M, C, True>(m,v); |
362 } |
362 } |
363 |
363 |
364 ///Difference of two maps |
364 ///Difference of two maps |
365 |
365 |
366 ///This \ref concept::ReadMap "read only map" returns the difference |
366 ///This \ref concept::ReadMap "read only map" returns the difference |
436 ///is equivalent with |
436 ///is equivalent with |
437 ///\code |
437 ///\code |
438 /// ConstMap<X::Key, X::Value> c_tmp(v); |
438 /// ConstMap<X::Key, X::Value> c_tmp(v); |
439 /// MulMap<X, ConstMap<X::Key, X::Value> > sc(x,v); |
439 /// MulMap<X, ConstMap<X::Key, X::Value> > sc(x,v); |
440 ///\endcode |
440 ///\endcode |
441 template<typename M, typename NC = False> |
441 template<typename M, typename C = typename M::Value, typename NC = False> |
442 class ScaleMap : public MapBase<typename M::Key, typename M::Value, NC> { |
442 class ScaleMap : public MapBase<typename M::Key, typename M::Value, NC> { |
443 typename SmartConstReference<M>::Type m; |
443 typename SmartConstReference<M>::Type m; |
444 typename M::Value v; |
444 C v; |
445 public: |
445 public: |
446 typedef MapBase<typename M::Key, typename M::Value, NC> Parent; |
446 typedef MapBase<typename M::Key, typename M::Value, NC> Parent; |
447 typedef typename Parent::Key Key; |
447 typedef typename Parent::Key Key; |
448 typedef typename Parent::Value Value; |
448 typedef typename Parent::Value Value; |
449 |
449 |
450 ///Constructor |
450 ///Constructor |
451 |
451 |
452 ///Constructor |
452 ///Constructor |
453 ///\param _m is the undelying map |
453 ///\param _m is the undelying map |
454 ///\param _v is the scaling value |
454 ///\param _v is the scaling value |
455 ScaleMap(const M &_m,const Value &_v ) : m(_m), v(_v) {}; |
455 ScaleMap(const M &_m, const C &_v ) : m(_m), v(_v) {}; |
456 Value operator[](Key k) const {return m[k]*v;} |
456 Value operator[](Key k) const {return v * m[k];} |
457 }; |
457 }; |
458 |
458 |
459 ///Returns an \ref ScaleMap class |
459 ///Returns an \ref ScaleMap class |
460 |
460 |
461 ///This function just returns an \ref ScaleMap class. |
461 ///This function just returns an \ref ScaleMap class. |
462 ///\relates ScaleMap |
462 ///\relates ScaleMap |
463 ///\todo A better name is required. |
463 ///\todo A better name is required. |
464 template<typename M> |
464 template<typename M, typename C> |
465 inline ScaleMap<M, True> scaleMap(const M &m,const typename M::Value &v) { |
465 inline ScaleMap<M, C, True> scaleMap(const M &m,const C &v) { |
466 return ScaleMap<M, True>(m,v); |
466 return ScaleMap<M, C, True>(m,v); |
467 } |
467 } |
468 |
468 |
469 ///Quotient of two maps |
469 ///Quotient of two maps |
470 |
470 |
471 ///This \ref concept::ReadMap "read only map" returns the quotient of the |
471 ///This \ref concept::ReadMap "read only map" returns the quotient of the |