allanmulin
Registered Member

Hello, it seems that all QR decomposition in Eigen only provides the absolute value of the determinant of the decomposed matrix (the log of this value can also be queried). I understand that this simplifies considerably the calculation, since only the product of the diagonal entries of R is performed, neglecting the determinant of Q which is either +1 or 1.
However, I am facing a problem that requires the sign of the determinant (its absolute value is of no importance). This necessity can be found in continuation methods for nonlinear problems. So, how could I find efficiently (i.e. linear complexity O(n) if possible) the sign of the determinant of A, where AP=QR and P a permutation matrix? 
allanmulin
Registered Member

Okay, I will answer my own question in case someone needs this in the future. This is basically the approach discussed in the link below translated to Eigen.
http://icl.cs.utk.edu/lapackforum/view ... f=2&t=1741 The determinant of Q is given by: det(Q) = (1)^k, where k is the number of Householder reflections used in the QR decomposition. Assume: HouseholderQR<MatrixXd> QR(A); The number k is then the number of nonzero Householder coefficients in the vector QR.hCoeffs(). 
ggael
Moderator

Thanks for sharing your finding. Patch welcome for adding true determinant() functions to the QR classes.

Registered users: Baidu [Spider], Bing [Bot], claydoh, farid, Google [Bot], jacksong, joebuckley, Moldmaker, Section_8, Sogou [Bot], zfazylz