質問

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.

役に立ちましたか?

解決

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).

他のヒント

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

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

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.

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

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top