www.delorie.com/gnu/docs/octave/octave_145.html   search  
 
Buy GNU books!


GNU Octave

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

17.2 Matrix Factorizations

Loadable Function: chol (a)
Compute the Cholesky factor, r, of the symmetric positive definite matrix a, where

 
r' * r = a.

Loadable Function: h = hess (a)
Loadable Function: [p, h] = hess (a)
Compute the Hessenberg decomposition of the matrix a.

The Hessenberg decomposition is usually used as the first step in an eigenvalue computation, but has other applications as well (see Golub, Nash, and Van Loan, IEEE Transactions on Automatic Control, 1979. The Hessenberg decomposition is p * h * p' = a where p is a square unitary matrix (p' * p = I, using complex-conjugate transposition) and h is upper Hessenberg (i >= j+1 => h (i, j) = 0).

Loadable Function: [l, u, p] = lu (a)
Compute the LU decomposition of a, using subroutines from LAPACK. The result is returned in a permuted form, according to the optional return value p. For example, given the matrix a = [1, 2; 3, 4],

 
[l, u, p] = lu (a)

returns

 
l =

  1.00000  0.00000
  0.33333  1.00000

u =

  3.00000  4.00000
  0.00000  0.66667

p =

  0  1
  1  0

Loadable Function: [q, r, p] = qr (a)
Compute the QR factorization of a, using standard LAPACK subroutines. For example, given the matrix a = [1, 2; 3, 4],

 
[q, r] = qr (a)

returns

 
q =

  -0.31623  -0.94868
  -0.94868   0.31623

r =

  -3.16228  -4.42719
   0.00000  -0.63246

The qr factorization has applications in the solution of least squares problems

 
min norm(A x - b)

for overdetermined systems of equations (i.e., a is a tall, thin matrix). The QR factorization is q * r = a where q is an orthogonal matrix and r is upper triangular.

The permuted QR factorization [q, r, p] = qr (a) forms the QR factorization such that the diagonal entries of r are decreasing in magnitude order. For example, given the matrix a = [1, 2; 3, 4],

 
[q, r, pi] = qr(a)

returns

 
q = 

  -0.44721  -0.89443
  -0.89443   0.44721

r =

  -4.47214  -3.13050
   0.00000   0.44721

p =

   0  1
   1  0

The permuted qr factorization [q, r, p] = qr (a) factorization allows the construction of an orthogonal basis of span (a).

Loadable Function: s = schur (a)
Loadable Function: [u, s] = schur (a, opt)
The Schur decomposition is used to compute eigenvalues of a square matrix, and has applications in the solution of algebraic Riccati equations in control (see are and dare). schur always returns s = u' * a * u where u is a unitary matrix (u'* u is identity) and s is upper triangular. The eigenvalues of a (and s) are the diagonal elements of s If the matrix a is real, then the real Schur decomposition is computed, in which the matrix u is orthogonal and s is block upper triangular with blocks of size at most 2 x 2 blocks along the diagonal. The diagonal elements of s (or the eigenvalues of the 2 x 2 blocks, when appropriate) are the eigenvalues of a and s.

The eigenvalues are optionally ordered along the diagonal according to the value of opt. opt = "a" indicates that all eigenvalues with negative real parts should be moved to the leading block of s (used in are), opt = "d" indicates that all eigenvalues with magnitude less than one should be moved to the leading block of s (used in dare), and opt = "u", the default, indicates that no ordering of eigenvalues should occur. The leading k columns of u always span the a-invariant subspace corresponding to the k leading eigenvalues of s.

Loadable Function: s = svd (a)
Loadable Function: [u, s, v] = svd (a)
Compute the singular value decomposition of a

 
a = u * sigma * v'

The function svd normally returns the vector of singular values. If asked for three return values, it computes U, S, and V. For example,

 
svd (hilb (3))

returns

 
ans =

  1.4083189
  0.1223271
  0.0026873

and

 
[u, s, v] = svd (hilb (3))

returns

 
u =

  -0.82704   0.54745   0.12766
  -0.45986  -0.52829  -0.71375
  -0.32330  -0.64901   0.68867

s =

  1.40832  0.00000  0.00000
  0.00000  0.12233  0.00000
  0.00000  0.00000  0.00269

v =

  -0.82704   0.54745   0.12766
  -0.45986  -0.52829  -0.71375
  -0.32330  -0.64901   0.68867

If given a second argument, svd returns an economy-sized decomposition, eliminating the unnecessary rows or columns of u or v.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003