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)
140 mln_precondition(exact(rhs).domain() == exact(lhs).domain());
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)
152 mln_precondition(exact(rhs).domain() == exact(lhs).domain());
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 trace::entering(
"arith::impl::generic::times_");
197 mln_piter(L) p(lhs.domain());
199 output(p) = lhs(p) * rhs(p);
201 trace::exiting("arith::impl::generic::times_");
204 template <typename L, typename R>
206 void times_inplace_(L& lhs, const R& rhs)
208 trace::entering(
"arith::impl::generic::times_inplace_");
210 mln_piter(R) p(rhs.domain());
214 trace::exiting("arith::impl::generic::times_inplace_");
224 template <typename L, typename R, typename O>
226 void times(const Image<L>& lhs, const Image<R>& rhs, Image<O>& output)
228 trace::entering(
"arith::times");
230 mln_precondition(exact(rhs).domain() == exact(lhs).domain());
231 mln_precondition(exact(output).domain() == exact(lhs).domain());
232 impl::times_(mln_trait_image_speed(L)(), exact(lhs),
233 mln_trait_image_speed(R)(), exact(rhs),
234 mln_trait_image_speed(O)(), exact(output));
236 trace::exiting(
"arith::times");
239 template <
typename I,
typename V,
typename O>
243 trace::entering(
"arith::times_cst");
245 mln_precondition(exact(output).domain() == exact(input).domain());
246 times(input, pw::cst(val) | exact(input).domain(), output);
249 trace::exiting(
"arith::times_cst");
252 template <
typename L,
typename R>
256 trace::entering(
"arith::times_inplace");
258 mln_precondition(exact(rhs).domain() <= exact(lhs).domain());
259 impl::times_inplace_(mln_trait_image_speed(L)(), exact(lhs),
260 mln_trait_image_speed(R)(), exact(rhs));
262 trace::exiting(
"arith::times_inplace");
265 template <
typename I,
typename V>
267 void times_cst_inplace(
Image<I>& input,
const V& val)
269 trace::entering(
"arith::times_cst_inplace");
271 mln_precondition(exact(input).is_valid());
272 times_inplace(input, pw::cst(val) | exact(input).domain());
275 trace::exiting(
"arith::times_cst_inplace");
280 # endif // ! MLN_INCLUDE_ONLY
285 #endif // ! MLN_ARITH_TIMES_HH