reverse certain inner loops. Now the benchmark runs in 3.5s instead of 5.5s before!

This commit is contained in:
Benoit Jacob 2007-10-08 07:24:00 +00:00
parent f0be175bdc
commit ac6ff5efd6
3 changed files with 3 additions and 3 deletions

View File

@ -32,11 +32,11 @@ struct EiDotUnroller
static void run(const Derived1 &v1, const Derived2& v2, typename Derived1::Scalar &dot)
{
const int i = Index - 1;
EiDotUnroller<Index-1, Size, Derived1, Derived2>::run(v1, v2, dot);
if(i == Size - 1)
dot = v1[i] * EiConj(v2[i]);
else
dot += v1[i] * EiConj(v2[i]);
EiDotUnroller<Index-1, Size, Derived1, Derived2>::run(v1, v2, dot);
}
};

View File

@ -112,11 +112,11 @@ struct EiMatrixProductUnroller
typename Lhs::Scalar &res)
{
const int i = Index - 1;
EiMatrixProductUnroller<Index-1, Size, Lhs, Rhs>::run(row, col, lhs, rhs, res);
if(i == Size - 1)
res = lhs.read(row, i) * rhs.read(i, col);
else
res += lhs.read(row, i) * rhs.read(i, col);
EiMatrixProductUnroller<Index-1, Size, Lhs, Rhs>::run(row, col, lhs, rhs, res);
}
};

View File

@ -31,11 +31,11 @@ template<int Index, int Rows, typename Derived> struct EiTraceUnroller
static void run(const Derived &mat, typename Derived::Scalar &trace)
{
const int i = Index - 1;
EiTraceUnroller<Index-1, Rows, Derived>::run(mat, trace);
if(i == Rows - 1)
trace = mat(i, i);
else
trace += mat(i, i);
EiTraceUnroller<Index-1, Rows, Derived>::run(mat, trace);
}
};