12 #ifndef EIGEN_ASSIGN_EVALUATOR_H
13 #define EIGEN_ASSIGN_EVALUATOR_H
27 template <
typename DstEvaluator,
typename SrcEvaluator,
typename AssignFunc,
int MaxPacketSize = -1>
30 typedef typename DstEvaluator::XprType Dst;
31 typedef typename Dst::Scalar DstScalar;
34 DstFlags = DstEvaluator::Flags,
35 SrcFlags = SrcEvaluator::Flags
40 DstAlignment = DstEvaluator::Alignment,
41 SrcAlignment = SrcEvaluator::Alignment,
43 JointAlignment = EIGEN_PLAIN_ENUM_MIN(DstAlignment,SrcAlignment)
48 InnerSize = int(Dst::IsVectorAtCompileTime) ? int(Dst::SizeAtCompileTime)
49 : int(DstFlags)&
RowMajorBit ? int(Dst::ColsAtCompileTime)
50 : int(Dst::RowsAtCompileTime),
51 InnerMaxSize = int(Dst::IsVectorAtCompileTime) ? int(Dst::MaxSizeAtCompileTime)
52 : int(DstFlags)&
RowMajorBit ? int(Dst::MaxColsAtCompileTime)
53 : int(Dst::MaxRowsAtCompileTime),
54 RestrictedInnerSize = EIGEN_SIZE_MIN_PREFER_FIXED(InnerSize,MaxPacketSize),
55 RestrictedLinearSize = EIGEN_SIZE_MIN_PREFER_FIXED(Dst::SizeAtCompileTime,MaxPacketSize),
57 MaxSizeAtCompileTime = Dst::SizeAtCompileTime
61 typedef typename find_best_packet<DstScalar,RestrictedLinearSize>::type LinearPacketType;
62 typedef typename find_best_packet<DstScalar,RestrictedInnerSize>::type InnerPacketType;
79 StorageOrdersAgree = (int(DstIsRowMajor) == int(SrcIsRowMajor)),
80 MightVectorize =
bool(StorageOrdersAgree)
81 && (int(DstFlags) & int(SrcFlags) & ActualPacketAccessBit)
83 MayInnerVectorize = MightVectorize
84 && int(InnerSize)!=
Dynamic && int(InnerSize)%int(InnerPacketSize)==0
86 && (EIGEN_UNALIGNED_VECTORIZE || int(JointAlignment)>=int(InnerRequiredAlignment)),
87 MayLinearize =
bool(StorageOrdersAgree) && (int(DstFlags) & int(SrcFlags) &
LinearAccessBit),
88 MayLinearVectorize =
bool(MightVectorize) && bool(MayLinearize) && bool(DstHasDirectAccess)
89 && (EIGEN_UNALIGNED_VECTORIZE || (int(DstAlignment)>=int(LinearRequiredAlignment)) || MaxSizeAtCompileTime ==
Dynamic),
92 MaySliceVectorize = bool(MightVectorize) && bool(DstHasDirectAccess)
93 && (int(InnerMaxSize)==
Dynamic || int(InnerMaxSize)>=(EIGEN_UNALIGNED_VECTORIZE?InnerPacketSize:(3*InnerPacketSize)))
102 Traversal = int(Dst::SizeAtCompileTime) == 0 ? int(AllAtOnceTraversal)
103 : (int(MayLinearVectorize) && (LinearPacketSize>InnerPacketSize)) ? int(LinearVectorizedTraversal)
104 : int(MayInnerVectorize) ? int(InnerVectorizedTraversal)
105 : int(MayLinearVectorize) ? int(LinearVectorizedTraversal)
106 : int(MaySliceVectorize) ? int(SliceVectorizedTraversal)
107 : int(MayLinearize) ? int(LinearTraversal)
108 : int(DefaultTraversal),
109 Vectorized = int(Traversal) == InnerVectorizedTraversal
110 || int(Traversal) == LinearVectorizedTraversal
111 || int(Traversal) == SliceVectorizedTraversal
114 typedef typename conditional<int(Traversal)==LinearVectorizedTraversal, LinearPacketType, InnerPacketType>::type
PacketType;
118 ActualPacketSize = int(Traversal)==LinearVectorizedTraversal ? LinearPacketSize
119 : Vectorized ? InnerPacketSize
121 UnrollingLimit = EIGEN_UNROLLING_LIMIT * ActualPacketSize,
122 MayUnrollCompletely = int(Dst::SizeAtCompileTime) !=
Dynamic
123 && int(Dst::SizeAtCompileTime) * (int(DstEvaluator::CoeffReadCost)+int(SrcEvaluator::CoeffReadCost)) <=
int(UnrollingLimit),
124 MayUnrollInner = int(InnerSize) !=
Dynamic
125 && int(InnerSize) * (int(DstEvaluator::CoeffReadCost)+int(SrcEvaluator::CoeffReadCost)) <=
int(UnrollingLimit)
130 Unrolling = (int(Traversal) == int(InnerVectorizedTraversal) || int(Traversal) == int(DefaultTraversal))
132 int(MayUnrollCompletely) ? int(CompleteUnrolling)
133 : int(MayUnrollInner) ? int(InnerUnrolling)
136 :
int(Traversal) == int(LinearVectorizedTraversal)
137 ? ( bool(MayUnrollCompletely) && ( EIGEN_UNALIGNED_VECTORIZE || (int(DstAlignment)>=int(LinearRequiredAlignment)))
138 ? int(CompleteUnrolling)
140 :
int(Traversal) == int(LinearTraversal)
141 ? ( bool(MayUnrollCompletely) ? int(CompleteUnrolling)
143 #
if EIGEN_UNALIGNED_VECTORIZE
144 :
int(Traversal) == int(SliceVectorizedTraversal)
145 ? ( bool(MayUnrollInner) ? int(InnerUnrolling)
151 #ifdef EIGEN_DEBUG_ASSIGN
154 std::cerr <<
"DstXpr: " <<
typeid(
typename DstEvaluator::XprType).name() << std::endl;
155 std::cerr <<
"SrcXpr: " <<
typeid(
typename SrcEvaluator::XprType).name() << std::endl;
156 std::cerr.setf(std::ios::hex, std::ios::basefield);
157 std::cerr <<
"DstFlags" <<
" = " << DstFlags <<
" (" << demangle_flags(DstFlags) <<
" )" << std::endl;
158 std::cerr <<
"SrcFlags" <<
" = " << SrcFlags <<
" (" << demangle_flags(SrcFlags) <<
" )" << std::endl;
159 std::cerr.unsetf(std::ios::hex);
160 EIGEN_DEBUG_VAR(DstAlignment)
161 EIGEN_DEBUG_VAR(SrcAlignment)
162 EIGEN_DEBUG_VAR(LinearRequiredAlignment)
163 EIGEN_DEBUG_VAR(InnerRequiredAlignment)
164 EIGEN_DEBUG_VAR(JointAlignment)
165 EIGEN_DEBUG_VAR(InnerSize)
166 EIGEN_DEBUG_VAR(InnerMaxSize)
167 EIGEN_DEBUG_VAR(LinearPacketSize)
168 EIGEN_DEBUG_VAR(InnerPacketSize)
169 EIGEN_DEBUG_VAR(ActualPacketSize)
170 EIGEN_DEBUG_VAR(StorageOrdersAgree)
171 EIGEN_DEBUG_VAR(MightVectorize)
172 EIGEN_DEBUG_VAR(MayLinearize)
173 EIGEN_DEBUG_VAR(MayInnerVectorize)
174 EIGEN_DEBUG_VAR(MayLinearVectorize)
175 EIGEN_DEBUG_VAR(MaySliceVectorize)
176 std::cerr <<
"Traversal" <<
" = " << Traversal <<
" (" << demangle_traversal(Traversal) <<
")" << std::endl;
177 EIGEN_DEBUG_VAR(SrcEvaluator::CoeffReadCost)
178 EIGEN_DEBUG_VAR(DstEvaluator::CoeffReadCost)
179 EIGEN_DEBUG_VAR(Dst::SizeAtCompileTime)
180 EIGEN_DEBUG_VAR(UnrollingLimit)
181 EIGEN_DEBUG_VAR(MayUnrollCompletely)
182 EIGEN_DEBUG_VAR(MayUnrollInner)
183 std::cerr <<
"Unrolling" <<
" = " << Unrolling <<
" (" << demangle_unrolling(Unrolling) <<
")" << std::endl;
184 std::cerr << std::endl;
197 template<
typename Kernel,
int Index,
int Stop>
201 typedef typename Kernel::DstEvaluatorType DstEvaluatorType;
202 typedef typename DstEvaluatorType::XprType DstXprType;
205 outer =
Index / DstXprType::InnerSizeAtCompileTime,
206 inner =
Index % DstXprType::InnerSizeAtCompileTime
209 EIGEN_DEVICE_FUNC
static EIGEN_STRONG_INLINE
void run(Kernel &kernel)
211 kernel.assignCoeffByOuterInner(outer, inner);
216 template<
typename Kernel,
int Stop>
219 EIGEN_DEVICE_FUNC
static EIGEN_STRONG_INLINE
void run(Kernel&) { }
222 template<
typename Kernel,
int Index_,
int Stop>
225 EIGEN_DEVICE_FUNC
static EIGEN_STRONG_INLINE
void run(Kernel &kernel,
Index outer)
227 kernel.assignCoeffByOuterInner(outer, Index_);
232 template<
typename Kernel,
int Stop>
235 EIGEN_DEVICE_FUNC
static EIGEN_STRONG_INLINE
void run(Kernel&,
Index) { }
242 template<
typename Kernel,
int Index,
int Stop>
245 EIGEN_DEVICE_FUNC
static EIGEN_STRONG_INLINE
void run(Kernel& kernel)
247 kernel.assignCoeff(
Index);
252 template<
typename Kernel,
int Stop>
255 EIGEN_DEVICE_FUNC
static EIGEN_STRONG_INLINE
void run(Kernel&) { }
262 template<
typename Kernel,
int Index,
int Stop>
266 typedef typename Kernel::DstEvaluatorType DstEvaluatorType;
267 typedef typename DstEvaluatorType::XprType DstXprType;
268 typedef typename Kernel::PacketType PacketType;
271 outer =
Index / DstXprType::InnerSizeAtCompileTime,
272 inner =
Index % DstXprType::InnerSizeAtCompileTime,
273 SrcAlignment = Kernel::AssignmentTraits::SrcAlignment,
274 DstAlignment = Kernel::AssignmentTraits::DstAlignment
277 EIGEN_DEVICE_FUNC
static EIGEN_STRONG_INLINE
void run(Kernel &kernel)
279 kernel.template assignPacketByOuterInner<DstAlignment, SrcAlignment, PacketType>(outer, inner);
285 template<
typename Kernel,
int Stop>
288 EIGEN_DEVICE_FUNC
static EIGEN_STRONG_INLINE
void run(Kernel&) { }
291 template<
typename Kernel,
int Index_,
int Stop,
int SrcAlignment,
int DstAlignment>
294 typedef typename Kernel::PacketType PacketType;
295 EIGEN_DEVICE_FUNC
static EIGEN_STRONG_INLINE
void run(Kernel &kernel,
Index outer)
297 kernel.template assignPacketByOuterInner<DstAlignment, SrcAlignment, PacketType>(outer, Index_);
303 template<
typename Kernel,
int Stop,
int SrcAlignment,
int DstAlignment>
306 EIGEN_DEVICE_FUNC
static EIGEN_STRONG_INLINE
void run(Kernel &,
Index) { }
315 template<
typename Kernel,
316 int Traversal = Kernel::AssignmentTraits::Traversal,
317 int Unrolling = Kernel::AssignmentTraits::Unrolling>
325 template<
typename Kernel,
int Unrolling>
328 EIGEN_DEVICE_FUNC
static void EIGEN_STRONG_INLINE run(Kernel& )
330 typedef typename Kernel::DstEvaluatorType::XprType DstXprType;
331 EIGEN_STATIC_ASSERT(
int(DstXprType::SizeAtCompileTime) == 0,
332 EIGEN_INTERNAL_ERROR_PLEASE_FILE_A_BUG_REPORT)
340 template<
typename Kernel>
343 EIGEN_DEVICE_FUNC
static void EIGEN_STRONG_INLINE run(Kernel &kernel)
345 for(
Index outer = 0; outer < kernel.outerSize(); ++outer) {
346 for(
Index inner = 0; inner < kernel.innerSize(); ++inner) {
347 kernel.assignCoeffByOuterInner(outer, inner);
353 template<
typename Kernel>
356 EIGEN_DEVICE_FUNC
static EIGEN_STRONG_INLINE
void run(Kernel &kernel)
358 typedef typename Kernel::DstEvaluatorType::XprType DstXprType;
363 template<
typename Kernel>
366 EIGEN_DEVICE_FUNC
static EIGEN_STRONG_INLINE
void run(Kernel &kernel)
368 typedef typename Kernel::DstEvaluatorType::XprType DstXprType;
370 const Index outerSize = kernel.outerSize();
371 for(
Index outer = 0; outer < outerSize; ++outer)
384 template <
bool IsAligned = false>
388 template <
typename Kernel>
389 EIGEN_DEVICE_FUNC
static EIGEN_STRONG_INLINE
void run(Kernel&,
Index,
Index) {}
399 template <
typename Kernel>
400 static EIGEN_DONT_INLINE
void run(Kernel &kernel,
404 template <
typename Kernel>
405 EIGEN_DEVICE_FUNC
static EIGEN_STRONG_INLINE
void run(Kernel &kernel,
410 for (
Index index = start; index < end; ++index)
411 kernel.assignCoeff(index);
415 template<
typename Kernel>
418 EIGEN_DEVICE_FUNC
static EIGEN_STRONG_INLINE
void run(Kernel &kernel)
420 const Index size = kernel.size();
421 typedef typename Kernel::Scalar Scalar;
422 typedef typename Kernel::PacketType PacketType;
424 requestedAlignment = Kernel::AssignmentTraits::LinearRequiredAlignment,
426 dstIsAligned = int(Kernel::AssignmentTraits::DstAlignment)>=int(requestedAlignment),
428 : int(Kernel::AssignmentTraits::DstAlignment),
429 srcAlignment = Kernel::AssignmentTraits::JointAlignment
431 const Index alignedStart = dstIsAligned ? 0 : internal::first_aligned<requestedAlignment>(kernel.dstDataPtr(), size);
432 const Index alignedEnd = alignedStart + ((size-alignedStart)/packetSize)*packetSize;
436 for(
Index index = alignedStart; index < alignedEnd; index += packetSize)
437 kernel.template assignPacket<dstAlignment, srcAlignment, PacketType>(index);
443 template<
typename Kernel>
446 EIGEN_DEVICE_FUNC
static EIGEN_STRONG_INLINE
void run(Kernel &kernel)
448 typedef typename Kernel::DstEvaluatorType::XprType DstXprType;
449 typedef typename Kernel::PacketType PacketType;
451 enum { size = DstXprType::SizeAtCompileTime,
453 alignedSize = (size/packetSize)*packetSize };
464 template<
typename Kernel>
467 typedef typename Kernel::PacketType PacketType;
469 SrcAlignment = Kernel::AssignmentTraits::SrcAlignment,
470 DstAlignment = Kernel::AssignmentTraits::DstAlignment
472 EIGEN_DEVICE_FUNC
static EIGEN_STRONG_INLINE
void run(Kernel &kernel)
474 const Index innerSize = kernel.innerSize();
475 const Index outerSize = kernel.outerSize();
477 for(
Index outer = 0; outer < outerSize; ++outer)
478 for(
Index inner = 0; inner < innerSize; inner+=packetSize)
479 kernel.template assignPacketByOuterInner<DstAlignment, SrcAlignment, PacketType>(outer, inner);
483 template<
typename Kernel>
486 EIGEN_DEVICE_FUNC
static EIGEN_STRONG_INLINE
void run(Kernel &kernel)
488 typedef typename Kernel::DstEvaluatorType::XprType DstXprType;
493 template<
typename Kernel>
496 EIGEN_DEVICE_FUNC
static EIGEN_STRONG_INLINE
void run(Kernel &kernel)
498 typedef typename Kernel::DstEvaluatorType::XprType DstXprType;
499 typedef typename Kernel::AssignmentTraits Traits;
500 const Index outerSize = kernel.outerSize();
501 for(
Index outer = 0; outer < outerSize; ++outer)
503 Traits::SrcAlignment, Traits::DstAlignment>::run(kernel, outer);
511 template<
typename Kernel>
514 EIGEN_DEVICE_FUNC
static EIGEN_STRONG_INLINE
void run(Kernel &kernel)
516 const Index size = kernel.size();
517 for(
Index i = 0; i < size; ++i)
518 kernel.assignCoeff(i);
522 template<
typename Kernel>
525 EIGEN_DEVICE_FUNC
static EIGEN_STRONG_INLINE
void run(Kernel &kernel)
527 typedef typename Kernel::DstEvaluatorType::XprType DstXprType;
536 template<
typename Kernel>
539 EIGEN_DEVICE_FUNC
static EIGEN_STRONG_INLINE
void run(Kernel &kernel)
541 typedef typename Kernel::Scalar Scalar;
542 typedef typename Kernel::PacketType PacketType;
545 requestedAlignment = int(Kernel::AssignmentTraits::InnerRequiredAlignment),
547 dstIsAligned =
int(Kernel::AssignmentTraits::DstAlignment)>=int(requestedAlignment),
548 dstAlignment = alignable ? int(requestedAlignment)
549 : int(Kernel::AssignmentTraits::DstAlignment)
551 const Scalar *dst_ptr = kernel.dstDataPtr();
552 if((!
bool(dstIsAligned)) && (UIntPtr(dst_ptr) %
sizeof(Scalar))>0)
557 const Index packetAlignedMask = packetSize - 1;
558 const Index innerSize = kernel.innerSize();
559 const Index outerSize = kernel.outerSize();
560 const Index alignedStep = alignable ? (packetSize - kernel.outerStride() % packetSize) & packetAlignedMask : 0;
561 Index alignedStart = ((!alignable) ||
bool(dstIsAligned)) ? 0 : internal::first_aligned<requestedAlignment>(dst_ptr, innerSize);
563 for(
Index outer = 0; outer < outerSize; ++outer)
565 const Index alignedEnd = alignedStart + ((innerSize-alignedStart) & ~packetAlignedMask);
567 for(
Index inner = 0; inner<alignedStart ; ++inner)
568 kernel.assignCoeffByOuterInner(outer, inner);
571 for(
Index inner = alignedStart; inner<alignedEnd; inner+=packetSize)
572 kernel.template assignPacketByOuterInner<dstAlignment, Unaligned, PacketType>(outer, inner);
575 for(
Index inner = alignedEnd; inner<innerSize ; ++inner)
576 kernel.assignCoeffByOuterInner(outer, inner);
578 alignedStart = numext::mini((alignedStart+alignedStep)%packetSize, innerSize);
583 #if EIGEN_UNALIGNED_VECTORIZE
584 template<
typename Kernel>
587 EIGEN_DEVICE_FUNC
static EIGEN_STRONG_INLINE
void run(Kernel &kernel)
589 typedef typename Kernel::DstEvaluatorType::XprType DstXprType;
590 typedef typename Kernel::PacketType PacketType;
592 enum { innerSize = DstXprType::InnerSizeAtCompileTime,
594 vectorizableSize = (innerSize/packetSize)*packetSize,
595 size = DstXprType::SizeAtCompileTime };
597 for(
Index outer = 0; outer < kernel.outerSize(); ++outer)
599 copy_using_evaluator_innervec_InnerUnrolling<Kernel, 0, vectorizableSize, 0, 0>::run(kernel, outer);
600 copy_using_evaluator_DefaultTraversal_InnerUnrolling<Kernel, vectorizableSize, innerSize>::run(kernel, outer);
617 template<
typename DstEvaluatorTypeT,
typename SrcEvaluatorTypeT,
typename Functor,
int Version = Specialized>
621 typedef typename DstEvaluatorTypeT::XprType DstXprType;
622 typedef typename SrcEvaluatorTypeT::XprType SrcXprType;
625 typedef DstEvaluatorTypeT DstEvaluatorType;
626 typedef SrcEvaluatorTypeT SrcEvaluatorType;
627 typedef typename DstEvaluatorType::Scalar Scalar;
632 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
634 : m_dst(dst), m_src(src), m_functor(func), m_dstExpr(dstExpr)
636 #ifdef EIGEN_DEBUG_ASSIGN
637 AssignmentTraits::debug();
641 EIGEN_DEVICE_FUNC
Index size()
const {
return m_dstExpr.size(); }
642 EIGEN_DEVICE_FUNC
Index innerSize()
const {
return m_dstExpr.innerSize(); }
643 EIGEN_DEVICE_FUNC
Index outerSize()
const {
return m_dstExpr.outerSize(); }
644 EIGEN_DEVICE_FUNC
Index rows()
const {
return m_dstExpr.rows(); }
645 EIGEN_DEVICE_FUNC
Index cols()
const {
return m_dstExpr.cols(); }
646 EIGEN_DEVICE_FUNC
Index outerStride()
const {
return m_dstExpr.outerStride(); }
648 EIGEN_DEVICE_FUNC DstEvaluatorType& dstEvaluator() {
return m_dst; }
649 EIGEN_DEVICE_FUNC
const SrcEvaluatorType& srcEvaluator()
const {
return m_src; }
654 m_functor.assignCoeff(m_dst.coeffRef(row,col), m_src.coeff(row,col));
660 m_functor.assignCoeff(m_dst.coeffRef(index), m_src.coeff(index));
666 Index row = rowIndexByOuterInner(outer, inner);
667 Index col = colIndexByOuterInner(outer, inner);
672 template<
int StoreMode,
int LoadMode,
typename PacketType>
673 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void assignPacket(
Index row,
Index col)
675 m_functor.template assignPacket<StoreMode>(&m_dst.coeffRef(row,col), m_src.template packet<LoadMode,PacketType>(row,col));
678 template<
int StoreMode,
int LoadMode,
typename PacketType>
679 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void assignPacket(
Index index)
681 m_functor.template assignPacket<StoreMode>(&m_dst.coeffRef(index), m_src.template packet<LoadMode,PacketType>(index));
684 template<
int StoreMode,
int LoadMode,
typename PacketType>
685 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void assignPacketByOuterInner(
Index outer,
Index inner)
687 Index row = rowIndexByOuterInner(outer, inner);
688 Index col = colIndexByOuterInner(outer, inner);
689 assignPacket<StoreMode,LoadMode,PacketType>(row, col);
692 EIGEN_DEVICE_FUNC
static EIGEN_STRONG_INLINE
Index rowIndexByOuterInner(
Index outer,
Index inner)
694 typedef typename DstEvaluatorType::ExpressionTraits Traits;
695 return int(Traits::RowsAtCompileTime) == 1 ? 0
696 : int(Traits::ColsAtCompileTime) == 1 ? inner
701 EIGEN_DEVICE_FUNC
static EIGEN_STRONG_INLINE
Index colIndexByOuterInner(
Index outer,
Index inner)
703 typedef typename DstEvaluatorType::ExpressionTraits Traits;
704 return int(Traits::ColsAtCompileTime) == 1 ? 0
705 : int(Traits::RowsAtCompileTime) == 1 ? inner
710 EIGEN_DEVICE_FUNC
const Scalar* dstDataPtr()
const
712 return m_dstExpr.data();
716 DstEvaluatorType& m_dst;
717 const SrcEvaluatorType& m_src;
718 const Functor &m_functor;
720 DstXprType& m_dstExpr;
727 template<
typename DstEvaluatorTypeT,
typename SrcEvaluatorTypeT,
typename Functor>
733 typedef typename Base::Scalar Scalar;
734 typedef typename Base::DstXprType DstXprType;
739 :
Base(dst, src, func, dstExpr)
748 template<
typename DstXprType,
typename SrcXprType,
typename Functor>
749 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
750 void resize_if_allowed(DstXprType &dst,
const SrcXprType& src,
const Functor &)
752 EIGEN_ONLY_USED_FOR_DEBUG(dst);
753 EIGEN_ONLY_USED_FOR_DEBUG(src);
754 eigen_assert(dst.rows() == src.rows() && dst.cols() == src.cols());
757 template<
typename DstXprType,
typename SrcXprType,
typename T1,
typename T2>
758 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
761 Index dstRows = src.rows();
762 Index dstCols = src.cols();
763 if(((dst.rows()!=dstRows) || (dst.cols()!=dstCols)))
764 dst.resize(dstRows, dstCols);
765 eigen_assert(dst.rows() == dstRows && dst.cols() == dstCols);
768 template<
typename DstXprType,
typename SrcXprType,
typename Functor>
769 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void call_dense_assignment_loop(DstXprType& dst,
const SrcXprType& src,
const Functor &func)
771 typedef evaluator<DstXprType> DstEvaluatorType;
772 typedef evaluator<SrcXprType> SrcEvaluatorType;
774 SrcEvaluatorType srcEvaluator(src);
778 resize_if_allowed(dst, src, func);
780 DstEvaluatorType dstEvaluator(dst);
782 typedef generic_dense_assignment_kernel<DstEvaluatorType,SrcEvaluatorType,Functor> Kernel;
783 Kernel kernel(dstEvaluator, srcEvaluator, func, dst.const_cast_derived());
785 dense_assignment_loop<Kernel>::run(kernel);
788 template<
typename DstXprType,
typename SrcXprType>
789 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void call_dense_assignment_loop(DstXprType& dst,
const SrcXprType& src)
791 call_dense_assignment_loop(dst, src, internal::assign_op<typename DstXprType::Scalar,typename SrcXprType::Scalar>());
801 template<
typename DstShape,
typename SrcShape>
struct AssignmentKind;
811 template<
typename DstXprType,
typename SrcXprType,
typename Functor,
822 template<
typename Dst,
typename Src>
823 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
824 void call_assignment(Dst& dst,
const Src& src)
828 template<
typename Dst,
typename Src>
829 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
830 void call_assignment(
const Dst& dst,
const Src& src)
836 template<
typename Dst,
typename Src,
typename Func>
837 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
838 void call_assignment(Dst& dst,
const Src& src,
const Func& func,
typename enable_if< evaluator_assume_aliasing<Src>::value,
void*>::type = 0)
840 typename plain_matrix_type<Src>::type tmp(src);
841 call_assignment_no_alias(dst, tmp, func);
844 template<
typename Dst,
typename Src,
typename Func>
845 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
846 void call_assignment(Dst& dst,
const Src& src,
const Func& func,
typename enable_if<!evaluator_assume_aliasing<Src>::value,
void*>::type = 0)
848 call_assignment_no_alias(dst, src, func);
853 template<
typename Dst,
template <
typename>
class StorageBase,
typename Src,
typename Func>
854 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
855 void call_assignment(NoAlias<Dst,StorageBase>& dst,
const Src& src,
const Func& func)
857 call_assignment_no_alias(dst.expression(), src, func);
861 template<
typename Dst,
typename Src,
typename Func>
862 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
863 void call_assignment_no_alias(Dst& dst,
const Src& src,
const Func& func)
866 NeedToTranspose = ( (int(Dst::RowsAtCompileTime) == 1 && int(Src::ColsAtCompileTime) == 1)
867 || (
int(Dst::ColsAtCompileTime) == 1 && int(Src::RowsAtCompileTime) == 1)
868 ) && int(Dst::SizeAtCompileTime) != 1
871 typedef typename internal::conditional<NeedToTranspose, Transpose<Dst>, Dst>::type ActualDstTypeCleaned;
872 typedef typename internal::conditional<NeedToTranspose, Transpose<Dst>, Dst&>::type ActualDstType;
873 ActualDstType actualDst(dst);
876 EIGEN_STATIC_ASSERT_LVALUE(Dst)
877 EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(ActualDstTypeCleaned,Src)
878 EIGEN_CHECK_BINARY_COMPATIBILIY(Func,
typename ActualDstTypeCleaned::Scalar,
typename Src::Scalar);
880 Assignment<ActualDstTypeCleaned,Src,Func>::run(actualDst, src, func);
883 template<
typename Dst,
typename Src,
typename Func>
884 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
885 void call_restricted_packet_assignment_no_alias(Dst& dst,
const Src& src,
const Func& func)
887 typedef evaluator<Dst> DstEvaluatorType;
888 typedef evaluator<Src> SrcEvaluatorType;
889 typedef restricted_packet_dense_assignment_kernel<DstEvaluatorType,SrcEvaluatorType,Func> Kernel;
891 EIGEN_STATIC_ASSERT_LVALUE(Dst)
892 EIGEN_CHECK_BINARY_COMPATIBILIY(Func,
typename Dst::Scalar,
typename Src::Scalar);
894 SrcEvaluatorType srcEvaluator(src);
895 resize_if_allowed(dst, src, func);
897 DstEvaluatorType dstEvaluator(dst);
898 Kernel kernel(dstEvaluator, srcEvaluator, func, dst.const_cast_derived());
900 dense_assignment_loop<Kernel>::run(kernel);
903 template<
typename Dst,
typename Src>
904 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
905 void call_assignment_no_alias(Dst& dst,
const Src& src)
907 call_assignment_no_alias(dst, src, internal::assign_op<typename Dst::Scalar,typename Src::Scalar>());
910 template<
typename Dst,
typename Src,
typename Func>
911 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
912 void call_assignment_no_alias_no_transpose(Dst& dst,
const Src& src,
const Func& func)
915 EIGEN_STATIC_ASSERT_LVALUE(Dst)
916 EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Dst,Src)
917 EIGEN_CHECK_BINARY_COMPATIBILIY(Func,
typename Dst::Scalar,
typename Src::Scalar);
919 Assignment<Dst,Src,Func>::run(dst, src, func);
921 template<
typename Dst,
typename Src>
922 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
923 void call_assignment_no_alias_no_transpose(Dst& dst,
const Src& src)
925 call_assignment_no_alias_no_transpose(dst, src, internal::assign_op<typename Dst::Scalar,typename Src::Scalar>());
929 template<
typename Dst,
typename Src>
void check_for_aliasing(
const Dst &dst,
const Src &src);
934 template<
typename DstXprType,
typename SrcXprType,
typename Functor,
typename Weak>
938 static EIGEN_STRONG_INLINE
void run(DstXprType &dst,
const SrcXprType &src,
const Functor &func)
940 #ifndef EIGEN_NO_DEBUG
941 internal::check_for_aliasing(dst, src);
944 call_dense_assignment_loop(dst, src, func);
952 template<
typename DstXprType,
typename SrcXprType,
typename Functor,
typename Weak>
958 Index dstRows = src.rows();
959 Index dstCols = src.cols();
960 if((dst.rows()!=dstRows) || (dst.cols()!=dstCols))
961 dst.resize(dstRows, dstCols);
963 eigen_assert(dst.rows() == src.rows() && dst.cols() == src.cols());
969 template<
typename SrcScalarType>
973 Index dstRows = src.rows();
974 Index dstCols = src.cols();
975 if((dst.rows()!=dstRows) || (dst.cols()!=dstCols))
976 dst.resize(dstRows, dstCols);
978 eigen_assert(dst.rows() == src.rows() && dst.cols() == src.cols());
982 template<
typename SrcScalarType>
986 Index dstRows = src.rows();
987 Index dstCols = src.cols();
988 if((dst.rows()!=dstRows) || (dst.cols()!=dstCols))
989 dst.resize(dstRows, dstCols);
991 eigen_assert(dst.rows() == src.rows() && dst.cols() == src.cols());
1000 #endif // EIGEN_ASSIGN_EVALUATOR_H