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

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

一些 LAPACK 函数(如 dgqrf)return 答案是上三角函数,但在对角线下方存储了一些辅助信息。我想知道是否有一个函数可以将对角线下方的条目清零。

一般问题

没有,标准中没有这个功能BLAS/LAPACK。

如果您愿意不再直接使用 BLAS/LAPACK 函数(存在所有潜在问题和副作用),您可能会发现线性代数包可以使此类操作更容易。比方说,Eigen would provide TriangularViews,而其他软件包会有他们这样做的方式。

如果必须直接使用BLAS/LAPACK,则需要自己清零。

QR-分解

我假设您不需要 QR 分解中的 Q,只关心 R。因此,您想将其存储在适当的位置并清理并避免复制到另一个分配的存储中。

从技术上讲,您可以使用 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 ()。