Azzera filtri
Azzera filtri

How does the backslash operator work when A is full?

59 visualizzazioni (ultimi 30 giorni)
I would like to know how the backslash operator works when A is full, and what the outline of the algorithm is.

Risposta accettata

MathWorks Support Team
MathWorks Support Team il 26 Mar 2023
Modificato: MathWorks Support Team il 27 Mar 2023
The method used by the backslash and forward slash operators to solve the system of linear equations A*x = b depends on the structure of the coefficient matrix A. In MATLAB 6.5 (R13), the types of structures the backslash operator tests the coefficient matrix for are given in the algorithm section of the following web page:
You can also access this webpage by typing "doc arithmeticoperators" (without the quotes) at the MATLAB prompt.
For earlier versions of MATLAB, the same testing for special structure was performed but fewer special structures were tested. Below is some pseudo-code describing how the backslash operator worked for MATLAB 6.0 (R12) and 6.1 (R12.1) in the case where A is full; you can find a full description in the documentation page for "arithmeticoperators".
>> x = A \ b;
% This is pseudo-code for how full \ works:
if size(A,1) == size(A,2) % A is square
if isequal(A,tril(A)) % A is lower triangular
x = A \ b; % This is a simple forward substitution on b
elseif isequal(A,triu(A)) % A is upper triangular
x = A \ b; % This is a simple backward substitution on b
if isequal(A,A') % A is symmetric
[R,p] = chol(A);
if (p == 0) % A is symmetric positive definite
x = R \ (R' \ b); % a forward and a backward substitution
[L,U,P] = lu(A); % general, square A
x = U \ (L \ (P*b)); % a forward and a backward substitution
else % A is rectangular
[Q,R] = qr(A);
x = R \ (Q' * b);
You can look at Golub and van Loan's Matrix Computations for more information on the various decompositions and pointers to the literature. Also see the LAPACK User's Guide for details of the LAPACK functions listed at the bottom of the documentation page on arithmeticoperators, such as DLANGE, DPOTRF, DPOTRS, DPOCON, DGESV, etc. You can find the LAPACK User's Guide at:

Più risposte (0)


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by