From 2b53fd4d53c87d41e26e4f178431f904ca2a42cd Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Thu, 10 Jul 2008 16:15:55 +0000 Subject: [PATCH] some performance fixes in Assign.h reported by Gael. Some doc update in Cwise. --- Eigen/src/Core/Assign.h | 32 ++++++++++++++++---------------- Eigen/src/Core/Cwise.h | 8 ++------ 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/Eigen/src/Core/Assign.h b/Eigen/src/Core/Assign.h index 1712846a3..828b49725 100644 --- a/Eigen/src/Core/Assign.h +++ b/Eigen/src/Core/Assign.h @@ -203,15 +203,15 @@ struct ei_assign_impl { static void run(Derived1 &dst, const Derived2 &src) { - const bool rowMajor = int(Derived1::Flags)&RowMajorBit; const int innerSize = dst.innerSize(); const int outerSize = dst.outerSize(); for(int j = 0; j < outerSize; j++) for(int i = 0; i < innerSize; i++) { - const int row = rowMajor ? j : i; - const int col = rowMajor ? i : j; - dst.coeffRef(row, col) = src.coeff(row, col); + if(int(Derived1::Flags)&RowMajorBit) + dst.coeffRef(j, i) = src.coeff(j, i); + else + dst.coeffRef(i, j) = src.coeff(i, j); } } }; @@ -254,14 +254,13 @@ struct ei_assign_impl const int outerSize = dst.outerSize(); const int packetSize = ei_packet_traits::size; for(int j = 0; j < outerSize; j++) - { for(int i = 0; i < innerSize; i+=packetSize) { - const int row = rowMajor ? j : i; - const int col = rowMajor ? i : j; - dst.template writePacket(row, col, src.template packet(row, col)); + if(int(Derived1::Flags)&RowMajorBit) + dst.template writePacket(j, i, src.template packet(j, i)); + else + dst.template writePacket(i, j, src.template packet(i, j)); } - } } }; @@ -336,7 +335,6 @@ struct ei_assign_impl static void run(Derived1 &dst, const Derived2 &src) { const int packetSize = ei_packet_traits::size; - const bool rowMajor = Derived1::Flags&RowMajorBit; const int innerSize = dst.innerSize(); const int outerSize = dst.outerSize(); const int alignedInnerSize = (innerSize/packetSize)*packetSize; @@ -346,17 +344,19 @@ struct ei_assign_impl // do the vectorizable part of the assignment for (int index = 0; index(row, col, src.template packet(row, col)); + if(Derived1::Flags&RowMajorBit) + dst.template writePacket(i, index, src.template packet(i, index)); + else + dst.template writePacket(index, i, src.template packet(index, i)); } // do the non-vectorizable part of the assignment for (int index = alignedInnerSize; index class Cwise ExpressionTypeNested m_matrix; }; -/** \array_module - * - * \returns a Cwise expression of *this providing additional coefficient-wise operations +/** \returns a Cwise wrapper of *this providing additional coefficient-wise operations * * \sa class Cwise */ @@ -157,9 +155,7 @@ MatrixBase::cwise() const return derived(); } -/** \array_module - * - * \returns a Cwise expression of *this providing additional coefficient-wise operations +/** \returns a Cwise wrapper of *this providing additional coefficient-wise operations * * \sa class Cwise */