Docsity

Lecture Slides for Linear Systems | CMSC 878R, Study notes of Computer Science

Toggle sidebar
bg1
1
Lecture 14: CMSC 878R/AMSC698R
Iterative Methods and the FMM
Outline
• Direct Solution of Linear Systems
– Inverse, LU decomposition, Cholesky, SVD, etc.
• Iterative methods for linear systems
– Why?
• Matrix splittings and fixed-point schemes
– SOR, Jacobi, Gauss Seidel, etc.
• Krylov Methods
– Conjugate Gradient, GMRES
• Convergence and Preconditioning
• Eigenvalue Problems
• Iterative methods for eigenvalue problems
Preliminary Comments
• FMM accelerates matrix-vector multiplication
• However, most problems require solution of linear systems
• Goal: See how linear systems can be solved using FMM
• Take home message
– Iterative methods require matrix vector products
– Can be written as FMM
– Some methods can be guaranteed to converge in Nsteps
– With good guess and clever algorithms may converge much faster
• Philosophy:
– In general it is better to be a “consumer” of linear algebra
– Use canned software which asks you to provide a product routine
– However, with FMM there may not be “canned” or “tuned”
software available and we may have to develop our own
Direct Solution of linear systems
Ax=b →x=A
-1
b
• Almost never a good idea to construct inverse to solve
• Computing inverse is more expensive than solving system
– Computing inverse leads to loss of precision
• Exceptions
– Analytical expression for inverse can be obtained, e.g.,
pf3
pf4
pf5

Partial preview of the text

Download Lecture Slides for Linear Systems | CMSC 878R and more Study notes Computer Science in PDF only on Docsity!

Lecture 14: CMSC 878R/AMSC698R

Iterative Methods and the FMM

Outline

  • Direct Solution of Linear Systems
    • Inverse, LU decomposition, Cholesky, SVD, etc.
  • Iterative methods for linear systems
    • Why?
  • Matrix splittings and fixed-point schemes
    • SOR, Jacobi, Gauss Seidel, etc.
  • Krylov Methods
    • Conjugate Gradient, GMRES
  • Convergence and Preconditioning
  • Eigenvalue Problems
  • Iterative methods for eigenvalue problems

Preliminary Comments

  • FMM accelerates matrix-vector multiplication
  • However, most problems require solution of linear systems
  • Goal: See how linear systems can be solved using FMM
  • Take home message
    • Iterative methods require matrix vector products
    • Can be written as FMM
    • Some methods can be guaranteed to converge in N steps
    • With good guess and clever algorithms may converge much faster
  • Philosophy:
    • In general it is better to be a “consumer” of linear algebra
    • Use canned software which asks you to provide a product routine
    • However, with FMM there may not be “canned” or “tuned” software available and we may have to develop our own

Direct Solution of linear systems

Ax=b → x=A-1b

  • Almost never a good idea to construct inverse to solve
  • Computing inverse is more expensive than solving system
    • Computing inverse leads to loss of precision
  • Exceptions
    • Analytical expression for inverse can be obtained, e.g.,

Direct solutions (2)

  • Consumer level – Use LAPACK or MATLAB,
    • (vectorized, cache-optimized, etc.) -- ATLAS
  • For non symmetric matrices use LU decomposition
  • LU decomposition  N^3 /3 operations
  • Backsubstitution O(N^2 )
  • For symmetric matrices use Cholesky decomposition  N^3 /6 operations
  • All these methods require storage of the matrix and for dense matrices have memory complexity O(N^2 )

