26 template<
typename Func,
typename Derived>
34 ? Derived::MaxColsAtCompileTime
35 : Derived::MaxRowsAtCompileTime
64 #ifdef EIGEN_DEBUG_ASSIGN 67 std::cerr <<
"Xpr: " <<
typeid(
typename Derived::XprType).
name() << std::endl;
68 std::cerr.setf(std::ios::hex, std::ios::basefield);
70 std::cerr.unsetf(std::ios::hex);
79 std::cerr << std::endl;
90 template<
typename Func,
typename Derived,
int Start,
int Length>
107 template<
typename Func,
typename Derived,
int Start>
111 outer = Start / Derived::InnerSizeAtCompileTime,
112 inner = Start % Derived::InnerSizeAtCompileTime
120 return mat.coeffByOuterInner(outer, inner);
127 template<
typename Func,
typename Derived,
int Start>
137 template<
typename Func,
typename Derived,
int Start,
int Length>
142 HalfLength = Length/2
150 return func.packetOp(
156 template<
typename Func,
typename Derived,
int Start>
161 outer = index /
int(Derived::InnerSizeAtCompileTime),
162 inner = index %
int(Derived::InnerSizeAtCompileTime),
163 alignment = Derived::Alignment
171 return mat.template packetByOuterInner<alignment,PacketScalar>(outer, inner);
179 template<
typename Func,
typename Derived,
185 template<
typename Func,
typename Derived>
192 eigen_assert(mat.rows()>0 && mat.cols()>0 &&
"you are using an empty matrix");
194 res = mat.coeffByOuterInner(0, 0);
195 for(
Index i = 1;
i < mat.innerSize(); ++
i)
196 res =
func(res, mat.coeffByOuterInner(0,
i));
197 for(
Index i = 1;
i < mat.outerSize(); ++
i)
198 for(
Index j = 0;
j < mat.innerSize(); ++
j)
199 res =
func(res, mat.coeffByOuterInner(
i,
j));
204 template<
typename Func,
typename Derived>
209 template<
typename Func,
typename Derived>
226 const Index alignedSize2 = ((size-alignedStart)/(2*packetSize))*(2*packetSize);
227 const Index alignedSize = ((size-alignedStart)/(packetSize))*(packetSize);
228 const Index alignedEnd2 = alignedStart + alignedSize2;
229 const Index alignedEnd = alignedStart + alignedSize;
233 PacketScalar packet_res0 = mat.template packet<alignment,PacketScalar>(alignedStart);
234 if(alignedSize>packetSize)
236 PacketScalar packet_res1 = mat.template packet<alignment,PacketScalar>(alignedStart+packetSize);
237 for(
Index index = alignedStart + 2*packetSize; index < alignedEnd2; index += 2*packetSize)
239 packet_res0 = func.packetOp(packet_res0, mat.template packet<alignment,PacketScalar>(index));
240 packet_res1 = func.packetOp(packet_res1, mat.template packet<alignment,PacketScalar>(index+packetSize));
243 packet_res0 = func.packetOp(packet_res0,packet_res1);
244 if(alignedEnd>alignedEnd2)
245 packet_res0 = func.packetOp(packet_res0, mat.template packet<alignment,PacketScalar>(alignedEnd2));
247 res = func.predux(packet_res0);
249 for(
Index index = 0; index < alignedStart; ++index)
250 res =
func(res,mat.coeff(index));
252 for(
Index index = alignedEnd; index <
size; ++index)
253 res =
func(res,mat.coeff(index));
259 for(
Index index = 1; index <
size; ++index)
260 res =
func(res,mat.coeff(index));
268 template<
typename Func,
typename Derived,
int Unrolling>
274 EIGEN_DEVICE_FUNC
static Scalar
run(
const Derived &
mat,
const Func&
func)
276 eigen_assert(mat.rows()>0 && mat.cols()>0 &&
"you are using an empty matrix");
277 const Index innerSize = mat.innerSize();
278 const Index outerSize = mat.outerSize();
282 const Index packetedInnerSize = ((innerSize)/packetSize)*packetSize;
284 if(packetedInnerSize)
286 PacketType packet_res = mat.template packet<Unaligned,PacketType>(0,0);
288 for(
Index i=(
j==0?packetSize:0);
i<packetedInnerSize;
i+=
Index(packetSize))
289 packet_res = func.packetOp(packet_res, mat.template packetByOuterInner<Unaligned,PacketType>(
j,
i));
291 res = func.predux(packet_res);
293 for(
Index i=packetedInnerSize;
i<innerSize; ++
i)
294 res =
func(res, mat.coeffByOuterInner(
j,
i));
306 template<
typename Func,
typename Derived>
314 Size = Derived::SizeAtCompileTime,
319 eigen_assert(mat.rows()>0 && mat.cols()>0 &&
"you are using an empty matrix");
320 if (VectorizedSize > 0) {
322 if (VectorizedSize != Size)
333 template<
typename _XprType>
338 EIGEN_DEVICE_FUNC
explicit redux_evaluator(
const XprType &xpr) : m_evaluator(xpr), m_xpr(xpr) {}
346 MaxRowsAtCompileTime = XprType::MaxRowsAtCompileTime,
347 MaxColsAtCompileTime = XprType::MaxColsAtCompileTime,
350 IsRowMajor = XprType::IsRowMajor,
351 SizeAtCompileTime = XprType::SizeAtCompileTime,
352 InnerSizeAtCompileTime = XprType::InnerSizeAtCompileTime,
357 EIGEN_DEVICE_FUNC
Index rows()
const {
return m_xpr.rows(); }
358 EIGEN_DEVICE_FUNC
Index cols()
const {
return m_xpr.cols(); }
359 EIGEN_DEVICE_FUNC
Index size()
const {
return m_xpr.size(); }
365 {
return m_evaluator.coeff(row, col); }
369 {
return m_evaluator.coeff(index); }
371 template<
int LoadMode,
typename PacketType>
373 {
return m_evaluator.template packet<LoadMode,PacketType>(
row,
col); }
375 template<
int LoadMode,
typename PacketType>
377 {
return m_evaluator.template packet<LoadMode,PacketType>(index); }
381 {
return m_evaluator.coeff(IsRowMajor ? outer : inner, IsRowMajor ? inner : outer); }
383 template<
int LoadMode,
typename PacketType>
385 {
return m_evaluator.template packet<LoadMode,PacketType>(IsRowMajor ? outer : inner, IsRowMajor ? inner : outer); }
408 template<
typename Derived>
409 template<
typename Func>
416 ThisEvaluator thisEval(derived());
424 template<
typename Derived>
434 template<
typename Derived>
447 template<
typename Derived>
451 if(SizeAtCompileTime==0 || (SizeAtCompileTime==
Dynamic &&
size()==0))
460 template<
typename Derived>
464 #ifdef __INTEL_COMPILER 466 #pragma warning ( disable : 2259 ) 469 #ifdef __INTEL_COMPILER 481 template<
typename Derived>
485 if(SizeAtCompileTime==0 || (SizeAtCompileTime==
Dynamic &&
size()==0))
496 template<
typename Derived>
500 return derived().diagonal().sum();
505 #endif // EIGEN_REDUX_H XprType::CoeffReturnType CoeffReturnType
find_best_packet_helper< Size, typename packet_traits< T >::type >::type type
static EIGEN_STRONG_INLINE PacketScalar run(const Derived &mat, const Func &func)
XprType::PacketScalar PacketScalar
EIGEN_DEVICE_FUNC Scalar prod() const
const unsigned int ActualPacketAccessBit
#define EIGEN_STRONG_INLINE
#define EIGEN_DEBUG_VAR(x)
EIGEN_DEVICE_FUNC Scalar trace() const
const unsigned int DirectAccessBit
XprType::PacketReturnType PacketReturnType
EIGEN_DEVICE_FUNC Index innerSize() const
EIGEN_DEVICE_FUNC Index rows() const
PacketType packetByOuterInner(Index outer, Index inner) const
#define EIGEN_PLAIN_ENUM_MAX(a, b)
Namespace containing all symbols from the Eigen library.
const XprType & nestedExpression() const
EIGEN_DEVICE_FUNC CoeffReturnType coeff(Index index) const
static Scalar run(const Derived &mat, const Func &func)
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar run(const Derived &mat, const Func &func)
internal::evaluator< XprType > m_evaluator
EIGEN_DEVICE_FUNC redux_evaluator(const XprType &xpr)
static Index first_default_aligned(const DenseBase< Derived > &m)
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar run(const Derived &mat, const Func &func)
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
redux_traits< Func, Derived >::PacketType PacketScalar
static EIGEN_DEVICE_FUNC Scalar run(const Derived &mat, const Func &func)
EIGEN_DEVICE_FUNC internal::traits< Derived >::Scalar maxCoeff() const
EIGEN_DEVICE_FUNC Scalar sum() const
EIGEN_DEVICE_FUNC Scalar redux(const BinaryOp &func) const
redux_traits< Func, Derived >::PacketType PacketScalar
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
EIGEN_DEVICE_FUNC internal::traits< Derived >::Scalar minCoeff() const
EIGEN_DEVICE_FUNC Index size() const
EIGEN_DEVICE_FUNC CoeffReturnType coeffByOuterInner(Index outer, Index inner) const
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar run(const Derived &mat, const Func &)
EIGEN_DEVICE_FUNC CoeffReturnType coeff(Index row, Index col) const
redux_traits< Func, Derived >::PacketType PacketScalar
redux_traits< Func, Derived >::PacketType PacketType
static EIGEN_STRONG_INLINE PacketScalar run(const Derived &mat, const Func &)
redux_traits< Func, Derived >::PacketType PacketScalar
EIGEN_DEVICE_FUNC Index outerSize() const
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar run(const Derived &, const Func &)
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar run(const Derived &mat, const Func &func)
PacketType packet(Index index) const
void run(Expr &expr, Dev &dev)
EIGEN_DEVICE_FUNC Scalar mean() const
const unsigned int LinearAccessBit
find_best_packet< typename Derived::Scalar, Derived::SizeAtCompileTime >::type PacketType
EIGEN_DEVICE_FUNC Index cols() const
#define EIGEN_UNROLLING_LIMIT
PacketType packet(Index row, Index col) const