26 #ifndef MLN_ARITH_TIMES_HH
27 # define MLN_ARITH_TIMES_HH
35 # include <mln/arith/includes.hh>
39 # include <mln/arith/times.spe.hh>
48 template <
typename L,
typename R>
49 struct set_binary_< op::
times, Image, L, Image, R >
51 typedef mln_trait_op_times(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::times, Image, I, mln::value::Scalar, S >
58 typedef mln_trait_op_times(mln_value(I), S) value;
59 typedef mln_ch_value(I, value) ret;
66 template <typename L, typename R>
67 mln_trait_op_times(L,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>
76 mln_trait_op_times(I,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 times(
const Image<L>& lhs,
const Image<R>& rhs, Image<O>& output);
108 template <
typename I,
typename V,
typename O>
109 void times_cst(
const Image<I>& input,
const V& val, Image<O>& output);
123 template <
typename L,
typename R>
132 # ifndef MLN_INCLUDE_ONLY
135 template <
typename L,
typename R>
137 mln_trait_op_times(L,R)
138 operator*(const Image<L>& lhs, const Image<R>&
rhs)
141 mln_trait_op_times(L,R) tmp;
143 arith::times(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_times(I,S)
161 operator*(const Image<I>& ima, const value::Scalar<S>& s)
163 mln_precondition(
exact(ima).is_valid());
164 mln_trait_op_times(I,S) tmp;
166 arith::times_cst(ima,
exact(s), tmp);
170 template <typename I, typename S>
173 operator*=(Image<I>& ima, const value::Scalar<S>& s)
175 mln_precondition(
exact(ima).is_valid());
191 template <
typename L,
typename R,
typename O>
193 void times_(
const L& lhs,
const R& rhs, O& output)
195 mln_trace(
"arith::impl::generic::times_");
197 mln_piter(L)
p(lhs.domain());
199 output(
p) = lhs(
p) * rhs(
p);
203 template <typename L, typename R>
205 void times_inplace_(L& lhs, const R& rhs)
207 mln_trace(
"arith::impl::generic::times_inplace_");
209 mln_piter(R) p(rhs.domain());
222 template <typename L, typename R, typename O>
224 void times(const Image<L>& lhs, const Image<R>& rhs, Image<O>& output)
226 mln_trace(
"arith::times");
228 mln_precondition(
exact(rhs).domain() ==
exact(lhs).domain());
229 mln_precondition(
exact(output).domain() ==
exact(lhs).domain());
230 impl::times_(mln_trait_image_speed(L)(),
exact(lhs),
231 mln_trait_image_speed(R)(),
exact(rhs),
232 mln_trait_image_speed(O)(),
exact(output));
236 template <
typename I,
typename V,
typename O>
238 void times_cst(
const Image<I>& input,
const V& val, Image<O>& output)
240 mln_trace(
"arith::times_cst");
242 mln_precondition(
exact(output).domain() ==
exact(input).domain());
243 times(input,
pw::cst(val) |
exact(input).domain(), output);
248 template <
typename L,
typename R>
252 mln_trace(
"arith::times_inplace");
254 mln_precondition(
exact(rhs).domain() <=
exact(lhs).domain());
255 impl::times_inplace_(mln_trait_image_speed(L)(),
exact(lhs),
256 mln_trait_image_speed(R)(),
exact(rhs));
260 template <
typename I,
typename V>
262 void times_cst_inplace(Image<I>& input,
const V& val)
264 mln_trace(
"arith::times_cst_inplace");
266 mln_precondition(
exact(input).is_valid());
274 # endif // ! MLN_INCLUDE_ONLY
279 #endif // ! MLN_ARITH_TIMES_HH