References

  • C.T. Kelley, “Iterative methods for Linear and Nonlinear Equations, SIAM, 1995)
  • J. Shewchuck, “An Introduction to the Conjugate Gradient Method Without the Agonizing Pain”
  • (downloadable from http://www-2.cs.cmu.edu/~jrs/jrspapers.html)
  • “Templates for the solution of linear systems: Building Blocks and Iterative Methods,” Barrett et al, SIAM (downloadable at http://www.netlib.org/linalg/html_templates/Templates.html )
  • Yousef Saad has two good books online NumericalMethods for Large Eigenvalue Problems Iterative methods for sparse linear systems. (downloadable at http://www-users.cs.umn.edu/~saad/books.html)

Iterative Methods: Notation

Ax =b

  • A is a nonsingular N § N matrix, x,b \in RN
  • Ax can be calculated using FMM
  • x* is the solution to be found. x* =A-1b \in RN
  • Definitions

Fixed point iteration

  • In fixed point iteration we write x=Mx
  • If M is a contraction (|| M || < 1) then following converges
    • Start with guess x 0
    • Generate successive estimates xk=M xk-
  • How to write our equation as a fixed point scheme? Ax=Ix + (A−I)x =b
  • So, I x = (I−A)x +b
  • (Richardson iteration) xk+1 = (I−A)xk +b
  • For convergence we require || I−A|| < 1
  • Iteration Matrix M here is ||I−A||

Steepest descent

  • So finding minimizer of the quadratic form gives a solution
  • Start at guess x 0 , take a step along − ∇ f (x 0 ) ∇ f (x 0 ) = Ax 0 −b = −r 0

x 1 = x 0 + α r 0

  • How big should the step α be?
  • We can find α that minimizes f(x 0 + α r 0 )
  • So if α should be chosen so that r 0 is orthogonal to ∇ f
  • Can show

Steepest Descent method

  • Putting things together
  • Requires two matrix vector products with A per iteration
  • Can reduce one
  • Can convert last equation to

ri+1=ri − α i Ari

  • only need calculate Ari
  • What about convergence?
  • Can show at k th iteration

Conjugate Gradient

  • Instead of minimizing each time along gradient, choose a set of basis directions to minimize along
  • Choose these directions to be from the Krylov subspace
  • Definition: Krylov subspace
  • Definition: Energy or A -norm of a vector ||x||A=(xt^ Ax)1/
  • Idea of conjugate gradient method
    • Generate Krylov subspace directions, and take a step that minimizes the A norm of the residual along this direction
  • Let search direction be at step k+1 be dk+
  • We require f(xk+ αk+1 d k+1 ) is minimized along direction
  • Conjugacy property d k+1 AK k =

CG Minimization

  • We want to make the current solution’s to be the one whose error is minimized in the energy norm
  • Express the solution in terms of Krylov basis
  • Here V is the N × k matrix with the Krylov vectors up to current iteration as columns
  • Set dE/dαααα =

CG Minimization

  • Computing the derivative
  • Observation: As iteration proceeds, because of the orthogonality, the earlier components do not change. - So all we need to do is compute the new entry α I - Practical implementation is a little different

CG Algorithm

  • Each iteration requires comput- ation of one matrix vector product Adi
  • Guaranteed to converge after N iterations (for exact arithmetic)
  • So FMM guaranteed to solve equations in O(N^2 ) time
  • Method does not require storage of any of the Krylov basis vectors
  • Trivial to add preconditioning
  • Implemented in Matlab as pcg

PCG

  • Pcg: Preconditioned conjugate gradients method
  • x = pcg(A,b)
    • pcg(A,b,tol)
    • pcg(A,b,tol,maxit)
    • pcg(A,b,tol,maxit,M)
    • pcg(A,b,tol,maxit,M1,M2,x0)
  • [x,flag] = pcg(A,b,...)
  • [x,flag,relres] = pcg(A,b,...)
  • [x,flag,relres,iter] = pcg(A,b,...)
  • [x,flag,relres,iter,resvec] = pcg(A,b,...)
  • Descriptionx = pcg(A,b) attempts to solve the system of linear equations A*x=b for x. The n-by-n coefficient matrix A must be symmetric and positive definite, and should also be large and sparse.
  • The column vector b must have length n.
  • A can be a function handle afun such that afun(x) returns Ax.*

Convergence of CG

  • If there are k distinct eigenvalues of A , then CG converges in at most k iterations to the exact solution (in exact arithmetic)
  • Usually we go to || b−Axk|| 2  η ||b|| 2
  • Converges quickly
  • Compare with steepest descent

Krylov methods for Eigenvalues

  • Arnoldi methods  Implemented in arpack
  • Available in Matlab as eigs

d = eigs(A) returns a vector of A's six largest magnitude eigenvalues.[V,D] = eigs(A) returns a diagonal matrix D of A's six largest magnitude eigenvalues and a matrix V whose columns are the corresponding eigenvectors. [V,D,flag] = eigs(A) also returns a convergence flag. If flag is 0 then all the eigenvalues converged; otherwise not all converged. eigs(A,B) solves the generalized eigenvalue problem AV == BVD. B must be symmetric (or Hermitian) positive definite and the same size as A. eigs(A,[],...) indicates the standard eigenvalue problem AV == V*D. eigs(A,k) and eigs(A,B,k) return the k largest magnitude eigenvalues. eigs(A,k,sigma) and eigs(A,B,k,sigma) return k eigenvalues based on sigma, which can take any of the following values:scalar (real or complex, including 0)The eigenvalues closest to sigma.

Research: Preconditioning for the FMM

  • In all these methods (especially at the large sizes where the FMM is used), iterative methods are slowly convergent
  • Unless iteration converges relatively quickly (less than 100 iterations), it may not be practically useful
  • Condition number is important in quantifying convergence
    • Project for estimating condition number
  • Most preconditioners were invented to speed up sparse matrix computations
  • Take O(N^2 ) time for dense matrices (or too slow)
  • Goal: Fashion good preconditioners for the FMM

Preconditioner cost

  • To be effective with the FMM the preconditioner cost should be O(N log N) or less
  • Otherwise we negate the advantage of the FMM
  • Our recent research two preconditioners for FMM
    • First, for highly oscillatory kernel --- multiple scattering with the Helmholtz equation
    • Second, we accelerate a highly successful preconditioner developed by Faul, Powell and Goodsell (2005), but which has a complexity of O(N^2 ) to O(N log N).