26 #ifndef MLN_WIN_MULTIPLE_HH
27 # define MLN_WIN_MULTIPLE_HH
35 # include <mln/core/internal/window_base.hh>
36 # include <mln/core/internal/site_relative_iterator_base.hh>
37 # include <mln/util/array.hh>
47 template <
typename W,
typename F>
class multiple;
48 template <
typename W,
typename F>
class multiple_qiter;
56 template <
typename W,
typename F>
57 struct window_< win::multiple<W,F> >
59 typedef trait::window::size::fixed size;
60 typedef trait::window::support::regular support;
61 typedef trait::window::definition::n_ary definition;
75 template <
typename W,
typename F>
78 :
public internal::window_base< mln_dpsite(W), multiple<W,F> >,
80 private metal::and_< mlc_is(mln_trait_window_size(W),
81 trait::window::size::fixed),
82 mlc_is(mln_trait_window_support(W),
83 trait::window::support::regular) >::check_t
87 typedef mln_dpsite(W) dpsite;
88 typedef mln_psite(W) psite;
89 typedef mln_site(W) site;
93 typedef multiple_qiter<W,F> fwd_qiter;
94 typedef multiple_qiter<W,F> bkd_qiter;
95 typedef multiple_qiter<W,F> qiter;
103 bool is_empty()
const;
105 void set_window(
unsigned i,
const W& win);
107 const W& window_(
unsigned i)
const;
109 unsigned nwindows()
const;
111 const F&
function()
const;
113 unsigned size()
const;
115 const mln_dpsite(W)& ith_dp_around(
unsigned i,
const mln_psite(W)& p)
const;
117 bool is_centered()
const;
119 bool is_symmetric()
const;
123 unsigned delta()
const;
132 template <
typename W,
typename F>
134 :
public internal::site_relative_iterator_base< multiple<W,F>,
135 multiple_qiter<W,F> >
137 typedef multiple_qiter<W,F> self_;
138 typedef internal::site_relative_iterator_base< multiple<W,F>, self_ > super_;
142 template <
typename Pref>
149 template <
typename Pref>
153 bool is_valid_()
const;
165 mln_psite(W) compute_p_() const;
174 # ifndef MLN_INCLUDE_ONLY
178 template <
typename W,
typename F>
185 template <
typename W,
typename F>
187 multiple<W,F>::multiple(
const F& f)
192 template <
typename W,
typename F>
195 multiple<W,F>::is_empty()
const
197 return win_.is_empty();
200 template <
typename W,
typename F>
203 multiple<W,F>::set_window(
unsigned i,
const W& win)
205 mln_precondition(i == win_.nelements());
207 mln_precondition(win.size() == win_[0].size());
211 template <
typename W,
typename F>
214 multiple<W,F>::window_(
unsigned i)
const
216 mln_precondition(i < win_.nelements());
220 template <
typename W,
typename F>
223 multiple<W,F>::nwindows()
const
225 return win_.nelements();
228 template <
typename W,
typename F>
231 multiple<W,F>::function()
const
236 template <
typename W,
typename F>
239 multiple<W,F>::size()
const
241 mln_precondition(win_.nelements() >= 2);
242 unsigned s = win_[0].size();
243 for (
unsigned i = 1; i < win_.nelements(); ++i)
244 mln_precondition(win_[i].size() == s);
248 template <
typename W,
typename F>
251 multiple<W,F>::is_centered()
const
253 mln_precondition(win_.nelements() >= 1);
254 for (
unsigned i = 0; i < win_.nelements(); ++i)
255 if (! win_[i].is_centered())
260 template <
typename W,
typename F>
263 multiple<W,F>::is_symmetric()
const
265 mln_precondition(win_.nelements() >= 1);
266 for (
unsigned i = 0; i < win_.nelements(); ++i)
267 if (! win_[i].is_symmetric())
273 template <
typename W,
typename F>
278 mln_precondition(win_.nelements() >= 1);
279 for (
unsigned i = 0; i < win_.nelements(); ++i)
283 template <
typename W,
typename F>
286 multiple<W,F>::delta()
const
288 mln_precondition(win_.nelements() >= 1);
289 unsigned d = win_[0].delta();
290 for (
unsigned i = 1; i < win_.nelements(); ++i)
292 unsigned d_i = win_[i].delta();
299 template <
typename W,
typename F>
302 multiple<W,F>::ith_dp_around(
unsigned i,
const mln_psite(W)& p)
const
304 mln_precondition(f_(p) < win_.nelements());
305 mln_precondition(i < win_[f_(p)].size());
306 return win_[f_(p)].dp(i);
312 template <
typename W,
typename F>
314 multiple_qiter<W,F>::multiple_qiter()
318 template <
typename W,
typename F>
319 template <
typename Pref>
321 multiple_qiter<W,F>::multiple_qiter(
const multiple<W,F>& w,
const Pref& c)
326 template <
typename W,
typename F>
327 template <
typename Pref>
330 multiple_qiter<W,F>::init_(
const multiple<W,F>& w,
const Pref& c)
338 template <
typename W,
typename F>
341 multiple_qiter<W,F>::change_target(
const multiple<W,F>& w)
344 this->super_::change_target(w);
347 template <
typename W,
typename F>
350 multiple_qiter<W,F>::is_valid_()
const
355 template <
typename W,
typename F>
358 multiple_qiter<W,F>::invalidate_()
363 template <
typename W,
typename F>
366 multiple_qiter<W,F>::do_start_()
371 template <
typename W,
typename F>
374 multiple_qiter<W,F>::do_next_()
379 template <
typename W,
typename F>
382 multiple_qiter<W,F>::compute_p_()
const
384 return *this->c_ + this->s_->ith_dp_around(i_, *this->c_);
387 # endif // ! MLN_INCLUDE_ONLY
395 #endif // ! MLN_WIN_MULTIPLE_HH