稀疏矩阵超定线性方程组 c/c++图书馆

发布于 2024-12-12 18:28:51 字数 137 浏览 0 评论 0原文

我需要一个库来解决 Ax=b 系统,其中 A 是一个非对称稀疏矩阵,每行有 8 个条目(而且可能很大)。我认为实现双共轭梯度的库应该没问题,但我找不到一个有效的库(我尝试过 iml++,但 iml++/sparselib++ 包中缺少一些标头)。有什么建议吗?

I need a library to solve Ax=b systems, where A is a non-symmetric sparse matrix, with 8 entry per row (and it might be quite big). I think a library that implements biconjugate gradient should be fine, but i can't find one that works (i've tried iml++, but there are some headers missing in the iml++/sparselib++ packages). Any tips?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

孤檠 2024-12-19 18:28:51

有处理超定系统的标准方法。例如维基百科这样说:

一组线性联立方程可以写成矩阵形式 Ax = y。如果方程多于变量,则系统被称为超定系统,并且(通常)没有解。然后系统可以更改为 (ATA)x = ATy。新系统有与变量一样多的方程(矩阵 ATA 是方阵),并且可以用通常的方法求解。该解决方案是原始超定系统的最小二乘解,最小化欧几里得范数 ||Ax − y||(原始系统中两侧差异的度量)。

因此,您可以使用任何标准方阵稀疏求解器。

就我个人而言,我使用 Tim Davis 的 CSparse 的直接求解器。 Tim 编写了许多优秀的直接稀疏求解器。事实上,他的 UMFPACK 是另一个很好的选择,例如 MATLAB 使用。请注意,这两个求解器都提供 C 接口。如果您正在寻找具有本机 C++ 接口的东西,那么我没有什么可以提供的。

我对迭代求解器有一些经验。然而,我发现对于我正在研究的问题,迭代方法对于大型矩阵变得不稳定。我在直接求解器方面取得了更大的成功。当然,根据问题提出的矩阵类型,您完全有可能获得相反的体验。

There are standard ways of treating overdetermined systems. For example Wikipedia says this:

A set of linear simultaneous equations can be written in matrix form as Ax = y. If there are more equations than variables, the system is called overdetermined, and has (in general) no solutions. The system can then be changed to (ATA)x = ATy. The new system has as many equations as variables (the matrix ATA is a square matrix) and can be solved in the usual way. The solution is a least-squares solution of the original, overdetermined system, minimizing the Euclidean norm ||Ax − y||, a measure of the discrepancy between the two sides in the original system.

Therefore you can use any standard square matrix sparse solver.

Personally I use a direct solver from CSparse by Tim Davis. Tim has written a number of excellent direct sparse solvers. Indeed, his UMFPACK is another excellent option and is used by MATLAB, for example. Note that both of these solvers offer C interfaces. If you are looking for something with a native C++ interface then I have nothing to offer.

I have had some experience with iterative solvers. However, I have found that for the problems I was looking at, the iterative methods became unstable for large matrices. I have had much more success with direct solvers. Of course, it's perfectly plausible that you could have the reverse experience depending on the type of matrix your problem throws up.

御弟哥哥 2024-12-19 18:28:51

看起来 ARPACK 解决了稀疏非对称矩阵问题。有一个C++版本

It looks like ARPACK solves sparse nonsymetric matrix problems. There is a C++ version

生生漫 2024-12-19 18:28:51

对于 David Heffernan 的回答:不要忘记一件重要的事情:必须检查/证明矩阵 A 具有线性独立的列,否则可能会发生 (A^TA) 是奇异的(然后它当然不起作用)。

To David Heffernan's answer: Do not forget one important thing: matrix A must be checked/proved to have linearly independent columns, otherwise it could happen that (A^T A) is singular (and then it would not work, of course).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文