Recently a wave of scientific research like a mad dog.
The last time or the partial differential equation of the undergraduate exam, a semester did not do homework and then go to the hospital to slow test failure, evening with the students walk through the red carpet after the preview, the next day eight points exam. And then it was C-.
So, never underestimate the determination of a lazy man.
--------------------------------------------------------------------------------------------------------------- ---------------------------------
Why write this today, because I suspect that matlab inside the PINV used to beg {1}-inverse, there will be a lot of precision error, so I intend to find a request {1}-inverse function.
Matlab There is no ready-made, and then online can not find, in order to lazy not to write my own can only use Rref.
The core idea is to use the rref inside the Gaussian elimination to do two times, because no rref how to record the transformation matrix, so the method of additional matrix can be recorded under the transformation matrix (must thank my two high-generation teachers haha).
I'm pretty hard to get lazy.
Put a code below, reach the party, wrong not to find me. (I want to reach out too!!!) )
function [y] = GINV (a) [m,n] = size (a); M1 = Cat (2,a,eye (m)); M2 = Rref (M1); PA = M2 (:, 1:n); P = M2 (:, n+1:n+m); M3 = Cat (2,PA ', Eye (n)); M4 = Rref (M3); J = M4 (:, 1:m); Q = M4 (:, m+1:m+n); y = Q ' *j ' *p;end
Stole the lazy mood good, write a blog to commemorate the haha.
(PostScript: Accuracy has improved.) However, and eggs, I found that the PINV error in the matrix is relatively small when the results do not make very outrageous, that is, or wrong, checked the discovery is not the wrong son code, hey. )
Matlab Beg {1}-inverse