Linear Algebra

Contents:

  1. LU Decomposition

  2. QR Decomposition

  3. QR Decomposition with Column Pivoting

  4. Singular Value Decomposition

  5. Cholesky Decomposition

  6. Tridiagonal Decomposition of Real Symmetric Matrices

  7. Tridiagonal Decomposition of Hermitian Matrices

  8. Hessenberg Decomposition of Real Matrices

  9. Hessenberg-Triangular Decomposition of Real Matrices

  10. Bidiagonalization

  11. Householder Transformations

  12. Householder solver for linear systems

  13. Tridiagonal Systems

  14. Balancing

  15. NArray

LU Decomposition


  1. Singleton method of the GSL::Linalg::LU module

    >> m = Matrix[1..9, 3, 3]
    => GSL::Matrix:
    [ 1.000e+00 2.000e+00 3.000e+00
      4.000e+00 5.000e+00 6.000e+00
      7.000e+00 8.000e+00 9.000e+00 ]
    >> lu, perm, sign = Linalg::LU.decomp(m)
  2. Instance method of GSL::Matrix class

    >> lu, perm, sign = m.LU_decomp

  1. Singleton method of the GSL::Linalg::LU module

    A = Matrix[[0.18, 0.60, 0.57, 0.96], [0.41, 0.24, 0.99, 0.58],
               [0.14, 0.30, 0.97, 0.66], [0.51, 0.13, 0.19, 0.85]]
    lu, perm, sign = A.LU_decomp
    b = Vector[1, 2, 3, 4]
    x = Linalg::LU.solve(lu, perm, b)
    
  2. Instance method of GSL::Linalg::LUMatrix class

    lu, perm, sign = A.LU_decomp  # lu is an instance of Linalg::LUMatrix class
    b = Vector[1, 2, 3, 4]
    x = lu.solve(perm, b)
    
  3. Solve directly

    x = Linalg::LU.solve(A, b)  # LU decomposition is calculated internally (A is not modified)
    




Complex LU decomposition

QR decomposition


  1. Singleton method of the module GSL::Linalg

    qr, tau = Linalg::QR_decomp(m)
    p qr.class                 # GSL::Linalg::QRMatrix, subclass of GSL::Matrix
    p tau.class                # GSL::Linalg::TauVector, subclass of GSL::Vector
    
  2. Singleton method of the module GSL::Linalg:QR

    qr, tau = Linalg::QR.decomp(m)
    
  3. Instance method of GSL::Matrix

    qr, tau = m.QR_decomp
    




QR Decomposition with Column Pivoting







Singular Value Decomposition





Cholesky Decomposition

A symmetric, positive definite square matrix A has a Cholesky decomposition into a product of a lower triangular matrix L and its transpose L^T, as A = L L^T. This is sometimes referred to as taking the square-root of a matrix. The Cholesky decomposition can only be carried out when all the eigenvalues of the matrix are positive. This decomposition can be used to convert the linear system A x = b into a pair of triangular systems (L y = b, L^T x = y), which can be solved by forward and back-substitution.



Complex Cholesky decomposition

Tridiagonal Decomposition of Real Symmetric Matrices




Tridiagonal Decomposition of Hermitian Matrices




Hessenberg Decomposition of Real Matrices





Hessenberg-Triangular Decomposition of Real Matrices



Bidiagonalization



Householder Transformations





Householder solver for linear systems




Tridiagonal Systems





Balancing

The process of balancing a matrix applies similarity transformations to make the rows and columns have comparable norms. This is useful, for example, to reduce roundoff errors in the solution of eigenvalue problems. Balancing a matrix A consists of replacing A with a similar matrix where D is a diagonal matrix whose entries are powers of the floating point radix.



NArray

The following Linalg methods can handle NArray objects:

prev next

Reference index top