Re: [eigen] GivensQR

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


>
> > Pros:
> >
> > The computation of Q is performed only if strictly needed; by default (by
> > the constructor) no computation is performed. Q is computed only if the
> > user requests it.
>
> that's something we'll have to uniformize across various
> decompositions later on.
> Actually I believe that the default should be "convenient but not
> fast" i.e. compute Q, with an option to not compute Q. But we had yet
> to discuss that on the list.


I implemented the class paing attention to the perfomance, but in facts the result is quite 
"comfortable". The idea behind the method compute() is not to ask the user which matrices are to be 
computed, but only a tool to update the decomposition if the matrix has changed (since the original 
matrix is stored as alias). The decision behind the behaviour of solve() is simply: there is no need 
for the unitary matrix in order to solve the sistem.
The only "problematic" issue is: if one needs both Q and R, he should request Q and then R and not 
viceversa. In the first case, Q and R are computed and Q is returned and then R is simply returned; 
in the second one R is computed and returned and then Q and R are both (re-)computed and Q is 
returned. In other words:

Matrix<...> m;
/* ... */

GivensQR<Matrix<...> > qr1(m);
qr1.matrixQ(); // Q and R are computed; Q is returned
qr1.matrixR(); // R is returned (was computed before)


GivensQR<Matrix<...> > qr2(m);
qr2.matrixR(); // R is computed and returned; Q is not yet computed.
qr2.matrixQ(); // Q and R are computed; Q is returned.


The first case is faster than the second one, in spite of the same result. An alternative is:

GivensQR<Matrix<...> > qr3(m);
qr3.compute(); // Both matrices are computed and stored
qr3.matrixR(); // R is returned; no computation
qr3.matrixQ(); //Q is returned; no computation

If the user doesn't care about performance, this issue is not a problem; if he does, the only think 
he must care is to call matrixQ() or compute() before matrixR() if he needs both Q and R.



If you need help in order to wirk on my code, I can provide a fully-commented version.

Just a note: I thought to store the R matrix in a row-major storage and Q in column-major and then I 
constructed the algorithm by updating R row-wise and Q column-wise. But I'm not sure about the 
performance and the stability, so I finally stored both in the default behaviour. What is your advice 
about that?



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