mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
reverse certain inner loops. Now the benchmark runs in 3.5s instead of 5.5s before!
This commit is contained in:
@@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user