|RE: [eigen] Matrix multiplication seems to be exceptionally slow in one specific case|
[ Thread Index |
| More lists.tuxfamily.org/eigen Archives
- To: <christian@xxxxxxxx>, <eigen@xxxxxxxxxxxxxxxxxxx>
- Subject: RE: [eigen] Matrix multiplication seems to be exceptionally slow in one specific case
- From: <Thijs.Kooi@xxxxxxxxxxxxx>
- Date: Mon, 16 Jun 2014 13:38:59 +0000
- Accept-language: en-GB, nl-NL, en-US
- Authentication-results: spf=pass (sender IP is 220.127.116.11) smtp.mailfrom=Thijs.Kooi@xxxxxxxxxxxxx;
- Thread-index: Ac+JZF5xyLo36AFbSvWK23ge7DaTGv//5WMAgAAiSOk=
- Thread-topic: [eigen] Matrix multiplication seems to be exceptionally slow in one specific case
That seems to fix it, thanks a lot. I wasn't aware of this behaviour of 'auto', sorry.
From: Christian Seiler [christian@xxxxxxxx]
Sent: 16 June 2014 15:35
Cc: Kooi, Thijs
Subject: Re: [eigen] Matrix multiplication seems to be exceptionally slow in one specific case
> 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();
Het Radboudumc staat geregistreerd bij de Kamer van Koophandel in het handelsregister onder nummer 41055629.
The Radboud university medical center is listed in the Commercial Register of the Chamber of Commerce under file number 41055629.