简体   繁体   中英

Is there a LAPACK function for zeroing out the upper / lower corner of a matrix?

Some LAPACK functions (like dgqrf ) return a function where the answer is upper triangular but then there's some auxilary information stored below the diagonal. I'm wondering if there's a function that will zero out the below the diagonal entries.

General Problem

No, there is no such function in standard BLAS/LAPACK.

If you are willing to move from using BLAS/LAPACK functions directly (with all potential issues and side effects), you may find linear algebra packages that would make such operations easier. Say, Eigen would provide TriangularViews , while other packages would have their way of doing that.

If you have to use BLAS/LAPACK directly, you would have to zero out it yourself.

QR-decomposition

I assume that you don't need the Q from the QR decomposition and only care about the R. With that, you want to store it in place and clean and avoid doing a copy into another allocated storage.

Technically, you can do it using dormqr and setting matrix C to be a zero-matrix. However, it is not efficient, as you are actually performing not needed linear algebra operations and storing another dense matrix. You are certainly better off doing a manual loop to clean up if that is actually required or copy R into another place ( similar to how it's done here ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM