How to Write Fast Numerical Code Spring 2011 Lecture 13 Instructor: - - PowerPoint PPT Presentation

how to write fast numerical code
SMART_READER_LITE
LIVE PREVIEW

How to Write Fast Numerical Code Spring 2011 Lecture 13 Instructor: - - PowerPoint PPT Presentation

How to Write Fast Numerical Code Spring 2011 Lecture 13 Instructor: Markus Pschel TA: Georg Ofenbeck Miscellaneous No class next Monday, April 11 th (Sechseluten) Midterm exam: Friday, April 15 th Today Solving linear systems


slide-1
SLIDE 1

How to Write Fast Numerical Code

Spring 2011 Lecture 13 Instructor: Markus Püschel TA: Georg Ofenbeck

slide-2
SLIDE 2

Miscellaneous

No class next Monday, April 11th (Sechseläuten)

Midterm exam: Friday, April 15th

slide-3
SLIDE 3

Today

Solving linear systems

Matrix inversion

PLU factorization

Determinant Chapter 2 in James W. Demmel, Applied Numerical Linear Algebra, SIAM, 1997

LAPACK BLAS

BLAS 1: vector-vector ops BLAS 2: matrix-vector ops BLAS 3: matrix-matrix ops Linear system solving Matrix inversion Singular value decomposition ... and more

slide-4
SLIDE 4

Gauss Elimination and LU Factorization

A = [ak,l]1≤k,l≤n

A

  • a2,1/a1,1
  • an,1/a1,1

a2,1 a1,1

  • =

a1,1 a1,n

A’ 1 1 1

a1,1

  • an,1 0

A

  • a1,1

a1,n a’2,2 a’1,n

A’

a2,1 a1,1

  • 1

1 1

a1,1

  • an,1 0

A

  • a’3,2

a’2,2

  • 1

1 1

a’2,2

  • a’n,2 0
  • =
slide-5
SLIDE 5

after n-1 steps ….

U =

A

  • A

U

a2,1 a1,1

1 1 1

a1,1 an,1 0 a’3,2 a’2,2

1 1 1

a’2,2 a’n,2 0

  • =

A

U

a2,1 a1,1

1 1 1

a1,1 an,1 a’3,2 a’2,2 a’2,2 a’n,2

  • =

= L ● U

slide-6
SLIDE 6

Summary

Gauss elimination is LU factorization

  • We assume that the occurring diagonal elements a1,1, a’2,2, … are all ≠ 0

(otherwise the LU factorization does not exist)

  • U = upper triangular
  • L = lower triangular (1’s on diagonal)
  • L contains the multipliers occurring in Gauss elimination

Now Ax = b is LUx = b and can be solved in two steps:

  • Solve Ly = b
  • Solve Ux = y
  • Cost: n2 + O(n) for each step = 2n2 + O(n)
slide-7
SLIDE 7

LU Factorization: Algorithm

From straightforward algorithm to optimized BLAS 3 based one (blackboard) Chapter 2 in James W. Demmel, Applied Numerical Linear Algebra, SIAM, 1997