This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Multiplication of triangular matrix

Tags: None
(comma "," separated)
jonaswallin
Registered Member
Posts
2
Karma
0

Multiplication of triangular matrix

Tue Apr 08, 2014 3:34 pm
Hello,

I am trying to solve several quadratic problem of the form x'Ax where the xs are varying but A ( which is symmetric, dense) is the same.
Since I there will be far greater xs then the dimension of A I want to precalculate as much as possible. So, I first to:
Code: Select all
 
LLT<MatrixXd> lltOfA(A);
MatrixXd U  = lltOfA.matrixU();
U = U.triangularView<Upper>();  // don't know if it should be there

Then for each x:
Code: Select all
 
Ux  =  U * x;
xAx = Ux.squaredNorm();

However when I compare to just: (in a loop when A is 4x4)
Code: Select all
 
Ax    = A*x;
xAx  = Ax.dot(x);

I notice no increase in speed for the first case, even though U is triangular, A is full.

Am I doing something wrong?
or is eigen doing something smart with A*x?


thanks
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
For 4x4 matrices exploiting symmetry is slower because it prevents vectorization. Moreover, make sure you are using a Matrix<?,4,4> type for A and Matrix<?,4,1> for vectors.


Bookmarks



Who is online

Registered users: Baidu [Spider], Bing [Bot], Google [Bot]