// This file is part of Eigen, a lightweight C++ template library // for linear algebra. // // Copyright (C) 2011-2018 Gael Guennebaud <[email protected]> // // This Source Code Form is subject to the terms of the Mozilla // Public License v. 2.0. If a copy of the MPL was not distributed // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. #ifndef EIGEN_PARTIALREDUX_H #define EIGEN_PARTIALREDUX_H // IWYU pragma: private #include "./InternalHeaderCheck.h" namespace Eigen { namespace internal { /*************************************************************************** * * This file provides evaluators for partial reductions. * There are two modes: * * - scalar path: simply calls the respective function on the column or row. * -> nothing special here, all the tricky part is handled by the return * types of VectorwiseOp's members. They embed the functor calling the * respective DenseBase's member function. * * - vectorized path: implements a packet-wise reductions followed by * some (optional) processing of the outcome, e.g., division by n for mean. * * For the vectorized path let's observe that the packet-size and outer-unrolling * are both decided by the assignment logic. So all we have to do is to decide * on the inner unrolling. * * For the unrolling, we can reuse "internal::redux_vec_unroller" from Redux.h, * but be need to be careful to specify correct increment. * ***************************************************************************/ /* logic deciding a strategy for unrolling of vectorized paths */ template <typename Func, typename Evaluator> struct packetwise_redux_traits { … }; /* Value to be returned when size==0 , by default let's return 0 */ template <typename PacketType, typename Func> EIGEN_DEVICE_FUNC PacketType packetwise_redux_empty_value(const Func&) { … } /* For products the default is 1 */ template <typename PacketType, typename Scalar> EIGEN_DEVICE_FUNC PacketType packetwise_redux_empty_value(const scalar_product_op<Scalar, Scalar>&) { … } /* Perform the actual reduction */ template <typename Func, typename Evaluator, int Unrolling = packetwise_redux_traits<Func, Evaluator>::Unrolling> struct packetwise_redux_impl; /* Perform the actual reduction with unrolling */ packetwise_redux_impl<Func, Evaluator, CompleteUnrolling>; /* Add a specialization of redux_vec_unroller for size==0 at compiletime. * This specialization is not required for general reductions, which is * why it is defined here. */ redux_vec_unroller<Func, Evaluator, Start, 0>; /* Perform the actual reduction for dynamic sizes */ packetwise_redux_impl<Func, Evaluator, NoUnrolling>; evaluator<PartialReduxExpr<ArgType, MemberOp, Direction>>; } // end namespace internal } // end namespace Eigen #endif // EIGEN_PARTIALREDUX_H