QR that returns permutation matrix?

47 views
Skip to first unread message

j.e....@gmail.com

unread,
Aug 25, 2023, 7:02:02 AM8/25/23
to gonum-dev
Hey all,

Is there QR decomposition in gonum that returns the Permutation matrix/vector too?
This is useful for variable selection/responding to multicollinearity.

I'm referring to P in this matlab documentation:


[Q,R,P] = qr(A) additionally returns a permutation matrix P such that A*P = Q*R. If A is full, the permutation matrix is chosen so that abs(diag(R)) is decreasing.

example

[Q,R,P] = qr(A,outputForm) specifies whether to return the permutation information P as a matrix or a vector. For example, if outputForm is "vector", then A(:,P) = Q*R. The default value of outputForm is "matrix" such that A*P = Q*R.


So that one can do things like


I didn't see one, searching gonum in github.... or maybe gonum has a different factorization already, to do the same thing?  Or it could be easily added.  GSL 
seems to have it; i.e.  



Thanks.

Vladimír Chalupecký

unread,
Sep 19, 2023, 2:12:09 PM9/19/23
to gonum-dev
Hi,

We do have QR factorization with column pivoting in Gonum as long as you don't mind accessing it through a Lapack-like interface for now, see lapack/gonum/dgeqp3.go (the implementation is in pure Go).

I'd be happy to add a wrapping type like PivotedQR to the mat package for convenient usage. The need for a permutation matrix type is a hurdle but maybe it's just that I haven't thought deep enough about it (which I haven't). There's already another factorization that needs it (PivotedCholesky, https://github.com/gonum/gonum/pull/1780), so that's two reasons to try to make progress. I'll see what I can do.

Vladimir
Reply all
Reply to author
Forward
0 new messages