MATLAB 求解 C = A \ B 的 MathNet 等效项是什么

发布于 2025-01-04 06:34:36 字数 206 浏览 4 评论 0原文

我最近开始使用 MathNet 来实现线性代数,但是在将 MATLAB 函数转换为 MathNet 时遇到一些问题。

在 MATLAB 中,我经常使用反斜杠运算符进行简单求解:

C = A \ B

在 MathNet 中与此等效的是什么?

我使用 C = Inv(A) * B 在一个小矩阵中得到相同的结果,但我不知道结果是否精确。

I've recently begun using MathNet to implement our linear algebra, however I'm having some trouble translation MATLAB functions to MathNet.

In MATLAB I often use the simple solve using the backslash operator:

C = A \ B

What is the equivalent of this in MathNet?

I get the same results in a small matrix using C = Inv(A) * B, but I don't know if the result is as precise.

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

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

发布评论

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

评论(4

百思不得你姐 2025-01-11 06:34:36

var C = A.QR().Solve(B);(使用 QR 分解)

对于方阵也:var C = A.LU().Solve(B);代码>(使用LU分解)

var C = A.QR().Solve(B); (using QR decomposition)

For square matrices also: var C = A.LU().Solve(B); (using LU decomposition)

‖放下 2025-01-11 06:34:36

我不认为 MathNet 有任何与 Matlab 反斜杠运算符“等价”的东西。有关 Matlab 反斜杠如何工作的一些信息,请参阅此网站:有关 mldivide() 的 Matlab 手册< /a>.我想你可以看看一些求解方法,比如 QRSolve,但我认为它们不会那么容易使用......

“精确”是什么意思?您是在问 MathNet 的 inv() 是否可以精确反转矩阵,或者您只是在问是否可以将 C 计算为 Inv(A)*(B)?

如果你问的是后者,是的,对于方阵Matlab的反斜杠与Inv(A)*(B)大致相同。

I don't think MathNet has any "equivalent" of Matlab's backslash operator. See this site for some info on how Matlab's backslash works: Matlab manual on mldivide(). I guess you could look at some of the solve methods, like QRSolve, but I don't think they will be as easy to use...

What do you mean by "precise"? Are you asking if MathNet's inv() does exact inversion of a matrix, or are you simply asking if you could calculate C as Inv(A)*(B)?

If you are asking the later, yes, for square matrices Matlab's backslash is roughly the same as Inv(A)*(B).

仅此而已 2025-01-11 06:34:36

通过我使用 Matlab 和 Math.Net 数值进行的测试:

矩阵 A
向量 B

Matlab: A \ B
Math.Net 数值:A.QR().Solve(B)

两者给出相同的结果(在我的例子中)。我认为 B 作为矩阵也适用。

With the tests I've made using Matlab and Math.Net Numerics:

Matrix A
Vector B

Matlab: A \ B
Math.Net Numerics: A.QR().Solve(B)

Both give the same results (in my case). I think it will work with B being a Matrix also.

凤舞天涯 2025-01-11 06:34:36

如果您使用 ILNumerics.Net 库
您可以尝试ILMath.linsolve(A, B);

If you use ILNumerics.Net Library,
You can try ILMath.linsolve(A, B);

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