{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

GaussOperationCount

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

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

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

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

View Full Document
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 ( k = 1 ) then the inner loop: i = 2 to n . The number of iterations of the inner loop are: n X i =2 1 = ( n - 2) + 1 = n
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern