URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2008-01-08 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
* mln/core/concept/point.hh: Add operator/ between points and scalars.
---
point.hh | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
Index: trunk/milena/mln/core/concept/point.hh
===================================================================
--- trunk/milena/mln/core/concept/point.hh (revision 1640)
+++ trunk/milena/mln/core/concept/point.hh (revision 1641)
@@ -35,6 +35,7 @@
# include <mln/core/concept/point_site.hh>
# include <mln/core/concept/dpoint.hh>
+# include <mln/value/concept/scalar.hh>
namespace mln
@@ -104,7 +105,18 @@
template <typename P, typename D>
P& operator-=(Point<P>& p, const Dpoint<D>& dp);
+ /*! \brief Divise a point \p by a scalar \p s.
+ *
+ * \param[in,out] p The targeted point.
+ * \param[in] dp A scalar.
+ * \return A reference to the point \p p once divised by \p s.
+ *
+ * \relates mln::Point
+ */
+ template <typename P, typename D>
+ P& operator/(Point<P>& p, const value::Scalar<D>& dp);
+ // FIXME : add operators and traits?
# ifndef MLN_INCLUDE_ONLY
@@ -146,6 +158,19 @@
return p;
}
+
+ template <typename P, typename D>
+ inline
+ P&
+ operator/(Point<P>& p_, const value::Scalar<D>& s_)
+ {
+ P& p = exact(p_);
+ const D& s = exact(s_);
+ for (unsigned i = 0; i < P::dim; ++i)
+ p[i] /= s;
+ return p;
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln