diff --git a/dune/solvers/common/interval.hh b/dune/solvers/common/interval.hh index f46d1599b880feb23392ef021d19ba30c9a29f7d..594a489f585fe2c75b802a271bbc7d67e42a758f 100644 --- a/dune/solvers/common/interval.hh +++ b/dune/solvers/common/interval.hh @@ -57,6 +57,15 @@ public: return *this; } + /** \brief Scalar multiplication + */ + Interval& operator*=(const field_type& c) + { + data_[0] *= c; + data_[1] *= c; + return *this; + } + /** \brief Project a scalar onto the interval */ field_type projectIn(const field_type& x) const @@ -97,6 +106,22 @@ private: std::array<field_type,2> data_; }; + +//! Scalar multiplication from the left +template <class field_type> +Interval<field_type> operator*(const field_type& c, const Interval<field_type>& i) +{ + auto ret = i; + return ret *= c; +} + +//! Scalar multiplication from the right +template <class field_type> +Interval<field_type> operator*(const Interval<field_type>& i, const field_type& c) +{ + return c * i; +} + //! Output operator for Interval template <class field_type> inline std::ostream& operator<< (std::ostream& s, const Interval<field_type>& interval)