[ncl-talk] Errors with inverting a matrix
Prashanth Bhalachandran
prashanth.bhalachandran at gmail.com
Fri Oct 25 19:30:43 MDT 2019
Dear NCL'ers,
I am having a problem with inverting the matrix using NCL that does not
make any sense.
I double-checked both the routines: inverse_matrix() as well as
solve_linsys() and both are functioning well for sample matrices that I am
trying out. I even compared their answers to Matlab and they were perfectly
right. However, when I use any of the two routines for the below matrix A:
write_matrix(A,"9f11.7", False)
A =
0.4000000 -0.0000000 -0.1000000 -0.0000000 -0.1000000 0.3077683
-0.0000000 0.0726542 -0.0000000
-0.0000000 0.1500000 -0.0000000 -0.1000000 -0.0000000 -0.0000000 0.1902113
-0.0000000 0.0363271
-0.1000000 -0.0000000 0.1500000 0.0000000 -0.1000000 -0.1175570
-0.0000000 0.1538842 -0.0000000
-0.0000000 -0.1000000 0.0000000 0.1500000 -0.0000000 -0.0000000
-0.1538842 -0.0000000 0.1175570
-0.1000000 -0.0000000 -0.1000000 -0.0000000 0.1500000 -0.0363271
-0.0000000 -0.1902113 -0.0000000
0.3077683 -0.0000000 -0.1175570 -0.0000000 -0.0363271 0.2500000 0.0000000
-0.0000000 -0.0000000
-0.0000000 0.1902113 -0.0000000 -0.1538842 -0.0000000 0.0000000
0.2500000 0.0000000 0.0000000
0.0726542 -0.0000000 0.1538842 -0.0000000 -0.1902113 -0.0000000
0.0000000 0.2500000 -0.0000000
-0.0000000 0.0363271 -0.0000000 0.1175570 -0.0000000 -0.0000000 0.0000000
-0.0000000 0.2500000
The inverse that NCL computes is totally wrong. That is: One, it does not
satisfy the identity, A Ainv = Identity Matrix. Two, for the same values,
it is very different from what Matlab produces and the one that Matlab
produces satisfies the identity matrix test. Can someone please help me
understand as to what is wrong with the above matrix and how to circumvent
this problem?
I read in previous NCL help that I could use solve_linsys(A, Identity
matrix) and that should give me the inverse. However, that does not work
for this particular A as well. It does work for other sample As that I
tried.
Please offer any advice if you have run into something like this before.
Warm Regards,
Prashanth
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20191025/3ddc9eee/attachment.html>
More information about the ncl-talk
mailing list