How to extract an upper triangular matrix (i.e. how to obtain R matrix form QR factorization)


Following the use of the cula ?orgqr function I want to obtain the R matrix. This can be done by copying the upper triangular values from the resulting matrix to another matrix and leaving the lower triangular values other than the diagonal as 0. I have not been able to find a way to do this using cuBLAS or cula.

this can be illustrated as follows:

a1 a2 a3     a1 a2 a3
a4 a5 a6 -> 0   a5 a6
a7 a8 a9     0   0   a9

Is there a way to do it with those libraries that I am not aware of? If not what would be an efficient way to perform this procedure?

Kind regards

Hey @sakilo

Did you manage to find out how to do that? I’m stuck at a similar point.

This should be possible with the cusolver function Dn?geqrf:

AFAICT ?orgqr would not normally be called until after ?geqrf is called anyway.