15inline void Ensemble::W2(
const T& f,
const T& g,
const M& gmask)
17 using value_type =
typename T::value_type;
18 using mask_type =
typename M::value_type;
20 static_assert(std::is_integral<mask_type>::value,
"Integral mask required.");
24 GOOSEEYE_ASSERT(f.dimension() == m_shape_orig.size(), std::out_of_range);
25 GOOSEEYE_ASSERT(xt::all(xt::equal(gmask, 0) || xt::equal(gmask, 1)), std::out_of_range);
26 GOOSEEYE_ASSERT(m_stat == Type::W2 || m_stat == Type::Unset, std::out_of_range);
32 xt::pad_mode pad_mode = xt::pad_mode::constant;
37 pad_mode = xt::pad_mode::periodic;
46 xt::pad(xt::atleast_3d(gmask), m_pad, xt::pad_mode::constant, mask_value);
49 for (
size_t h = m_pad[0][0]; h < F.shape(0) - m_pad[0][1]; ++h) {
50 for (
size_t i = m_pad[1][0]; i < F.shape(1) - m_pad[1][1]; ++i) {
51 for (
size_t j = m_pad[2][0]; j < F.shape(2) - m_pad[2][1]; ++j) {
55 xt::range(h - m_pad[0][0], h + m_pad[0][1] + 1),
56 xt::range(i - m_pad[1][0], i + m_pad[1][1] + 1),
57 xt::range(j - m_pad[2][0], j + m_pad[2][1] + 1));
59 auto Gmii = 1.0 - xt::view(
61 xt::range(h - m_pad[0][0], h + m_pad[0][1] + 1),
62 xt::range(i - m_pad[1][0], i + m_pad[1][1] + 1),
63 xt::range(j - m_pad[2][0], j + m_pad[2][1] + 1));
65 if (F(h, i, j) != 0) {
66 m_first += Fd(h, i, j) * Gi * Gmii;
69 m_norm += F(h, i, j) * Gmii;