GaussOperationCount

GaussOperationCount - Silvana Ilie - MTH510 Lecture Notes 1...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Silvana Ilie - MTH510 Lecture Notes 1 Chapter 9.2. Naive Gaussian Elimination: Operation Counting 1.1 Naive Gaussian elimination code function x = GaussNaive(A,b) [m,n] = size(A); if m~=n, error(’Matrix A must be square’); end nb = n+1; Aug = [A b]; % forward elimination for k = 1:n-1 for i = k+1:n factor = Aug(i,k)/Aug(k,k); Aug(i,k:nb) = Aug(i,k:nb)-factor*Aug(k,k:nb); end end % back substitution x = zeros(n,1); x(n) = Aug(n,nb)/Aug(n,n); for i = n-1:-1:1 x(i) = (Aug(i,nb)-Aug(i,i+1:n)*x(i+1:n))Aug(i,i); end 1.2 Operation counting floating point operations (flops) time to perform addition/subtraction and multiplication/division about the same get insight in which part of program is most consuming 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
We shall use the following formulae: m X i =1 cf ( i ) = c m X i =1 f ( i ) m X i =1 1 = m m X i = k 1 = m - k + 1 m X i =1 i = 1 + 2 + 3 + ··· + m = m ( m + 1) 2 = m 2 2 + O ( m ) m X i =1 i 2 = 1 2 + 2 2 + 3 2 + ··· + m 2 = m ( m + 1)( m + 2) 6 = m 3 3 + O ( m 2 ) Let us now analyze the program above. Outer loop (
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/07/2012 for the course MTH MTH510 taught by Professor Dr.silvanailie during the Winter '12 term at Ryerson.

Page1 / 3

GaussOperationCount - Silvana Ilie - MTH510 Lecture Notes 1...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online