C++ :使用回代算法求解方程组的数学库

发布于 2024-08-26 05:30:15 字数 180 浏览 3 评论 0原文

如果我有这个:

A * f = g;
A: upper triangular matrix (n x n)
f: (n x 1)
g: (n x 1)

需要使用回代算法求解 f 。我想说,自己写一个并不难,但是哦,好吧,如果有一个图书馆,那为什么不呢。

If I have this:

A * f = g;
A: upper triangular matrix (n x n)
f: (n x 1)
g: (n x 1)

Need to solve for f using back substitution algorithm. I would say that it not really that hard to write one myself, but oh well, if there is a library out there, then why not.

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

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

发布评论

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

评论(4

云之铃。 2024-09-02 05:30:15

Boost uBlas 应该可以工作。至少如果我正确理解你的问题,你可能想首先查看lu_substitute()inplace_solve()

Boost uBlas should work. At least if I understand your question correctly, you probably want to start by looking at lu_substitute() and inplace_solve().

執念 2024-09-02 05:30:15

使用LAPACK。它已经安装在许多系统上,并且对于没有它的系统有许多可用的实现。

具体来说,您想要的例程是 dtrtrsstrtrs,具体取决于您的数据是双精度还是单精度。

Use the LAPACK. It's already installed on many systems, and there are many implementations available for systems that don't have it.

Specifically, the routine you want is dtrtrs or strtrs, depending on whether your data is in double- or single-precision.

北音执念 2024-09-02 05:30:15

是其中之一吗?我以前没有听说过用“回代”求解线性方程组。为什么一定要回代呢?

http://eigen.tuxfamily.org/dox/TutorialAdvancedLinearAlgebra.html

Is it one of these? I haven't heard of solving systems of linear equations with "back substitution" before. Why does it have to be back substitution?

http://eigen.tuxfamily.org/dox/TutorialAdvancedLinearAlgebra.html

国际总奸 2024-09-02 05:30:15

为了简单起见缺乏依赖项,我会选择 JAMA+TNT 并使用 LU 用于分解及其 solve()方法。似乎没有一种方法可以使用预先存在的上三角矩阵来初始化 LU(LU 的构造函数不做任何假设,只是开始分解),但我认为您可以按原样使用它,并承受性能影响冗余因式分解,或者只是采用求解方法并根据您的需要进行调整。

For simplicity & lack of dependencies, I'd go for JAMA+TNT and use the LU class for factorization and its solve() method. There doesn't appear to be a way you can initialize LU with a pre-existing upper triangular matrix (LU's constructor makes no assumptions and just starts factoring) but I would think you could either use it as is, and live with the performance hit of the redundant factoring, or just take solve method and adapt it to your needs.

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