如何通过ilnumerics获得Moore-Penrose广义逆

时间:2015-01-20 02:05:51

标签: c# ilnumerics

是否可以通过 ilnumerics 获得矩阵A的 Moore-Penrose广义逆?什么 pinv 在ilnumerics中意味着什么? pinv意味着逆矩阵?

1 个答案:

答案 0 :(得分:1)

是的,ILNumerics可以实现!

这是一个注释的例子:

// Matrix A
ILArray<double> A = new double[,] { { 1, 2 }, { 3, 4 } };

// The Moore-Penrose pseudoinverse
ILArray<double> Ainv = pinv(A);

// Check for: A * A^-1 = I
ILArray<double> AtimesAinv = multiply(A, Ainv);

// difference of I = eye(2,2) - the inverse
ILArray<double> diff = eye(2, 2) - AtimesAinv;

// max norm of the difference
double normalized = (double)norm(diff)[0];

// Arbitrary epsilon to make the comparison
double epsilon = 1e-10;
Assert.AreEqual(true, normalized <= epsilon);

请通过以下链接查看文档以获取更多信息:ILNumerics API Doc - pinv