Re: [eigen] Matrix multiplication seems to be exceptionally slow in one specific case |

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]

*To*: eigen@xxxxxxxxxxxxxxxxxxx*Subject*: Re: [eigen] Matrix multiplication seems to be exceptionally slow in one specific case*From*: Christoph Hertzberg <chtz@xxxxxxxxxxxxxxxxxxxxxxxx>*Date*: Mon, 16 Jun 2014 15:44:17 +0200

Hi, besides the already noted misuse of the auto keyword:

Christoph On 16.06.2014 15:14, Thijs.Kooi@xxxxxxxxxxxxx wrote:

Hi, I am trying to implement a whitening transform using Eigen3, but I find that one of the matrix operations is extremely slow and I can't understand why. Below is the code: MatrixXd M = convertToEigen(data); MatrixXd mu = M.rowwise() - M.colwise().mean(); MatrixXd S = (mu.adjoint()*mu)/double(M.rows()); EigenSolver<MatrixXd> es(S, true); auto V(es.eigenvalues()); auto U(es.eigenvectors()); V = V.cwiseSqrt().asDiagonal(); MatrixXd L(S.rows(), S.cols()); for(size_t d = 0; d < L.rows(); d++) L(d, d) = 1./real(L(d, d)); MatrixXd Y(M.rows(), M.cols()); auto T = L*U.real().transpose(); for(size_t n = 0; n < M.rows(); n++) { Y.row(n) = T*(M.row(n) - mu); } Y = Y.transpose(); I clocked some of the operations and find that the T*() inside the for-loop is the bottle neck, which takes about 0.047688 seconds on a 4th generation intel i7 and about the same time as the eigenvalue decomposition, which takes 0.049989 seconds, so that can't be right. M is a 12498 x 225 matrix, so T is 225 x 225 and so is mu. I am running Kubuntu 14.04, Eigen 3.2.0-8, which is in the repositories and all optimisation flags are turned on. Does anybody know what the problem is? Best regards, Thijs 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.

-- ---------------------------------------------- Dipl.-Inf., Dipl.-Math. Christoph Hertzberg Cartesium 0.049 Universität Bremen Enrique-Schmidt-Straße 5 28359 Bremen Tel: +49 (421) 218-64252 ----------------------------------------------

**Follow-Ups**:

**References**:

**Messages sorted by:**[ date | thread ]- Prev by Date:
**RE: [eigen] Matrix multiplication seems to be exceptionally slow in one specific case** - Next by Date:
**RE: [eigen] Matrix multiplication seems to be exceptionally slow in one specific case** - Previous by thread:
**Re: [eigen] Matrix multiplication seems to be exceptionally slow in one specific case** - Next by thread:
**RE: [eigen] Matrix multiplication seems to be exceptionally slow in one specific case**

Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |