I use dgetrf and dgetri (called from C++) to invert the following matrix:
- Code: Select all
A = [
1 -1 -1 1 1 1
1 1 -1 1 -1 1
1 0 2 0 0 3
1 0 -1 -0.5 -0 1
1 0.5 0.5 0.25 0.75 -0.5
1 -0.5 0.5 0.25 -0.75 -0.5]
The inverse that I obtained is:
- Code: Select all
inv(A) = [
-2.77556e-17 5.55112e-17 -2.77556e-17 0.333333 0.333333 0.333333
-0.3 0.3 0 0 0.4 -0.4
-0.1 -0.1 0.2 -0.266667 0.133333 0.133333
0.333333 0.333333 0 -0.666667 0 0
0.2 -0.2 0 0 0.4 -0.4
0.0666667 0.0666667 0.2 0.0666667 -0.2 -0.2 ]
What disturbs me are the near-zero values (effect of finite precision artihmetic, I know). The problem is that I don't see the same when running Matlab:
- Code: Select all
inv(A)
ans =
0 -0.0000 0 0.3333 0.3333 0.3333
-0.3000 0.3000 0 0 0.4000 -0.4000
-0.1000 -0.1000 0.2000 -0.2667 0.1333 0.1333
0.3333 0.3333 0 -0.6667 0 0
0.2000 -0.2000 0 0 0.4000 -0.4000
0.0667 0.0667 0.2000 0.0667 -0.2000 -0.2000
Is there anything I can do to increase the accuracy of the matrix inverse? I am using the reference Lapack implementation installed through my Linux distribution.
Thank you very much.
Best regards,
Martin Vymazal

