简体   繁体   English

是否有用于将矩阵的上角/下角归零的 LAPACK function?

[英]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.一些 LAPACK 函数(如dgqrf )返回 function ,其中答案是上三角形,但在对角线下方存储了一些辅助信息。 I'm wondering if there's a function that will zero out the below the diagonal entries.我想知道是否有一个 function 会将对角线下方的条目归零。

General Problem一般问题

No, there is no such function in standard BLAS/LAPACK.不,标准 BLAS/LAPACK 中没有这样的 function。

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.如果您愿意放弃直接使用 BLAS/LAPACK 函数(存在所有潜在问题和副作用),您可能会发现线性代数包可以使此类操作更容易。 Say, Eigen would provide TriangularViews , while other packages would have their way of doing that.比如说, Eigen会提供TriangularViews ,而其他包会有他们这样做的方式。

If you have to use BLAS/LAPACK directly, you would have to zero out it yourself.如果您必须直接使用 BLAS/LAPACK,则必须自己将其归零。

QR-decomposition QR分解

I assume that you don't need the Q from the QR decomposition and only care about the R.我假设您不需要 QR 分解中的 Q,只关心 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.从技术上讲,您可以使用dormqr并将矩阵 C 设置为零矩阵。 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 ).如果确实需要,您最好进行手动循环进行清理,或者将 R 复制到另一个地方(类似于这里的做法)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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