26 #ifndef MLN_ARITH_DIV_HH
27 # define MLN_ARITH_DIV_HH
35 # include <mln/arith/includes.hh>
38 # include <mln/arith/div.spe.hh>
48 template <
typename L,
typename R>
49 struct set_binary_< op::
div, Image, L, Image, R >
51 typedef mln_trait_op_div(mln_value(L), mln_value(R))
value;
52 typedef mln_ch_value(L, value)
ret;
55 template <typename I, typename S>
56 struct set_binary_< op::div, Image, I, mln::value::Scalar, S >
58 typedef mln_trait_op_div(mln_value(I), S) value;
59 typedef mln_ch_value(I, value) ret;
66 template <typename L, typename R>
68 operator/(const Image<L>& lhs, const Image<R>&
rhs);
70 template <typename L, typename R>
72 operator/=(Image<L>& lhs, const Image<R>& rhs);
75 template <typename I, typename S>
77 operator/(const Image<I>& ima, const value::Scalar<S>& s);
79 template <typename I, typename S>
81 operator/=(Image<I>& ima, const value::Scalar<S>& s);
96 template <
typename L,
typename R,
typename O>
97 void div(
const Image<L>& lhs,
const Image<R>& rhs, Image<O>& output);
108 template <
typename I,
typename V,
typename O>
109 void div_cst(
const Image<I>& input,
const V& val, Image<O>& output);
123 template <
typename L,
typename R>
124 void div_inplace(Image<L>& lhs,
const Image<R>& rhs);
132 # ifndef MLN_INCLUDE_ONLY
135 template <
typename L,
typename R>
137 mln_trait_op_div(L,R)
138 operator/(const Image<L>& lhs, const Image<R>&
rhs)
141 mln_trait_op_div(L,R) tmp;
143 arith::div(lhs, rhs, tmp);
147 template <typename L, typename R>
150 operator/=(Image<L>& lhs, const Image<R>& rhs)
158 template <
typename I,
typename S>
160 mln_trait_op_div(I,S)
161 operator/(const Image<I>& ima, const value::Scalar<S>& s)
163 mln_precondition(
exact(ima).is_valid());
164 mln_precondition(s != 0);
165 mln_trait_op_div(I,S) tmp;
167 arith::div_cst(ima,
exact(s), tmp);
171 template <typename I, typename S>
174 operator/=(Image<I>& ima, const value::Scalar<S>& s)
176 mln_precondition(
exact(ima).is_valid());
192 template <
typename L,
typename R,
typename O>
194 void div_(
const L& lhs,
const R& rhs, O& output)
196 mln_trace(
"arith::impl::generic::div_");
198 mln_piter(L)
p(lhs.domain());
200 output(
p) = lhs(
p) / rhs(
p);
204 template <typename L, typename R>
206 void div_inplace_(L& lhs, const R& rhs)
208 mln_trace(
"arith::impl::generic::div_inplace_");
210 mln_piter(R) p(rhs.domain());
223 template <typename L, typename R, typename O>
225 void div(const Image<L>& lhs, const Image<R>& rhs, Image<O>& output)
227 mln_trace(
"arith::div");
229 mln_precondition(
exact(rhs).domain() ==
exact(lhs).domain());
230 mln_precondition(
exact(output).domain() ==
exact(lhs).domain());
231 impl::div_(mln_trait_image_speed(L)(),
exact(lhs),
232 mln_trait_image_speed(R)(),
exact(rhs),
233 mln_trait_image_speed(O)(),
exact(output));
237 template <
typename I,
typename V,
typename O>
239 void div_cst(
const Image<I>& input,
const V& val, Image<O>& output)
241 mln_trace(
"arith::div_cst");
243 mln_precondition(
exact(output).domain() ==
exact(input).domain());
244 div(input,
pw::cst(val) |
exact(input).domain(), output);
249 template <
typename L,
typename R>
251 void div_inplace(Image<L>& lhs,
const Image<R>& rhs)
253 mln_trace(
"arith::div_inplace");
255 mln_precondition(
exact(rhs).domain() <=
exact(lhs).domain());
256 impl::div_inplace_(mln_trait_image_speed(L)(),
exact(lhs),
257 mln_trait_image_speed(R)(),
exact(rhs));
261 template <
typename I,
typename V>
263 void div_cst_inplace(Image<I>& input,
const V& val)
265 mln_trace(
"arith::div_cst_inplace");
267 mln_precondition(
exact(input).is_valid());
275 # endif // ! MLN_INCLUDE_ONLY
280 #endif // ! MLN_ARITH_DIV_HH