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

Solving Ax=By+c

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

Solving Ax=By+c

Mon Apr 22, 2013 12:17 pm
Hi,
I want to solve A.X=B where A is a square dense matrix et B a vector. To reduce the size of my problem, I wrote X=P+S , P is the vector of primary unknowns and S is the vector of secondary unknown. Knowning matrix Q,R,T, I want to solve Q.S =R.P + T. with eigen.
What is the best solution (regarding memory and cpu) to get Q-1*R and Q-1*T using eigen ? Can you post code to solve this problem (I am new user of eigen)

Thank in advance
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: Solving Ax=By+c

Mon Apr 22, 2013 12:34 pm
Can you comment on Q? (size, symmetry, etc.)

A general approach would be:

Code: Select all
MatrixXd Q, invQtimesR;
VectorXd T, invQtimesT;
HouseholderQR<MatrixXd> solver(Q); // factorize the matrix
invQtimesR = solver.solve(R); // Q-1*R
invQtimesT = solver.solve(T); // Q-1*T


Check these pages for alternatives and details:
http://eigen.tuxfamily.org/dox-devel/gr ... tions.html
http://eigen.tuxfamily.org/dox-devel/gr ... gebra.html
varaville
Registered Member
Posts
2
Karma
0

Re: Solving Ax=By+c

Mon Apr 22, 2013 12:51 pm
ggael wrote:Can you comment on Q? (size, symmetry, etc.)

A general approach would be:

Code: Select all
MatrixXd Q, invQtimesR;
VectorXd T, invQtimesT;
HouseholderQR<MatrixXd> solver(Q); // factorize the matrix
invQtimesR = solver.solve(R); // Q-1*R
invQtimesT = solver.solve(T); // Q-1*T


Check these pages for alternatives and details:
http://eigen.tuxfamily.org/dox-devel/gr ... tions.html
http://eigen.tuxfamily.org/dox-devel/gr ... gebra.html



Thanks,
I will test it.
Q is a dense non symetric matrix.
Typical sizes for my problem are X vector of 15 elements with 7 primary and 8 secondary unkwown.
With thoses sizes, Q is a (8x8) square dense non symetric matrix, R is a (8,7) matrix and T is a 8 element vector
The key Issue is that this process is a local resolution I repeat 100,000 times per Newton step.
is HouseholderQR the best solver for that ?
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: Solving Ax=By+c

Mon Apr 22, 2013 4:16 pm
Since Q is squared, PartialPivLu will be faster. Also, since your matrix sizes are small an known at compile time, I recommend you to use fixed size matrices, e.g., with float:

typedef Matrix<float, 8, 8> Matrix88f;
typedef Matrix<float, 8, 7> Matrix87f;
typedef Matrix<float, 8, 1> Vector8f;

This way you make sure to avoid costly dynamic memory allocations.


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot]