26 #ifndef MLN_CORE_CONCEPT_GDPOINT_HH
27 # define MLN_CORE_CONCEPT_GDPOINT_HH
33 # include <mln/core/concept/object.hh>
34 # include <mln/core/grids.hh>
35 # include <mln/trait/all.hh>
36 # include <mln/value/scalar.hh>
37 # include <mln/debug/format.hh>
44 template <
typename E>
struct Gdpoint;
53 template <
typename L,
typename R >
54 struct set_binary_< op::
plus,
60 template <
typename L,
typename R >
61 struct set_binary_< op::
minus,
67 template <
typename D,
typename S >
68 struct set_binary_< op::
times,
70 mln::value::Scalar, S >
78 typedef mln::internal::ord_vec< D > ret;
113 template <
typename D>
115 operator<<(std::ostream& ostr, const Gdpoint<D>& dp);
118 template <
typename L,
typename R>
123 template <
typename L,
typename R>
127 template <
typename L,
typename R>
131 template <
typename D,
typename S>
133 operator*(
const Gdpoint<D>& lhs,
const value::Scalar<S>& rhs);
143 template <
typename D>
160 # ifndef MLN_INCLUDE_ONLY
162 template <
typename E>
164 Gdpoint<E>::Gdpoint()
166 typedef mln_grid(E) grid;
167 typedef mln_vec(E) vec;
168 vec (E::*m)() const = & E::to_vec;
173 template <typename D>
175 std::ostream& operator<<(std::ostream& ostr, const Gdpoint<D>& dp)
179 for (
unsigned i = 0; i < n; ++i)
180 ostr <<
debug::format(exact(dp)[i]) << (i == n - 1 ?
')' :
',');
185 template <
typename L,
typename R>
187 bool operator==(
const Gdpoint<L>& lhs,
const Gdpoint<R>& rhs)
189 mlc_equal(mln_grid(L), mln_grid(R))::check();
190 return exact(lhs).to_vec() == exact(rhs).to_vec();
193 template <
typename L,
typename R>
196 operator+(
const Gdpoint<L>& lhs,
const Gdpoint<R>& rhs)
198 mlc_equal(mln_grid(L), mln_grid(R))::check();
199 L tmp = exact(lhs).to_vec() + exact(rhs).to_vec();
203 template <
typename L,
typename R>
206 operator-(
const Gdpoint<L>& lhs,
const Gdpoint<R>& rhs)
208 mlc_equal(mln_grid(L), mln_grid(R))::check();
209 L tmp = exact(lhs).to_vec() - exact(rhs).to_vec();
213 template <
typename D,
typename S>
215 operator*(
const Gdpoint<D>& lhs,
const value::Scalar<S>& rhs)
217 D tmp = exact(lhs).to_vec() * exact(rhs);
228 template <
typename D>
231 from_to_(
const Gdpoint<D>& dp_, mln_site(D)& p)
234 const D& dp = exact(dp_);
235 for (
unsigned i = 0; i < n; ++i)
243 # endif // ! MLN_INCLUDE_ONLY
248 #endif // ! MLN_CORE_CONCEPT_GDPOINT_HH