Why is inv() better for symmetric matrices compared to '\'?
Ältere Kommentare anzeigen
I'm interested in calculating alot of covariance matrices, which all require an inversion of a symmetric matrix, and therefore the output should be symmetric. I've always been taught that using the backslash operator is better than using inv() or ^(-1), i.e.
Ainv = A\eye(size(A,1))
BUT! If I run the following code,
P = 1000;
pp = randn(P);
A = pp*pp';
issymmetric(A)
issymmetric(inv(A))
issymmetric(A\eye(P))
this yields that inv() returns a symmetric matrix but '\' doesnt. Why is this the case?
1 Kommentar
Jos (10584)
am 17 Feb. 2016
The asymmetry probably relates to round-off errors occurring during the calculations used by the algorithm.
What do you mean by "better". Better for what? To calculate the inverse, use inv But for most other purposes, use the backslash operator
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Linear Algebra finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!