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,
181 int Unrolling = redux_traits<Func, Derived>::Unrolling
185 template<
typename Func,
typename Derived>
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)
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);
287 for(
Index j=0; j<outerSize; ++j)
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);
292 for(
Index j=0; j<outerSize; ++j)
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,
320 if (VectorizedSize > 0) {
322 if (VectorizedSize != Size)
333 template<
typename _XprType>
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>
413 eigen_assert(this->rows()>0 && this->cols()>0 &&
"you are using an empty matrix");
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