简体   繁体   English

什么是MATLAB的MathNet等价物解决C = A \\ B

[英]What is the MathNet equivalent of MATLAB solve C = A \ B

I've recently begun using MathNet to implement our linear algebra, however I'm having some trouble translation MATLAB functions to MathNet. 我最近开始使用MathNet来实现我们的线性代数,但是我在将MATLAB函数转换为MathNet时遇到了一些麻烦。

In MATLAB I often use the simple solve using the backslash operator: 在MATLAB中,我经常使用反斜杠运算符来简单求解:

C = A \\ B C = A \\ B

What is the equivalent of this in MathNet? 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. 我使用C = Inv(A)* B在小矩阵中得到相同的结果,但我不知道结果是否精确。

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

For square matrices also: var C = A.LU().Solve(B); 对于平方矩阵,: var C = A.LU().Solve(B); (using LU decomposition) (使用LU分解)

I don't think MathNet has any "equivalent" of Matlab's backslash operator. 我不认为MathNet有任何“等效”的Matlab反斜杠运算符。 See this site for some info on how Matlab's backslash works: Matlab manual on mldivide() . 有关Matlab反斜杠如何工作的一些信息,请访问此站点: mldivide()上的Matlab手册 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... 我想你可以看看一些解决方法,比如QRSolve,但我认为它们不会那么容易使用......

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)? 您是在询问MathNet的inv()是否对矩阵进行了精确反演,或者您只是在询问是否可以将C计算为Inv(A)*(B)?

If you are asking the later, yes, for square matrices Matlab's backslash is roughly the same as Inv(A)*(B). 如果你问的是后者,是的,对于方形矩阵,Matlab的反斜杠与Inv(A)*(B)大致相同。

With the tests I've made using Matlab and Math.Net Numerics: 通过我使用Matlab和Math.Net Numerics进行的测试:

Matrix A Vector B 矩阵A矢量B.

Matlab: A \\ B Math.Net Numerics: A.QR().Solve(B) Matlab:A \\ B Math.Net数字:A.QR()。解决(B)

Both give the same results (in my case). 两者都给出了相同的结果(在我的例子中)。 I think it will work with B being a Matrix also. 我认为这也适用于B也是一个矩阵。

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

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

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