specialize for Size==0 in order to catch user bugs and not clutter

the compiler output with an infinite recursion. Also add a #define switch
for loop unrolling.
This commit is contained in:
Benoit Jacob
2007-12-11 10:04:39 +00:00
parent 9d51572cbe
commit fc924bc7d4
4 changed files with 62 additions and 13 deletions

View File

@@ -40,6 +40,17 @@ template<int UnrollCount, int Rows> struct CopyHelperUnroller
}
};
// prevent buggy user code from causing an infinite recursion
template<int UnrollCount> struct CopyHelperUnroller<UnrollCount, 0>
{
template <typename Derived1, typename Derived2>
static void run(Derived1 &dst, const Derived2 &src)
{
EIGEN_UNUSED(dst);
EIGEN_UNUSED(src);
}
};
template<int Rows> struct CopyHelperUnroller<1, Rows>
{
template <typename Derived1, typename Derived2>
@@ -63,7 +74,7 @@ template<typename Scalar, typename Derived>
template<typename OtherDerived>
void MatrixBase<Scalar, Derived>::_copy_helper(const MatrixBase<Scalar, OtherDerived>& other)
{
if(SizeAtCompileTime != Dynamic && SizeAtCompileTime <= 25)
if(EIGEN_UNROLLED_LOOPS && SizeAtCompileTime != Dynamic && SizeAtCompileTime <= 25)
CopyHelperUnroller<SizeAtCompileTime, RowsAtCompileTime>::run(*this, other);
else
for(int i = 0; i < rows(); i++)