351 undecay_expression m_e;
352 functor_type m_functor;
376 template <
class F,
class S, layout_type L>
377 struct functorview_temporary_type_impl
382 template <
class F,
class T, std::
size_t N, layout_type L>
383 struct functorview_temporary_type_impl<F, std::array<T, N>, L>
385 using type = xtensor<typename F::value_type, N, L>;
389 template <
class F,
class E>
399 template <
class F,
class CT>
402 template <
class F,
class CT>
405 using xexpression_type = std::decay_t<CT>;
407 using functor_type = std::decay_t<F>;
408 using reference =
decltype(std::declval<F>()(std::declval<xexpression_type>()()));
409 using const_reference =
decltype(std::declval<F>()(std::declval<const xexpression_type>()()));
410 using size_type =
typename xexpression_type::size_type;
411 using temporary_type =
typename xfunctor_view_temporary_type<F, xexpression_type>::type;
414 template <
class F,
class CT,
class T>
439 template <
class F,
class CT>
442 public extension::xfunctor_view_base_t<F, CT>
467 void assign_temporary_impl(temporary_type&&
tmp);
476 template <
class F,
class CT>
479 template <
class F,
class CT>
482 using xexpression_type = std::decay_t<CT>;
484 using functor_type = std::decay_t<F>;
485 using reference =
typename functor_type::reference;
486 using const_reference =
typename functor_type::const_reference;
487 using size_type =
typename xexpression_type::size_type;
488 using temporary_type =
typename xfunctor_view_temporary_type<F, xexpression_type>::type;
491 template <
class F,
class CT,
class T>
508 template <
class F,
class CT>
511 public extension::xfunctor_view_base_t<F, CT>
517 using xexpression_type = std::decay_t<CT>;
519 using shape_type =
typename base_type::shape_type;
520 using strides_type =
typename xexpression_type::strides_type;
530 template <
class S = shape_type>
531 auto resize(
S&& shape,
bool force =
false);
533 template <
class S = shape_type>
536 template <
class S = shape_type>
537 auto resize(
S&& shape,
const strides_type&
strides);
539 template <
class S = shape_type>
540 auto& reshape(
S&& shape,
layout_type layout = base_type::static_layout) &;
545 void assign_temporary_impl(temporary_type&&
tmp);
558 using pointer = std::add_pointer_t<std::remove_reference_t<R>>;
563 template <
class F,
class IT>
564 struct xfunctor_invoker
566 using type =
decltype(std::declval<F>()(*(std::declval<IT>())));
569 template <
class F,
class IT>
570 using xfunctor_invoker_t =
typename xfunctor_invoker<F, IT>::type;
573 template <
class F,
class IT>
575 xfunctor_iterator<F, IT>,
576 typename std::decay_t<F>::value_type,
577 typename std::iterator_traits<IT>::difference_type,
578 typename xproxy_inner_types<detail::xfunctor_invoker_t<F, IT>>::pointer,
579 typename xproxy_inner_types<detail::xfunctor_invoker_t<F, IT>>::reference>
583 using functor_type =
F;
584 using subiterator_traits = std::iterator_traits<IT>;
587 using value_type =
typename functor_type::value_type;
588 using reference =
typename proxy_inner::reference;
589 using pointer =
typename proxy_inner::pointer;
590 using difference_type =
typename subiterator_traits::difference_type;
591 using iterator_category =
typename subiterator_traits::iterator_category;
605 reference operator*()
const;
606 pointer operator->()
const;
614 functor_type* p_functor;
617 template <
class F,
class IT>
620 template <
class F,
class IT>
627 template <
class F,
class ST>
632 using functor_type =
F;
635 using value_type =
typename functor_type::value_type;
636 using reference =
typename proxy_inner::reference;
637 using pointer = std::remove_reference_t<reference>*;
638 using size_type =
typename ST::size_type;
639 using difference_type =
typename ST::difference_type;
641 using shape_type =
typename ST::shape_type;
646 reference operator*()
const;
648 void step(size_type
dim);
649 void step_back(size_type
dim);
650 void step(size_type
dim, size_type
n);
651 void step_back(size_type
dim, size_type
n);
652 void reset(size_type
dim);
653 void reset_back(size_type
dim);
661 functor_type* p_functor;
681 , m_functor(functor_type())
692 template <
class Func,
class E>
694 : m_e(std::forward<E>(
e))
695 , m_functor(std::forward<Func>(
func))
729 return m_e.strides();
738 return m_e.backstrides();
753 return m_e.is_contiguous();
769 template <
class... Args>
772 XTENSOR_TRY(check_index(
shape(),
args...));
773 XTENSOR_CHECK_DIMENSION(
shape(),
args...);
774 return m_functor(m_e(
args...));
797 template <
class...
Args>
800 return m_functor(m_e.unchecked(
args...));
815 return m_functor(m_e.element(
first,
last));
825 template <
class...
Args>
828 XTENSOR_TRY(check_index(
shape(),
args...));
829 XTENSOR_CHECK_DIMENSION(
shape(),
args...);
830 return m_functor(m_e(
args...));
853 template <
class...
Args>
856 return m_functor(m_e.unchecked(
args...));
871 return m_functor(m_e.element(
first,
last));
921 return m_e.has_linear_assign(
strides);
935 template <layout_type L>
950 template <layout_type L>
961 template <layout_type L>
973 template <layout_type L>
976 return this->
template cend<L>();
984 template <layout_type L>
999 template <layout_type L>
1022 template <
class S, layout_type L>
1036 template <
class S, layout_type L>
1050 template <
class S, layout_type L>
1065 template <
class S, layout_type L>
1079 template <
class S, layout_type L>
1094 template <
class S, layout_type L>
1111 template <layout_type L>
1126 template <layout_type L>
1140 template <layout_type L>
1152 template <layout_type L>
1163 template <layout_type L>
1178 template <layout_type L>
1201 template <
class S, layout_type L>
1215 template <
class S, layout_type L>
1229 template <
class S, layout_type L>
1244 template <
class S, layout_type L>
1259 template <
class S, layout_type L>
1274 template <
class S, layout_type L>
1286 return linear_iterator(m_e.linear_begin(), &m_functor);
1290 inline auto xfunctor_applier_base<D>::linear_end() noexcept -> linear_iterator
1292 return linear_iterator(m_e.linear_end(), &m_functor);
1296 inline auto xfunctor_applier_base<D>::linear_begin() const noexcept -> const_linear_iterator
1298 return const_linear_iterator(m_e.linear_begin(), &m_functor);
1302 inline auto xfunctor_applier_base<D>::linear_end() const noexcept -> const_linear_iterator
1304 return const_linear_iterator(m_e.linear_end(), &m_functor);
1308 inline auto xfunctor_applier_base<D>::linear_cbegin() const noexcept -> const_linear_iterator
1310 return const_linear_iterator(m_e.linear_cbegin(), &m_functor);
1314 inline auto xfunctor_applier_base<D>::linear_cend() const noexcept -> const_linear_iterator
1316 return const_linear_iterator(m_e.linear_cend(), &m_functor);
1320 inline auto xfunctor_applier_base<D>::linear_rbegin() noexcept -> reverse_linear_iterator
1322 return reverse_linear_iterator(m_e.linear_rbegin(), &m_functor);
1326 inline auto xfunctor_applier_base<D>::linear_rend() noexcept -> reverse_linear_iterator
1328 return reverse_linear_iterator(m_e.linear_rend(), &m_functor);
1332 inline auto xfunctor_applier_base<D>::linear_rbegin() const noexcept -> const_reverse_linear_iterator
1334 return const_reverse_linear_iterator(m_e.linear_rbegin(), &m_functor);
1338 inline auto xfunctor_applier_base<D>::linear_rend() const noexcept -> const_reverse_linear_iterator
1340 return const_reverse_linear_iterator(m_e.linear_rend(), &m_functor);
1344 inline auto xfunctor_applier_base<D>::linear_crbegin() const noexcept -> const_reverse_linear_iterator
1346 return const_reverse_linear_iterator(m_e.linear_crbegin(), &m_functor);
1350 inline auto xfunctor_applier_base<D>::linear_crend() const noexcept -> const_reverse_linear_iterator
1352 return const_reverse_linear_iterator(m_e.linear_crend(), &m_functor);
1361 inline auto xfunctor_applier_base<D>::stepper_begin(
const S&
shape)
noexcept -> stepper
1363 return stepper(m_e.stepper_begin(
shape), &m_functor);
1368 inline auto xfunctor_applier_base<D>::stepper_end(
const S&
shape,
layout_type l)
noexcept -> stepper
1370 return stepper(m_e.stepper_end(
shape, l), &m_functor);
1375 inline auto xfunctor_applier_base<D>::stepper_begin(
const S&
shape)
const noexcept -> const_stepper
1377 const xexpression_type& const_m_e = m_e;
1378 return const_stepper(const_m_e.stepper_begin(
shape), &m_functor);
1383 inline auto xfunctor_applier_base<D>::stepper_end(
const S&
shape,
layout_type l)
const noexcept
1386 const xexpression_type& const_m_e = m_e;
1387 return const_stepper(const_m_e.stepper_end(
shape, l), &m_functor);
1401 template <
class F,
class CT>
1405 bool cond = (
e.derived_cast().shape().size() == this->
dimension())
1406 && std::equal(this->
shape().begin(), this->
shape().end(),
e.derived_cast().shape().begin());
1409 semantic_base::operator=(
broadcast(
e.derived_cast(),
this->shape()));
1413 semantic_base::operator=(
e);
1420 template <
class F,
class CT>
1424 std::fill(this->
begin(), this->
end(),
e);
1428 template <
class F,
class CT>
1429 inline void xfunctor_view<F, CT>::assign_temporary_impl(temporary_type&& tmp)
1431 std::copy(tmp.cbegin(), tmp.cend(), this->begin());
1434 template <
class F,
class CT>
1436 inline auto xfunctor_view<F, CT>::build_functor_view(E&& e)
const -> rebind_t<E>
1438 return rebind_t<E>((this->m_functor), std::forward<E>(e));
1452 template <
class F,
class CT>
1456 const auto&
de =
e.derived_cast();
1457 this->m_e.resize(
de.shape());
1461 std::copy(
de.linear_begin(),
de.linear_end(),
this->linear_begin());
1466 std::copy(
de.begin(),
de.end(),
this->begin());
1474 template <
class F,
class CT>
1478 this->m_e.resize(std::forward<S>(
shape),
force);
1481 template <
class F,
class CT>
1485 this->m_e.resize(std::forward<S>(
shape), l);
1488 template <
class F,
class CT>
1490 auto xfunctor_adaptor<F, CT>::resize(S&&
shape,
const strides_type&
strides)
1495 template <
class F,
class CT>
1499 this->m_e.reshape(std::forward<S>(
shape),
layout);
1507 template <
class F,
class IT>
1508 xfunctor_iterator<F, IT>::xfunctor_iterator(
const IT& it, functor_type* pf)
1514 template <
class F,
class IT>
1515 inline auto xfunctor_iterator<F, IT>::operator++() -> self_type&
1521 template <
class F,
class IT>
1522 inline auto xfunctor_iterator<F, IT>::operator--() -> self_type&
1528 template <
class F,
class IT>
1529 inline auto xfunctor_iterator<F, IT>::operator+=(difference_type n) -> self_type&
1535 template <
class F,
class IT>
1536 inline auto xfunctor_iterator<F, IT>::operator-=(difference_type n) -> self_type&
1542 template <
class F,
class IT>
1543 inline auto xfunctor_iterator<F, IT>::operator-(xfunctor_iterator rhs)
const -> difference_type
1545 return m_it - rhs.m_it;
1548 template <
class F,
class IT>
1549 auto xfunctor_iterator<F, IT>::operator*() const -> reference
1551 return (*p_functor)(*m_it);
1554 template <
class F,
class IT>
1555 auto xfunctor_iterator<F, IT>::operator->() const -> pointer
1560 template <
class F,
class IT>
1561 auto xfunctor_iterator<F, IT>::equal(
const xfunctor_iterator& rhs)
const ->
bool
1563 return m_it == rhs.m_it;
1566 template <
class F,
class IT>
1567 auto xfunctor_iterator<F, IT>::less_than(
const xfunctor_iterator& rhs)
const ->
bool
1569 return m_it < rhs.m_it;
1572 template <
class F,
class IT>
1573 bool operator==(
const xfunctor_iterator<F, IT>& lhs,
const xfunctor_iterator<F, IT>& rhs)
1575 return lhs.equal(rhs);
1578 template <
class F,
class IT>
1579 bool operator<(
const xfunctor_iterator<F, IT>& lhs,
const xfunctor_iterator<F, IT>& rhs)
1581 return !lhs.less_than(rhs);
1588 template <
class F,
class ST>
1589 xfunctor_stepper<F, ST>::xfunctor_stepper(
const ST& stepper, functor_type* pf)
1590 : m_stepper(stepper)
1595 template <
class F,
class ST>
1596 auto xfunctor_stepper<F, ST>::operator*() const -> reference
1598 return (*p_functor)(*m_stepper);
1601 template <
class F,
class ST>
1602 void xfunctor_stepper<F, ST>::step(size_type dim)
1604 m_stepper.step(dim);
1607 template <
class F,
class ST>
1608 void xfunctor_stepper<F, ST>::step_back(size_type dim)
1610 m_stepper.step_back(dim);
1613 template <
class F,
class ST>
1614 void xfunctor_stepper<F, ST>::step(size_type dim, size_type n)
1616 m_stepper.step(dim, n);
1619 template <
class F,
class ST>
1620 void xfunctor_stepper<F, ST>::step_back(size_type dim, size_type n)
1622 m_stepper.step_back(dim, n);
1625 template <
class F,
class ST>
1626 void xfunctor_stepper<F, ST>::reset(size_type dim)
1628 m_stepper.reset(dim);
1631 template <
class F,
class ST>
1632 void xfunctor_stepper<F, ST>::reset_back(size_type dim)
1634 m_stepper.reset_back(dim);
1637 template <
class F,
class ST>
1638 void xfunctor_stepper<F, ST>::to_begin()
1640 m_stepper.to_begin();
1643 template <
class F,
class ST>
1644 void xfunctor_stepper<F, ST>::to_end(
layout_type l)
1646 m_stepper.to_end(l);