This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: MAE 107 Problem JDG-NA03 1.) Write a Matlab function cpucomp that will compare the required CPU time (on whatever platform is used) for solution of the n × 1 linear equation A x = b by means of the Matlab operations x=inv(A)*b and x=A \ b , for the case of a random (”forcing”) b= rand(n,1) . Your function should accept an n × n square matrix (A) as input and return the two times, say tinv and tbsl, along with the condition number of the matrix, in response to a function call of the form: [tinv, tbsl, c]=cpucomp(A) . Using the comment symbols %, include a brief preamble above the function definition stating what the function does and stating your name as author. (This preamble can then be displayed with the command help cpucomp . ) For a random forcing vector b= rand(n,1) , test your program on the matrices: i.) randomly rotated diagonal matrix , defined by: Q = orth(randn(n, n)); d = logspace(0,-10,n); A = Q*diag(d)*Q’; ii.) the Hilbert matrix , defined by A(i, j) =1/(i+j -1) , which may be constructed with for-loops., which may be constructed with for-loops....
View Full Document
This note was uploaded on 05/12/2010 for the course MAE 107 taught by Professor Goddard during the Winter '10 term at San Diego.
- Winter '10