if I use the member function of Eigen Matrix3Xf
matrices myMatrix.middleCols(a, b)
with a = 0, b = myMatrix.cols()-1
, I get a performance penalty.
Of course I usually use other values for a and b, but with these values, it's easiest to compare to the normal matrices.
Is this normal behaviour? Is this the case, because alignment cannot be ensured and thus no vectorization is possible? I did not find anything about it in the docs.
Here's an example code:
Matrix3Xf a_full = Matrix3Xf::Random(3, 400);
Vector3f v = Vector3f::Random();
RowVectorXf b_full = RowVectorXf::Random(400);
volatile int left = 0, right = 399;
auto& a = a_full.middleCols(left, right);
auto& b = b_full.middleCols(left, right);
//auto& a = a_full;
//auto& b = b_full;
for (float f = 0; f < 1000000; f++)
{
b += (v.transpose() * a);
}
cout << b.sum();
With this code I get 8.6s execution time. Having a = a_full; and b = b_ful; uncommented, the execution time is 7.8s