|Re: [eigen] Matrix multiplication seems to be exceptionally slow in one specific case|
[ Thread Index |
| More lists.tuxfamily.org/eigen Archives
auto T = L*U.real().transpose();
This will store Eigen's temporary expression object in T, not the
result of the calculation. This means that here:
Y.row(n) = T*(M.row(n) - mu);
T has to be evaluated again and again.
If you evaluate it explicitly instead of using auto, like:
Eigen::MatrixXd T = L*U.real().transpose();
the code should run quite a bit faster.
There has been a proposal for 'operator auto' in C++ because of this,
but there doesn't seem to be enough traction for it. OTOH, Gael said
earlier  that once bug #99 is finally fully done, you will be able
to do something like
auto foo = (L*U.real().transpose()).eval();