This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Is there a substitute for Matlab's backslash

Tags: None
(comma "," separated)
HWJ
Registered Member
Posts
18
Karma
0
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.
Andre
Registered Member
Posts
90
Karma
1
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
HWJ
Registered Member
Posts
18
Karma
0
Andre wrote: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.


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.
Royi
Registered Member
Posts
34
Karma
0
Is "Automatic" solution available now?
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
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.
Royi
Registered Member
Posts
34
Karma
0
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).


Bookmarks



Who is online

Registered users: Bing [Bot], daret, Google [Bot], sandyvee, Sogou [Bot]