12 #ifndef EIGEN_ASSIGN_H 13 #define EIGEN_ASSIGN_H 23 template <
typename Derived,
typename OtherDerived>
36 InnerSize = int(Derived::IsVectorAtCompileTime) ? int(Derived::SizeAtCompileTime)
37 : int(Derived::Flags)&
RowMajorBit ? int(Derived::ColsAtCompileTime)
38 : int(Derived::RowsAtCompileTime),
40 : int(Derived::Flags)&
RowMajorBit ? int(Derived::MaxColsAtCompileTime)
41 : int(Derived::MaxRowsAtCompileTime),
79 MayUnrollCompletely = int(Derived::SizeAtCompileTime) !=
Dynamic 80 && int(OtherDerived::CoeffReadCost) !=
Dynamic 81 && int(Derived::SizeAtCompileTime) * int(OtherDerived::CoeffReadCost) <= int(
UnrollingLimit),
83 && int(OtherDerived::CoeffReadCost) !=
Dynamic 102 #ifdef EIGEN_DEBUG_ASSIGN 134 template<
typename Derived1,
typename Derived2,
int Index,
int Stop>
138 outer = Index / Derived1::InnerSizeAtCompileTime,
139 inner = Index % Derived1::InnerSizeAtCompileTime
144 dst.copyCoeffByOuterInner(outer, inner, src);
149 template<
typename Derived1,
typename Derived2,
int Stop>
155 template<
typename Derived1,
typename Derived2,
int Index,
int Stop>
160 dst.copyCoeffByOuterInner(outer, Index, src);
165 template<
typename Derived1,
typename Derived2,
int Stop>
175 template<
typename Derived1,
typename Derived2,
int Index,
int Stop>
180 dst.copyCoeff(Index, src);
185 template<
typename Derived1,
typename Derived2,
int Stop>
195 template<
typename Derived1,
typename Derived2,
int Index,
int Stop>
199 outer = Index / Derived1::InnerSizeAtCompileTime,
200 inner = Index % Derived1::InnerSizeAtCompileTime,
206 dst.template copyPacketByOuterInner<Derived2, Aligned, JointAlignment>(outer, inner, src);
212 template<
typename Derived1,
typename Derived2,
int Stop>
218 template<
typename Derived1,
typename Derived2,
int Index,
int Stop>
223 dst.template copyPacketByOuterInner<Derived2, Aligned, Aligned>(outer, Index, src);
229 template<
typename Derived1,
typename Derived2,
int Stop>
239 template<
typename Derived1,
typename Derived2,
249 template<
typename Derived1,
typename Derived2,
int Unrolling,
int Version>
252 static inline void run(Derived1 &,
const Derived2 &) { }
255 template<
typename Derived1,
typename Derived2,
int Version>
258 typedef typename Derived1::Index
Index;
259 static inline void run(Derived1 &dst,
const Derived2 &src)
261 const Index innerSize = dst.innerSize();
262 const Index outerSize = dst.outerSize();
263 for(Index outer = 0; outer < outerSize; ++outer)
264 for(Index inner = 0; inner < innerSize; ++inner)
265 dst.copyCoeffByOuterInner(outer, inner, src);
269 template<
typename Derived1,
typename Derived2,
int Version>
279 template<
typename Derived1,
typename Derived2,
int Version>
282 typedef typename Derived1::Index
Index;
285 const Index outerSize = dst.outerSize();
286 for(Index outer = 0; outer < outerSize; ++outer)
288 ::run(dst, src, outer);
296 template<
typename Derived1,
typename Derived2,
int Version>
299 typedef typename Derived1::Index
Index;
300 static inline void run(Derived1 &dst,
const Derived2 &src)
302 const Index size = dst.size();
303 for(Index i = 0; i < size; ++i)
304 dst.copyCoeff(i, src);
308 template<
typename Derived1,
typename Derived2,
int Version>
322 template<
typename Derived1,
typename Derived2,
int Version>
325 typedef typename Derived1::Index
Index;
326 static inline void run(Derived1 &dst,
const Derived2 &src)
328 const Index innerSize = dst.innerSize();
329 const Index outerSize = dst.outerSize();
331 for(Index outer = 0; outer < outerSize; ++outer)
332 for(Index inner = 0; inner < innerSize; inner+=packetSize)
333 dst.template copyPacketByOuterInner<Derived2, Aligned, Aligned>(outer, inner, src);
337 template<
typename Derived1,
typename Derived2,
int Version>
347 template<
typename Derived1,
typename Derived2,
int Version>
350 typedef typename Derived1::Index
Index;
353 const Index outerSize = dst.outerSize();
354 for(Index outer = 0; outer < outerSize; ++outer)
356 ::run(dst, src, outer);
364 template <
bool IsAligned = false>
367 template <
typename Derived,
typename OtherDerived>
377 template <
typename Derived,
typename OtherDerived>
378 static EIGEN_DONT_INLINE void run(
const Derived& src, OtherDerived& dst,
typename Derived::Index start,
typename Derived::Index end)
380 template <
typename Derived,
typename OtherDerived>
381 static EIGEN_STRONG_INLINE void run(
const Derived& src, OtherDerived& dst,
typename Derived::Index start,
typename Derived::Index end)
384 for (
typename Derived::Index index = start; index < end; ++index)
385 dst.copyCoeff(index, src);
389 template<
typename Derived1,
typename Derived2,
int Version>
392 typedef typename Derived1::Index
Index;
395 const Index size = dst.size();
398 packetSize = PacketTraits::size,
404 const Index alignedEnd = alignedStart + ((size-alignedStart)/packetSize)*packetSize;
408 for(Index index = alignedStart; index < alignedEnd; index += packetSize)
410 dst.template copyPacket<Derived2, dstAlignment, srcAlignment>(index, src);
417 template<
typename Derived1,
typename Derived2,
int Version>
420 typedef typename Derived1::Index
Index;
423 enum { size = Derived1::SizeAtCompileTime,
425 alignedSize = (size/packetSize)*packetSize };
436 template<
typename Derived1,
typename Derived2,
int Version>
439 typedef typename Derived1::Index
Index;
440 static inline void run(Derived1 &dst,
const Derived2 &src)
444 packetSize = PacketTraits::size,
445 alignable = PacketTraits::AlignedOnScalar,
449 const Index packetAlignedMask = packetSize - 1;
450 const Index innerSize = dst.innerSize();
451 const Index outerSize = dst.outerSize();
452 const Index alignedStep = alignable ? (packetSize - dst.outerStride() % packetSize) & packetAlignedMask : 0;
456 for(Index outer = 0; outer < outerSize; ++outer)
458 const Index alignedEnd = alignedStart + ((innerSize-alignedStart) & ~packetAlignedMask);
460 for(Index inner = 0; inner<alignedStart ; ++inner)
461 dst.copyCoeffByOuterInner(outer, inner, src);
464 for(Index inner = alignedStart; inner<alignedEnd; inner+=packetSize)
465 dst.template copyPacketByOuterInner<Derived2, dstAlignment, Unaligned>(outer, inner, src);
468 for(Index inner = alignedEnd; inner<innerSize ; ++inner)
469 dst.copyCoeffByOuterInner(outer, inner, src);
471 alignedStart = std::min<Index>((alignedStart+alignedStep)%packetSize, innerSize);
482 template<
typename Derived>
483 template<
typename OtherDerived>
493 EIGEN_STATIC_ASSERT(SameType,YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
495 #ifdef EIGEN_DEBUG_ASSIGN 498 eigen_assert(rows() == other.rows() && cols() == other.cols());
501 #ifndef EIGEN_NO_DEBUG 502 checkTransposeAliasing(other.derived());
509 template<
typename Derived,
typename OtherDerived,
511 bool NeedToTranspose = ((
int(Derived::RowsAtCompileTime) == 1 &&
int(OtherDerived::ColsAtCompileTime) == 1)
514 (int(Derived::ColsAtCompileTime) == 1 && int(OtherDerived::RowsAtCompileTime) == 1))
515 && int(Derived::SizeAtCompileTime) != 1>
518 template<
typename Derived,
typename OtherDerived>
520 static EIGEN_STRONG_INLINE Derived&
run(Derived& dst,
const OtherDerived& other) {
return dst.lazyAssign(other.derived()); }
521 template<
typename ActualDerived,
typename ActualOtherDerived>
524 template<
typename Derived,
typename OtherDerived>
526 static EIGEN_STRONG_INLINE Derived&
run(Derived& dst,
const OtherDerived& other) {
return dst.lazyAssign(other.eval()); }
528 template<
typename Derived,
typename OtherDerived>
530 static EIGEN_STRONG_INLINE Derived&
run(Derived& dst,
const OtherDerived& other) {
return dst.lazyAssign(other.transpose()); }
531 template<
typename ActualDerived,
typename ActualOtherDerived>
534 template<
typename Derived,
typename OtherDerived>
536 static EIGEN_STRONG_INLINE Derived&
run(Derived& dst,
const OtherDerived& other) {
return dst.lazyAssign(other.transpose().eval()); }
541 template<
typename Derived>
542 template<
typename OtherDerived>
548 template<
typename Derived>
554 template<
typename Derived>
560 template<
typename Derived>
561 template <
typename OtherDerived>
567 template<
typename Derived>
568 template <
typename OtherDerived>
574 template<
typename Derived>
575 template<
typename OtherDerived>
583 #endif // EIGEN_ASSIGN_H
static EIGEN_STRONG_INLINE void run(const Derived &, OtherDerived &, typename Derived::Index, typename Derived::Index)
const unsigned int ActualPacketAccessBit
static EIGEN_STRONG_INLINE Derived & evalTo(ActualDerived &dst, const ActualOtherDerived &other)
#define EIGEN_STRONG_INLINE
static EIGEN_STRONG_INLINE void run(Derived1 &dst, const Derived2 &src)
static void run(Derived1 &dst, const Derived2 &src)
static EIGEN_STRONG_INLINE void run(Derived1 &, const Derived2 &, typename Derived1::Index)
Expression of the transpose of a matrix.
const unsigned int DirectAccessBit
static EIGEN_STRONG_INLINE void run(Derived1 &dst, const Derived2 &src)
iterative scaling algorithm to equilibrate rows and column norms in matrices
static EIGEN_STRONG_INLINE void run(Derived1 &, const Derived2 &)
#define EIGEN_STATIC_ASSERT(CONDITION, MSG)
const unsigned int RowMajorBit
Base class for all dense matrices, vectors, and arrays.
#define EIGEN_STATIC_ASSERT_LVALUE(Derived)
static EIGEN_STRONG_INLINE void run(Derived1 &dst, const Derived2 &src)
static EIGEN_STRONG_INLINE void run(Derived1 &, const Derived2 &)
const unsigned int AlignedBit
static void run(Derived1 &dst, const Derived2 &src)
Derived & lazyAssign(const DenseBase< OtherDerived > &other)
static EIGEN_STRONG_INLINE Derived & run(Derived &dst, const OtherDerived &other)
static EIGEN_STRONG_INLINE Derived & evalTo(ActualDerived &dst, const ActualOtherDerived &other)
static EIGEN_STRONG_INLINE void run(const Derived &src, OtherDerived &dst, typename Derived::Index start, typename Derived::Index end)
static EIGEN_STRONG_INLINE void run(Derived1 &dst, const Derived2 &src)
static EIGEN_STRONG_INLINE void run(Derived1 &dst, const Derived2 &src)
const unsigned int EvalBeforeAssigningBit
static EIGEN_STRONG_INLINE void run(Derived1 &dst, const Derived2 &src)
static EIGEN_STRONG_INLINE void run(Derived1 &dst, const Derived2 &src, typename Derived1::Index outer)
static void run(Derived1 &, const Derived2 &)
static EIGEN_STRONG_INLINE void run(Derived1 &, const Derived2 &)
static void run(Derived1 &dst, const Derived2 &src)
static EIGEN_STRONG_INLINE Derived & run(Derived &dst, const OtherDerived &other)
Derived & operator=(const DenseBase< OtherDerived > &other)
static void run(Derived1 &dst, const Derived2 &src)
static EIGEN_STRONG_INLINE void run(Derived1 &dst, const Derived2 &src)
static EIGEN_STRONG_INLINE void run(Derived1 &, const Derived2 &, typename Derived1::Index)
static EIGEN_STRONG_INLINE Derived & run(Derived &dst, const OtherDerived &other)
static EIGEN_STRONG_INLINE Derived & run(Derived &dst, const OtherDerived &other)
#define EIGEN_DONT_INLINE
#define EIGEN_DEBUG_VAR(x)
static Derived::Index first_aligned(const Derived &m)
static EIGEN_STRONG_INLINE void run(Derived1 &dst, const Derived2 &src, typename Derived1::Index outer)
Derived & operator=(const MatrixBase &other)
static EIGEN_STRONG_INLINE void run(Derived1 &dst, const Derived2 &src)
Base class for all dense matrices, vectors, and expressions.
const unsigned int LinearAccessBit
#define EIGEN_UNROLLING_LIMIT
static EIGEN_STRONG_INLINE void run(Derived1 &dst, const Derived2 &src)
static EIGEN_STRONG_INLINE void run(Derived1 &dst, const Derived2 &src)
#define EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(TYPE0, TYPE1)