13 #ifndef EIGEN_PRODUCTEVALUATORS_H 14 #define EIGEN_PRODUCTEVALUATORS_H 28 template<
typename Lhs,
typename Rhs,
int Options>
35 EIGEN_DEVICE_FUNC
explicit evaluator(
const XprType& xpr) : Base(xpr) {}
40 template<
typename Lhs,
typename Rhs,
typename Scalar1,
typename Scalar2,
typename Plain1>
42 const
CwiseNullaryOp<internal::scalar_constant_op<Scalar1>, Plain1>,
43 const
Product<Lhs, Rhs, DefaultProduct> > >
45 static const bool value =
true;
47 template<
typename Lhs,
typename Rhs,
typename Scalar1,
typename Scalar2,
typename Plain1>
49 const
CwiseNullaryOp<internal::scalar_constant_op<Scalar1>, Plain1>,
50 const
Product<Lhs, Rhs, DefaultProduct> > >
51 :
public evaluator<Product<EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(Scalar1,Lhs,product), Rhs, DefaultProduct> >
58 EIGEN_DEVICE_FUNC
explicit evaluator(
const XprType& xpr)
59 : Base(xpr.
lhs().functor().m_other * xpr.
rhs().lhs() * xpr.
rhs().rhs())
64 template<
typename Lhs,
typename Rhs,
int DiagIndex>
66 :
public evaluator<Diagonal<const Product<Lhs, Rhs, LazyProduct>, DiagIndex> >
71 EIGEN_DEVICE_FUNC
explicit evaluator(
const XprType& xpr)
82 template<
typename Lhs,
typename Rhs,
83 typename LhsShape =
typename evaluator_traits<Lhs>::Shape,
84 typename RhsShape =
typename evaluator_traits<Rhs>::Shape,
88 template<
typename Lhs,
typename Rhs>
90 static const bool value =
true;
95 template<
typename Lhs,
typename Rhs,
int Options,
int ProductTag,
typename LhsShape,
typename RhsShape>
97 :
public evaluator<typename Product<Lhs, Rhs, Options>::PlainObject>
100 typedef typename XprType::PlainObject PlainObject;
106 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
108 : m_result(xpr.rows(), xpr.cols())
110 ::new (static_cast<Base*>(
this)) Base(m_result);
128 PlainObject m_result;
135 template<
typename DstXprType,
typename Lhs,
typename Rhs,
int Options,
typename Scalar>
137 typename
enable_if<(Options==DefaultProduct || Options==AliasFreeProduct)>::type>
140 static EIGEN_STRONG_INLINE
143 Index dstRows = src.rows();
144 Index dstCols = src.cols();
145 if((dst.rows()!=dstRows) || (dst.cols()!=dstCols))
146 dst.resize(dstRows, dstCols);
153 template<
typename DstXprType,
typename Lhs,
typename Rhs,
int Options,
typename Scalar>
155 typename
enable_if<(Options==DefaultProduct || Options==AliasFreeProduct)>::type>
158 static EIGEN_STRONG_INLINE
161 Index dstRows = src.rows();
162 Index dstCols = src.cols();
163 if((dst.rows()!=dstRows) || (dst.cols()!=dstCols))
164 dst.resize(dstRows, dstCols);
171 template<
typename DstXprType,
typename Lhs,
typename Rhs,
int Options,
typename Scalar>
173 typename
enable_if<(Options==DefaultProduct || Options==AliasFreeProduct)>::type>
176 static EIGEN_STRONG_INLINE
179 Index dstRows = src.rows();
180 Index dstCols = src.cols();
181 if((dst.rows()!=dstRows) || (dst.cols()!=dstCols))
182 dst.resize(dstRows, dstCols);
192 template<
typename DstXprType,
typename Lhs,
typename Rhs,
typename AssignFunc,
typename Scalar,
typename ScalarBis,
typename Plain>
199 static EIGEN_STRONG_INLINE
200 void run(DstXprType &dst,
const SrcXprType &src,
const AssignFunc&
func)
202 call_assignment_no_alias(dst, (src.
lhs().functor().m_other * src.
rhs().lhs())*src.
rhs().rhs(), func);
210 template<
typename OtherXpr,
typename Lhs,
typename Rhs>
213 static const bool value =
true;
216 template<
typename DstXprType,
typename OtherXpr,
typename ProductType,
typename Func1,
typename Func2>
219 template<
typename SrcXprType,
typename InitialFunc>
220 static EIGEN_STRONG_INLINE
221 void run(DstXprType &dst,
const SrcXprType &src,
const InitialFunc& )
223 call_assignment_no_alias(dst, src.lhs(), Func1());
224 call_assignment_no_alias(dst, src.rhs(), Func2());
228 #define EIGEN_CATCH_ASSIGN_XPR_OP_PRODUCT(ASSIGN_OP,BINOP,ASSIGN_OP2) \ 229 template< typename DstXprType, typename OtherXpr, typename Lhs, typename Rhs, typename DstScalar, typename SrcScalar, typename OtherScalar,typename ProdScalar> \ 230 struct Assignment<DstXprType, CwiseBinaryOp<internal::BINOP<OtherScalar,ProdScalar>, const OtherXpr, \ 231 const Product<Lhs,Rhs,DefaultProduct> >, internal::ASSIGN_OP<DstScalar,SrcScalar>, Dense2Dense> \ 232 : assignment_from_xpr_op_product<DstXprType, OtherXpr, Product<Lhs,Rhs,DefaultProduct>, internal::ASSIGN_OP<DstScalar,OtherScalar>, internal::ASSIGN_OP2<DstScalar,ProdScalar> > \ 245 template<
typename Lhs,
typename Rhs>
248 template<
typename Dst>
249 static inline void evalTo(Dst& dst,
const Lhs& lhs,
const Rhs& rhs)
251 dst.coeffRef(0,0) = (lhs.transpose().cwiseProduct(rhs)).sum();
254 template<
typename Dst>
255 static inline void addTo(Dst& dst,
const Lhs& lhs,
const Rhs& rhs)
257 dst.coeffRef(0,0) += (lhs.transpose().cwiseProduct(rhs)).sum();
260 template<
typename Dst>
261 static void subTo(Dst& dst,
const Lhs& lhs,
const Rhs& rhs)
262 { dst.coeffRef(0,0) -= (lhs.transpose().cwiseProduct(rhs)).sum(); }
271 template<
typename Dst,
typename Lhs,
typename Rhs,
typename Func>
272 void outer_product_selector_run(Dst& dst,
const Lhs &lhs,
const Rhs &rhs,
const Func&
func,
const false_type&)
278 const Index cols = dst.cols();
279 for (
Index j=0; j<cols; ++j)
280 func(dst.col(j), rhsEval.coeff(
Index(0),j) * actual_lhs);
284 template<
typename Dst,
typename Lhs,
typename Rhs,
typename Func>
285 void outer_product_selector_run(Dst& dst,
const Lhs &lhs,
const Rhs &rhs,
const Func& func,
const true_type&)
291 const Index rows = dst.rows();
292 for (
Index i=0; i<rows; ++i)
293 func(dst.row(i), lhsEval.coeff(i,
Index(0)) * actual_rhs);
296 template<
typename Lhs,
typename Rhs>
299 template<
typename T>
struct is_row_major :
internal::conditional<(int(T::Flags)&RowMajorBit), internal::true_type, internal::false_type>::type {};
303 struct set {
template<
typename Dst,
typename Src>
void operator()(
const Dst& dst,
const Src& src)
const { dst.const_cast_derived() = src; } };
304 struct add {
template<
typename Dst,
typename Src>
void operator()(
const Dst& dst,
const Src& src)
const { dst.const_cast_derived() += src; } };
305 struct sub {
template<
typename Dst,
typename Src>
void operator()(
const Dst& dst,
const Src& src)
const { dst.const_cast_derived() -= src; } };
308 explicit adds(
const Scalar& s) : m_scale(s) {}
309 template<
typename Dst,
typename Src>
void operator()(
const Dst& dst,
const Src& src)
const {
310 dst.const_cast_derived() += m_scale * src;
314 template<
typename Dst>
315 static inline void evalTo(Dst& dst,
const Lhs& lhs,
const Rhs& rhs)
317 internal::outer_product_selector_run(dst, lhs, rhs,
set(), is_row_major<Dst>());
320 template<
typename Dst>
321 static inline void addTo(Dst& dst,
const Lhs& lhs,
const Rhs& rhs)
323 internal::outer_product_selector_run(dst, lhs, rhs, add(), is_row_major<Dst>());
326 template<
typename Dst>
327 static inline void subTo(Dst& dst,
const Lhs& lhs,
const Rhs& rhs)
329 internal::outer_product_selector_run(dst, lhs, rhs, sub(), is_row_major<Dst>());
332 template<
typename Dst>
333 static inline void scaleAndAddTo(Dst& dst,
const Lhs& lhs,
const Rhs& rhs,
const Scalar& alpha)
335 internal::outer_product_selector_run(dst, lhs, rhs, adds(alpha), is_row_major<Dst>());
342 template<
typename Lhs,
typename Rhs,
typename Derived>
347 template<
typename Dst>
348 static EIGEN_STRONG_INLINE
void evalTo(Dst& dst,
const Lhs& lhs,
const Rhs& rhs)
349 { dst.setZero(); scaleAndAddTo(dst, lhs, rhs, Scalar(1)); }
351 template<
typename Dst>
352 static EIGEN_STRONG_INLINE
void addTo(Dst& dst,
const Lhs& lhs,
const Rhs& rhs)
353 { scaleAndAddTo(dst,lhs, rhs, Scalar(1)); }
355 template<
typename Dst>
356 static EIGEN_STRONG_INLINE
void subTo(Dst& dst,
const Lhs& lhs,
const Rhs& rhs)
357 { scaleAndAddTo(dst, lhs, rhs, Scalar(-1)); }
359 template<
typename Dst>
360 static EIGEN_STRONG_INLINE
void scaleAndAddTo(Dst& dst,
const Lhs& lhs,
const Rhs& rhs,
const Scalar& alpha)
361 { Derived::scaleAndAddTo(dst,lhs,rhs,alpha); }
365 template<
typename Lhs,
typename Rhs>
375 template<
typename Dest>
376 static EIGEN_STRONG_INLINE
void scaleAndAddTo(Dest& dst,
const Lhs& lhs,
const Rhs& rhs,
const Scalar& alpha)
378 LhsNested actual_lhs(lhs);
379 RhsNested actual_rhs(rhs);
384 >::run(actual_lhs, actual_rhs, dst, alpha);
388 template<
typename Lhs,
typename Rhs>
393 template<
typename Dst>
394 static EIGEN_STRONG_INLINE
void evalTo(Dst& dst,
const Lhs& lhs,
const Rhs& rhs)
401 template<
typename Dst>
402 static EIGEN_STRONG_INLINE
void addTo(Dst& dst,
const Lhs& lhs,
const Rhs& rhs)
408 template<
typename Dst>
409 static EIGEN_STRONG_INLINE
void subTo(Dst& dst,
const Lhs& lhs,
const Rhs& rhs)
421 template<
typename Lhs,
typename Rhs>
431 template<
int Traversal,
int UnrollingIndex,
typename Lhs,
typename Rhs,
typename RetScalar>
434 template<
int StorageOrder,
int UnrollingIndex,
typename Lhs,
typename Rhs,
typename Packet,
int LoadMode>
437 template<
typename Lhs,
typename Rhs,
int ProductTag>
442 typedef typename XprType::Scalar Scalar;
443 typedef typename XprType::CoeffReturnType CoeffReturnType;
445 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
452 m_innerDim(xpr.lhs().cols())
456 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
458 std::cerr <<
"LhsOuterStrideBytes= " << LhsOuterStrideBytes <<
"\n";
459 std::cerr <<
"RhsOuterStrideBytes= " << RhsOuterStrideBytes <<
"\n";
460 std::cerr <<
"LhsAlignment= " << LhsAlignment <<
"\n";
461 std::cerr <<
"RhsAlignment= " << RhsAlignment <<
"\n";
462 std::cerr <<
"CanVectorizeLhs= " << CanVectorizeLhs <<
"\n";
463 std::cerr <<
"CanVectorizeRhs= " << CanVectorizeRhs <<
"\n";
464 std::cerr <<
"CanVectorizeInner= " << CanVectorizeInner <<
"\n";
465 std::cerr <<
"EvalToRowMajor= " << EvalToRowMajor <<
"\n";
466 std::cerr <<
"Alignment= " << Alignment <<
"\n";
467 std::cerr <<
"Flags= " << Flags <<
"\n";
483 RowsAtCompileTime = LhsNestedCleaned::RowsAtCompileTime,
484 ColsAtCompileTime = RhsNestedCleaned::ColsAtCompileTime,
485 InnerSize = EIGEN_SIZE_MIN_PREFER_FIXED(LhsNestedCleaned::ColsAtCompileTime, RhsNestedCleaned::RowsAtCompileTime),
486 MaxRowsAtCompileTime = LhsNestedCleaned::MaxRowsAtCompileTime,
487 MaxColsAtCompileTime = RhsNestedCleaned::MaxColsAtCompileTime
490 typedef typename find_best_packet<Scalar,RowsAtCompileTime>::type LhsVecPacketType;
491 typedef typename find_best_packet<Scalar,ColsAtCompileTime>::type RhsVecPacketType;
495 LhsCoeffReadCost = LhsEtorType::CoeffReadCost,
496 RhsCoeffReadCost = RhsEtorType::CoeffReadCost,
502 Unroll = CoeffReadCost <= EIGEN_UNROLLING_LIMIT,
504 LhsFlags = LhsEtorType::Flags,
505 RhsFlags = RhsEtorType::Flags,
514 LhsAlignment = EIGEN_PLAIN_ENUM_MIN(LhsEtorType::Alignment,LhsVecPacketSize*
int(
sizeof(
typename LhsNestedCleaned::Scalar))),
515 RhsAlignment = EIGEN_PLAIN_ENUM_MIN(RhsEtorType::Alignment,RhsVecPacketSize*
int(
sizeof(
typename RhsNestedCleaned::Scalar))),
519 CanVectorizeRhs = bool(RhsRowMajor) && (RhsFlags &
PacketAccessBit) && (ColsAtCompileTime!=1),
520 CanVectorizeLhs = (!LhsRowMajor) && (LhsFlags &
PacketAccessBit) && (RowsAtCompileTime!=1),
522 EvalToRowMajor = (MaxRowsAtCompileTime==1&&MaxColsAtCompileTime!=1) ? 1
523 : (MaxColsAtCompileTime==1&&MaxRowsAtCompileTime!=1) ? 0
524 : (
bool(RhsRowMajor) && !CanVectorizeLhs),
526 Flags = ((
unsigned int)(LhsFlags | RhsFlags) & HereditaryBits & ~RowMajorBit)
527 | (EvalToRowMajor ? RowMajorBit : 0)
529 | (SameType && (CanVectorizeLhs || CanVectorizeRhs) ? PacketAccessBit : 0)
532 LhsOuterStrideBytes = int(LhsNestedCleaned::OuterStrideAtCompileTime) * int(
sizeof(
typename LhsNestedCleaned::Scalar)),
533 RhsOuterStrideBytes = int(RhsNestedCleaned::OuterStrideAtCompileTime) * int(
sizeof(
typename RhsNestedCleaned::Scalar)),
535 Alignment = bool(CanVectorizeLhs) ? (LhsOuterStrideBytes<=0 || (int(LhsOuterStrideBytes) % EIGEN_PLAIN_ENUM_MAX(1,LhsAlignment))!=0 ? 0 : LhsAlignment)
536 : bool(CanVectorizeRhs) ? (RhsOuterStrideBytes<=0 || (int(RhsOuterStrideBytes) % EIGEN_PLAIN_ENUM_MAX(1,RhsAlignment))!=0 ? 0 : RhsAlignment)
544 CanVectorizeInner = SameType
547 && (LhsFlags & RhsFlags & ActualPacketAccessBit)
551 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
const CoeffReturnType coeff(
Index row,
Index col)
const 553 return (m_lhs.row(row).transpose().cwiseProduct( m_rhs.col(col) )).sum();
560 EIGEN_DEVICE_FUNC
const CoeffReturnType coeff(
Index index)
const 562 const Index row = (RowsAtCompileTime == 1 || MaxRowsAtCompileTime==1) ? 0 : index;
563 const Index col = (RowsAtCompileTime == 1 || MaxRowsAtCompileTime==1) ? index : 0;
564 return (m_lhs.row(row).transpose().cwiseProduct( m_rhs.col(col) )).sum();
567 template<
int LoadMode,
typename PacketType>
572 Unroll ? int(InnerSize) :
Dynamic,
573 LhsEtorType, RhsEtorType,
PacketType, LoadMode> PacketImpl;
574 PacketImpl::run(row, col, m_lhsImpl, m_rhsImpl, m_innerDim, res);
578 template<
int LoadMode,
typename PacketType>
581 const Index row = (RowsAtCompileTime == 1 || MaxRowsAtCompileTime==1) ? 0 : index;
582 const Index col = (RowsAtCompileTime == 1 || MaxRowsAtCompileTime==1) ? index : 0;
583 return packet<LoadMode,PacketType>(row,col);
590 LhsEtorType m_lhsImpl;
591 RhsEtorType m_rhsImpl;
597 template<
typename Lhs,
typename Rhs>
599 :
product_evaluator<Product<Lhs, Rhs, LazyProduct>, CoeffBasedProductMode, DenseShape, DenseShape>
608 : Base(BaseProduct(xpr.lhs(),xpr.rhs()))
616 template<
int UnrollingIndex,
typename Lhs,
typename Rhs,
typename Packet,
int LoadMode>
619 static EIGEN_STRONG_INLINE
void run(
Index row,
Index col,
const Lhs& lhs,
const Rhs& rhs,
Index innerDim,
Packet &res)
621 etor_product_packet_impl<RowMajor, UnrollingIndex-1, Lhs, Rhs, Packet, LoadMode>::run(row, col, lhs, rhs, innerDim, res);
622 res = pmadd(pset1<Packet>(lhs.coeff(row,
Index(UnrollingIndex-1))), rhs.template packet<LoadMode,Packet>(
Index(UnrollingIndex-1), col), res);
626 template<
int UnrollingIndex,
typename Lhs,
typename Rhs,
typename Packet,
int LoadMode>
629 static EIGEN_STRONG_INLINE
void run(
Index row,
Index col,
const Lhs& lhs,
const Rhs& rhs,
Index innerDim,
Packet &res)
631 etor_product_packet_impl<ColMajor, UnrollingIndex-1, Lhs, Rhs, Packet, LoadMode>::run(row, col, lhs, rhs, innerDim, res);
632 res = pmadd(lhs.template packet<LoadMode,Packet>(row,
Index(UnrollingIndex-1)), pset1<Packet>(rhs.coeff(
Index(UnrollingIndex-1), col)), res);
636 template<
typename Lhs,
typename Rhs,
typename Packet,
int LoadMode>
639 static EIGEN_STRONG_INLINE
void run(
Index row,
Index col,
const Lhs& lhs,
const Rhs& rhs,
Index ,
Packet &res)
641 res = pmul(pset1<Packet>(lhs.coeff(row,
Index(0))),rhs.template packet<LoadMode,Packet>(
Index(0), col));
645 template<
typename Lhs,
typename Rhs,
typename Packet,
int LoadMode>
648 static EIGEN_STRONG_INLINE
void run(
Index row,
Index col,
const Lhs& lhs,
const Rhs& rhs,
Index ,
Packet &res)
650 res = pmul(lhs.template packet<LoadMode,Packet>(row,
Index(0)), pset1<Packet>(rhs.coeff(
Index(0), col)));
654 template<
typename Lhs,
typename Rhs,
typename Packet,
int LoadMode>
663 template<
typename Lhs,
typename Rhs,
typename Packet,
int LoadMode>
672 template<
typename Lhs,
typename Rhs,
typename Packet,
int LoadMode>
675 static EIGEN_STRONG_INLINE
void run(
Index row,
Index col,
const Lhs& lhs,
const Rhs& rhs,
Index innerDim,
Packet& res)
678 for(
Index i = 0; i < innerDim; ++i)
679 res = pmadd(pset1<Packet>(lhs.coeff(row, i)), rhs.template packet<LoadMode,Packet>(i, col), res);
683 template<
typename Lhs,
typename Rhs,
typename Packet,
int LoadMode>
686 static EIGEN_STRONG_INLINE
void run(
Index row,
Index col,
const Lhs& lhs,
const Rhs& rhs,
Index innerDim,
Packet& res)
689 for(
Index i = 0; i < innerDim; ++i)
690 res = pmadd(lhs.template packet<LoadMode,Packet>(row, i), pset1<Packet>(rhs.coeff(i, col)), res);
698 template<
int Mode,
bool LhsIsTriangular,
699 typename Lhs,
bool LhsIsVector,
700 typename Rhs,
bool RhsIsVector>
703 template<
typename Lhs,
typename Rhs,
int ProductTag>
709 template<
typename Dest>
710 static void scaleAndAddTo(Dest& dst,
const Lhs& lhs,
const Rhs& rhs,
const Scalar& alpha)
713 ::run(dst, lhs.nestedExpression(), rhs, alpha);
717 template<
typename Lhs,
typename Rhs,
int ProductTag>
723 template<
typename Dest>
724 static void scaleAndAddTo(Dest& dst,
const Lhs& lhs,
const Rhs& rhs,
const Scalar& alpha)
734 template <
typename Lhs,
int LhsMode,
bool LhsIsVector,
735 typename Rhs,
int RhsMode,
bool RhsIsVector>
738 template<
typename Lhs,
typename Rhs,
int ProductTag>
744 template<
typename Dest>
745 static void scaleAndAddTo(Dest& dst,
const Lhs& lhs,
const Rhs& rhs,
const Scalar& alpha)
751 template<
typename Lhs,
typename Rhs,
int ProductTag>
757 template<
typename Dest>
758 static void scaleAndAddTo(Dest& dst,
const Lhs& lhs,
const Rhs& rhs,
const Scalar& alpha)
769 template<
typename MatrixType,
typename DiagonalType,
typename Derived,
int ProductOrder>
781 _ScalarAccessOnDiag = !((int(_StorageOrder) ==
ColMajor && int(ProductOrder) ==
OnTheLeft)
786 _Vectorizable = bool(
int(MatrixFlags)&
PacketAccessBit) && _SameTypes && (_ScalarAccessOnDiag || (bool(
int(DiagFlags)&PacketAccessBit))),
787 _LinearAccessMask = (MatrixType::RowsAtCompileTime==1 || MatrixType::ColsAtCompileTime==1) ?
LinearAccessBit : 0,
788 Flags = ((HereditaryBits|_LinearAccessMask) & (
unsigned int)(MatrixFlags)) | (_Vectorizable ? PacketAccessBit : 0),
793 : m_diagImpl(diag), m_matImpl(mat)
796 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
799 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
const Scalar coeff(
Index idx)
const 801 return m_diagImpl.coeff(idx) * m_matImpl.coeff(idx);
805 template<
int LoadMode,
typename PacketType>
808 return internal::pmul(m_matImpl.template packet<LoadMode,PacketType>(row, col),
809 internal::pset1<PacketType>(m_diagImpl.coeff(
id)));
812 template<
int LoadMode,
typename PacketType>
816 InnerSize = (MatrixType::Flags &
RowMajorBit) ? MatrixType::ColsAtCompileTime : MatrixType::RowsAtCompileTime,
819 return internal::pmul(m_matImpl.template packet<LoadMode,PacketType>(row, col),
820 m_diagImpl.template packet<DiagonalPacketLoadMode,PacketType>(
id));
828 template<
typename Lhs,
typename Rhs,
int ProductKind,
int ProductTag>
833 using Base::m_diagImpl;
834 using Base::m_matImpl;
836 typedef typename Base::Scalar Scalar;
839 typedef typename XprType::PlainObject PlainObject;
846 : Base(xpr.rhs(), xpr.lhs().diagonal())
850 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
const Scalar coeff(
Index row,
Index col)
const 852 return m_diagImpl.coeff(row) * m_matImpl.coeff(row, col);
856 template<
int LoadMode,
typename PacketType>
861 return this->
template packet_impl<LoadMode,PacketType>(row,col, row,
865 template<
int LoadMode,
typename PacketType>
868 return packet<LoadMode,PacketType>(int(StorageOrder)==
ColMajor?idx:0,int(StorageOrder)==
ColMajor?0:idx);
874 template<
typename Lhs,
typename Rhs,
int ProductKind,
int ProductTag>
879 using Base::m_diagImpl;
880 using Base::m_matImpl;
882 typedef typename Base::Scalar Scalar;
885 typedef typename XprType::PlainObject PlainObject;
890 : Base(xpr.lhs(), xpr.rhs().diagonal())
894 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
const Scalar coeff(
Index row,
Index col)
const 896 return m_matImpl.coeff(row, col) * m_diagImpl.coeff(col);
900 template<
int LoadMode,
typename PacketType>
903 return this->
template packet_impl<LoadMode,PacketType>(row,col, col,
907 template<
int LoadMode,
typename PacketType>
910 return packet<LoadMode,PacketType>(int(StorageOrder)==
ColMajor?idx:0,int(StorageOrder)==
ColMajor?0:idx);
924 template<
typename ExpressionType,
int S
ide,
bool Transposed,
typename ExpressionShape>
927 template<
typename ExpressionType,
int S
ide,
bool Transposed>
933 template<
typename Dest,
typename PermutationType>
934 static inline void run(Dest& dst,
const PermutationType& perm,
const ExpressionType& xpr)
941 if(is_same_dense(dst, mat))
947 while(r < perm.size())
950 while(r<perm.size() && mask[r]) r++;
957 for(
Index k=perm.indices().coeff(k0); k!=k0; k=perm.indices().coeff(k))
961 (dst,((Side==
OnTheLeft) ^ Transposed) ? k0 : kPrev));
963 mask.coeffRef(k) =
true;
970 for(
Index i = 0; i < n; ++i)
973 (dst, ((Side==
OnTheLeft) ^ Transposed) ? perm.indices().coeff(i) : i)
978 (mat, ((Side==
OnTheRight) ^ Transposed) ? perm.indices().coeff(i) : i);
984 template<
typename Lhs,
typename Rhs,
int ProductTag,
typename MatrixShape>
987 template<
typename Dest>
988 static void evalTo(Dest& dst,
const Lhs& lhs,
const Rhs& rhs)
994 template<
typename Lhs,
typename Rhs,
int ProductTag,
typename MatrixShape>
997 template<
typename Dest>
998 static void evalTo(Dest& dst,
const Lhs& lhs,
const Rhs& rhs)
1004 template<
typename Lhs,
typename Rhs,
int ProductTag,
typename MatrixShape>
1007 template<
typename Dest>
1008 static void evalTo(Dest& dst,
const Inverse<Lhs>& lhs,
const Rhs& rhs)
1014 template<
typename Lhs,
typename Rhs,
int ProductTag,
typename MatrixShape>
1017 template<
typename Dest>
1018 static void evalTo(Dest& dst,
const Lhs& lhs,
const Inverse<Rhs>& rhs)
1035 template<
typename ExpressionType,
int S
ide,
bool Transposed,
typename ExpressionShape>
1041 template<
typename Dest,
typename TranspositionType>
1042 static inline void run(Dest& dst,
const TranspositionType& tr,
const ExpressionType& xpr)
1044 MatrixType mat(xpr);
1045 typedef typename TranspositionType::StorageIndex StorageIndex;
1046 const Index size = tr.size();
1049 if(!is_same_dense(dst,mat))
1052 for(
Index k=(Transposed?size-1:0) ; Transposed?k>=0:k<size ; Transposed?--k:++k)
1053 if(
Index(j=tr.coeff(k))!=k)
1055 if(Side==
OnTheLeft) dst.row(k).swap(dst.row(j));
1056 else if(Side==
OnTheRight) dst.col(k).swap(dst.col(j));
1061 template<
typename Lhs,
typename Rhs,
int ProductTag,
typename MatrixShape>
1064 template<
typename Dest>
1065 static void evalTo(Dest& dst,
const Lhs& lhs,
const Rhs& rhs)
1071 template<
typename Lhs,
typename Rhs,
int ProductTag,
typename MatrixShape>
1074 template<
typename Dest>
1075 static void evalTo(Dest& dst,
const Lhs& lhs,
const Rhs& rhs)
1082 template<
typename Lhs,
typename Rhs,
int ProductTag,
typename MatrixShape>
1085 template<
typename Dest>
1086 static void evalTo(Dest& dst,
const Transpose<Lhs>& lhs,
const Rhs& rhs)
1092 template<
typename Lhs,
typename Rhs,
int ProductTag,
typename MatrixShape>
1095 template<
typename Dest>
1096 static void evalTo(Dest& dst,
const Lhs& lhs,
const Transpose<Rhs>& rhs)
1106 #endif // EIGEN_PRODUCT_EVALUATORS_H Generic expression of a matrix where all coefficients are defined by a functor.
Definition: CwiseNullaryOp.h:60
Definition: BlasUtil.h:269
Storage order is column major (see TopicStorageOrders).
Definition: Constants.h:320
const int HugeCost
This value means that the cost to evaluate an expression coefficient is either very expensive or cann...
Definition: Constants.h:39
Expression of the product of two arbitrary matrices or vectors.
Definition: Product.h:71
Definition: ForwardDeclarations.h:162
Apply transformation on the right.
Definition: Constants.h:335
Data pointer is aligned on a 16 bytes boundary.
Definition: Constants.h:230
Definition: XprHelper.h:158
Definition: AssignmentFunctors.h:67
Expression of the transpose of a matrix.
Definition: Transpose.h:52
Definition: BinaryFunctors.h:32
Definition: CoreEvaluators.h:90
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:85
Definition: ProductEvaluators.h:995
Holds information about the various numeric (i.e.
Definition: NumTraits.h:150
const unsigned int RowMajorBit
for a matrix, this means that the storage order is row-major.
Definition: Constants.h:61
Definition: Constants.h:512
Definition: ProductEvaluators.h:343
const unsigned int PacketAccessBit
Short version: means the expression might be vectorized.
Definition: Constants.h:89
EIGEN_DEVICE_FUNC const _RhsNested & rhs() const
Definition: CwiseBinaryOp.h:135
EIGEN_DEVICE_FUNC const internal::remove_all< MatrixTypeNested >::type & nestedExpression() const
Definition: Transpose.h:74
Definition: ProductEvaluators.h:1036
Definition: AssignmentFunctors.h:21
Definition: AssignEvaluator.h:753
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar & coeffRef(Index rowId, Index colId)
This is an overloaded version of DenseCoeffsBase<Derived,WriteAccessors>::coeffRef(Index,Index) const provided to by-pass the creation of an evaluator of the expression, thus saving compilation efforts.
Definition: PlainObjectBase.h:177
Definition: AssignEvaluator.h:743
Definition: CoreEvaluators.h:109
Expression of the inverse of another expression.
Definition: Inverse.h:43
Definition: GenericPacketMath.h:96
Definition: BinaryFunctors.h:76
Generic expression where a coefficient-wise binary operator is applied to two expressions.
Definition: CwiseBinaryOp.h:77
Definition: ProductEvaluators.h:217
Definition: ProductEvaluators.h:925
Definition: ProductEvaluators.h:86
Definition: GeneralProduct.h:36
Definition: Constants.h:518
Definition: Constants.h:515
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:33
Apply transformation on the left.
Definition: Constants.h:333
Definition: ProductEvaluators.h:770
Definition: ProductEvaluators.h:701
Definition: ProductEvaluators.h:435
Definition: ProductEvaluators.h:928
Definition: benchGeometry.cpp:23
Definition: PacketMath.h:48
Definition: BandTriangularSolver.h:13
Expression of a fixed-size or dynamic-size block.
Definition: Block.h:103
Definition: CoreEvaluators.h:84
Definition: BinaryFunctors.h:329
Storage order is row major (see TopicStorageOrders).
Definition: Constants.h:322
Definition: GeneralProduct.h:140
Definition: ProductEvaluators.h:432
Definition: ProductEvaluators.h:736
Determines whether the given binary operation of two numeric types is allowed and what the scalar ret...
Definition: XprHelper.h:757
Definition: AssignmentFunctors.h:46
Definition: Constants.h:517
Expression of a diagonal/subdiagonal/superdiagonal in a matrix.
Definition: Diagonal.h:63
const int Dynamic
This value means that a positive quantity (e.g., a size) is not known at compile-time, and that instead the value is stored in some runtime variable.
Definition: Constants.h:21
const unsigned int EvalBeforeNestingBit
means the expression should be evaluated by the calling expression
Definition: Constants.h:65
Generic expression where a coefficient-wise unary operator is applied to an expression.
Definition: CwiseUnaryOp.h:55
Definition: TensorMeta.h:50
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:178
Definition: ProductEvaluators.h:985
const unsigned int LinearAccessBit
Short version: means the expression can be seen as 1D vector.
Definition: Constants.h:125
EIGEN_DEVICE_FUNC const _LhsNested & lhs() const
Definition: CwiseBinaryOp.h:132
Definition: Constants.h:520
Definition: TensorRef.h:78
Definition: Constants.h:519