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

Using Pre-Computed Decompositions

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

Using Pre-Computed Decompositions

Sat Jun 18, 2011 10:46 pm
Please help me figure out how to use the pre-computed LU decomposition. I am solving this in a loop where some of the A matrices are the same. If they are the same, An = An-1, I want to skip the decomposition. I have tried various things but cannot get it to work. How can I save the pre-computation so that it is still in scope when I need it (the next loop)? Below is my loop that works. When I try to put an if condition around luofa.compute(A); it fails.

Code: Select all
void eigenCalculations(inputOutput data[])
{
FullPivLU<MatrixXd> luofa;  //  declaration for the pre-computation matrix
        for(int i = 0; i < data[0].lines; i++)  //  Next three nested loops fill up our IC matrix
        {
        MatrixXd A(data[i].N,data[i].N);
        VectorXd X(data[i].N);
                for (int j = 0; j < data[i].N; j++)
                {
                X(j)=data[i].rhs[j];
                        for(int k=0; k< data[i].N; k++)
                        {
                        A(j,k)= data[i].IC[j][k];
                        }
                }
        luofa.compute(A);           
        VectorXd sol = luofa.solve(X);
}
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
that should work, perhaps that's your condition which is wrong... IF you cannot figure it out, please post the version with the condition.
rhzehr
Registered Member
Posts
2
Karma
0
OS
You are right! I fixed the condition statement and it works :)


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], q.ignora, watchstar