add dot product, extend meta unrolling everywhere

This commit is contained in:
Benoit Jacob
2007-10-08 07:17:54 +00:00
parent 95b3316701
commit f0be175bdc
6 changed files with 190 additions and 48 deletions

View File

@@ -27,37 +27,44 @@
#ifndef EI_COPYHELPER_H
#define EI_COPYHELPER_H
template<int UnrollCount, int Rows> class EiCopyHelperUnroller
template<int UnrollCount, int Rows> struct EiCopyHelperUnroller
{
static const int col = (UnrollCount-1) / Rows;
static const int row = (UnrollCount-1) % Rows;
static const int col = (UnrollCount-1) / Rows;
static const int row = (UnrollCount-1) % Rows;
public:
template <typename Derived1, typename Derived2>
static void run(Derived1 &dst, const Derived2 &src)
{
EiCopyHelperUnroller<UnrollCount-1, Rows>::run(dst, src);
dst.write(row, col) = src.read(row, col);
}
template <typename Derived1, typename Derived2>
static void run(Derived1 &dst, const Derived2 &src)
{
EiCopyHelperUnroller<UnrollCount-1, Rows>::run(dst, src);
dst.write(row, col) = src.read(row, col);
}
};
template<int Rows> class EiCopyHelperUnroller<0, Rows>
template<int Rows> struct EiCopyHelperUnroller<0, Rows>
{
public:
template <typename Derived1, typename Derived2>
static void run(Derived1 &dst, const Derived2 &src)
{
EI_UNUSED(dst);
EI_UNUSED(src);
}
template <typename Derived1, typename Derived2>
static void run(Derived1 &dst, const Derived2 &src)
{
dst.write(0, 0) = src.read(0, 0);
}
};
template<int Rows> struct EiCopyHelperUnroller<EiDynamic, Rows>
{
template <typename Derived1, typename Derived2>
static void run(Derived1 &dst, const Derived2 &src)
{
EI_UNUSED(dst);
EI_UNUSED(src);
}
};
template<typename Scalar, typename Derived>
template<typename OtherDerived>
void EiObject<Scalar, Derived>::_copy_helper(const EiObject<Scalar, OtherDerived>& other)
{
if(UnrollCount > 0 && UnrollCount <= EI_LOOP_UNROLLING_LIMIT)
EiCopyHelperUnroller<UnrollCount, RowsAtCompileTime>::run(*this, other);
if(SizeAtCompileTime != EiDynamic && SizeAtCompileTime <= EI_LOOP_UNROLLING_LIMIT)
EiCopyHelperUnroller<SizeAtCompileTime, RowsAtCompileTime>::run(*this, other);
else
for(int i = 0; i < rows(); i++)
for(int j = 0; j < cols(); j++)