mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-06-04 18:54:00 +08:00
some performance fixes in Assign.h reported by Gael. Some doc update in
Cwise.
This commit is contained in:
parent
7b4c6b8862
commit
2b53fd4d53
@ -203,15 +203,15 @@ struct ei_assign_impl<Derived1, Derived2, NoVectorization, NoUnrolling>
|
|||||||
{
|
{
|
||||||
static void run(Derived1 &dst, const Derived2 &src)
|
static void run(Derived1 &dst, const Derived2 &src)
|
||||||
{
|
{
|
||||||
const bool rowMajor = int(Derived1::Flags)&RowMajorBit;
|
|
||||||
const int innerSize = dst.innerSize();
|
const int innerSize = dst.innerSize();
|
||||||
const int outerSize = dst.outerSize();
|
const int outerSize = dst.outerSize();
|
||||||
for(int j = 0; j < outerSize; j++)
|
for(int j = 0; j < outerSize; j++)
|
||||||
for(int i = 0; i < innerSize; i++)
|
for(int i = 0; i < innerSize; i++)
|
||||||
{
|
{
|
||||||
const int row = rowMajor ? j : i;
|
if(int(Derived1::Flags)&RowMajorBit)
|
||||||
const int col = rowMajor ? i : j;
|
dst.coeffRef(j, i) = src.coeff(j, i);
|
||||||
dst.coeffRef(row, col) = src.coeff(row, col);
|
else
|
||||||
|
dst.coeffRef(i, j) = src.coeff(i, j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -254,13 +254,12 @@ struct ei_assign_impl<Derived1, Derived2, InnerVectorization, NoUnrolling>
|
|||||||
const int outerSize = dst.outerSize();
|
const int outerSize = dst.outerSize();
|
||||||
const int packetSize = ei_packet_traits<typename Derived1::Scalar>::size;
|
const int packetSize = ei_packet_traits<typename Derived1::Scalar>::size;
|
||||||
for(int j = 0; j < outerSize; j++)
|
for(int j = 0; j < outerSize; j++)
|
||||||
{
|
|
||||||
for(int i = 0; i < innerSize; i+=packetSize)
|
for(int i = 0; i < innerSize; i+=packetSize)
|
||||||
{
|
{
|
||||||
const int row = rowMajor ? j : i;
|
if(int(Derived1::Flags)&RowMajorBit)
|
||||||
const int col = rowMajor ? i : j;
|
dst.template writePacket<Aligned>(j, i, src.template packet<Aligned>(j, i));
|
||||||
dst.template writePacket<Aligned>(row, col, src.template packet<Aligned>(row, col));
|
else
|
||||||
}
|
dst.template writePacket<Aligned>(i, j, src.template packet<Aligned>(i, j));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -336,7 +335,6 @@ struct ei_assign_impl<Derived1, Derived2, SliceVectorization, NoUnrolling>
|
|||||||
static void run(Derived1 &dst, const Derived2 &src)
|
static void run(Derived1 &dst, const Derived2 &src)
|
||||||
{
|
{
|
||||||
const int packetSize = ei_packet_traits<typename Derived1::Scalar>::size;
|
const int packetSize = ei_packet_traits<typename Derived1::Scalar>::size;
|
||||||
const bool rowMajor = Derived1::Flags&RowMajorBit;
|
|
||||||
const int innerSize = dst.innerSize();
|
const int innerSize = dst.innerSize();
|
||||||
const int outerSize = dst.outerSize();
|
const int outerSize = dst.outerSize();
|
||||||
const int alignedInnerSize = (innerSize/packetSize)*packetSize;
|
const int alignedInnerSize = (innerSize/packetSize)*packetSize;
|
||||||
@ -346,17 +344,19 @@ struct ei_assign_impl<Derived1, Derived2, SliceVectorization, NoUnrolling>
|
|||||||
// do the vectorizable part of the assignment
|
// do the vectorizable part of the assignment
|
||||||
for (int index = 0; index<alignedInnerSize ; index+=packetSize)
|
for (int index = 0; index<alignedInnerSize ; index+=packetSize)
|
||||||
{
|
{
|
||||||
const int row = rowMajor ? i : index;
|
if(Derived1::Flags&RowMajorBit)
|
||||||
const int col = rowMajor ? index : i;
|
dst.template writePacket<Unaligned>(i, index, src.template packet<Unaligned>(i, index));
|
||||||
dst.template writePacket<Unaligned>(row, col, src.template packet<Unaligned>(row, col));
|
else
|
||||||
|
dst.template writePacket<Unaligned>(index, i, src.template packet<Unaligned>(index, i));
|
||||||
}
|
}
|
||||||
|
|
||||||
// do the non-vectorizable part of the assignment
|
// do the non-vectorizable part of the assignment
|
||||||
for (int index = alignedInnerSize; index<innerSize ; index++)
|
for (int index = alignedInnerSize; index<innerSize ; index++)
|
||||||
{
|
{
|
||||||
const int row = rowMajor ? i : index;
|
if(Derived1::Flags&RowMajorBit)
|
||||||
const int col = rowMajor ? index : i;
|
dst.coeffRef(i, index) = src.coeff(i, index);
|
||||||
dst.coeffRef(row, col) = src.coeff(row, col);
|
else
|
||||||
|
dst.coeffRef(index, i) = src.coeff(index, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,9 +144,7 @@ template<typename ExpressionType> class Cwise
|
|||||||
ExpressionTypeNested m_matrix;
|
ExpressionTypeNested m_matrix;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** \array_module
|
/** \returns a Cwise wrapper of *this providing additional coefficient-wise operations
|
||||||
*
|
|
||||||
* \returns a Cwise expression of *this providing additional coefficient-wise operations
|
|
||||||
*
|
*
|
||||||
* \sa class Cwise
|
* \sa class Cwise
|
||||||
*/
|
*/
|
||||||
@ -157,9 +155,7 @@ MatrixBase<Derived>::cwise() const
|
|||||||
return derived();
|
return derived();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \array_module
|
/** \returns a Cwise wrapper of *this providing additional coefficient-wise operations
|
||||||
*
|
|
||||||
* \returns a Cwise expression of *this providing additional coefficient-wise operations
|
|
||||||
*
|
*
|
||||||
* \sa class Cwise
|
* \sa class Cwise
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user