Registered Member
|
Hi
how expression the Matlab's backslash operater Ab, i.e. solve (e.g. by Gaussian elimination) the system A*x = b if it's solvable and if the condition number of A doesn't exceed a given tolerance. Otherwise compute the minimum norm least solution to it. I have seen linearRegression in the docs, but AFAIK, I have to set up a vector pointers to the columns of A which is ugly. Is there a shorter more direct method? Thanks for being patient with me, Helmut. |
Registered Member
|
I'm pretty sure there is no such operator.
I think you have to know your matrix, include right header and call A.lu().solve(b, &x) A.llt().solve(b,&x); A.ldlt().solve(b,&x); or just solve() with SVD.
'And all those exclamation marks, you notice? Five? A sure sign of someone who wears his underpants on his head.' ~Terry Pratchett
'It's funny. All you have to do is say something nobody understands and they'll do practically anything you want them to.' ~J.D. Salinger |
Registered Member
|
Thanks, currently I have no much time. In about 3 weeks I'll write a rank-revealing ULR decomposition which gives a "robust" solve, i.e. it will automatically switch to the least squares solution if the (estimate) of the smallest singular value is below some user specified threshold. |
Registered Member
|
Is "Automatic" solution available now?
|
Moderator
|
Nope mostly because 1) there is no consensus on what should be the default strategy, so people usually cook their own tailored for there own needs and 2) it does not allow for reuse of the intermediate factorizations. With Eigen it's only a matter of about 10 lines of code to cook your own, e.g., call PartialPivLU, check condition number, and fallback to CompleteOrthogonalDecomposition if needed.
|
Registered Member
|
I see your point.
I think it would be good to have "Automatic" solver and the logic on that can be copied from MATLAB's Algorithm for Solving Linear System (See the Algorithm section). |
Registered users: Bing [Bot], daret, Google [Bot], sandyvee, Sogou [Bot]