Skip to content
Snippets Groups Projects

Interval: scalar multiplication

1 file
+ 25
0
Compare changes
  • Side-by-side
  • Inline
@@ -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)
Loading