Your algorithm should iterate until k r k k 2 k b k 2 is less than tol or the

# Your algorithm should iterate until k r k k 2 k b k 2

• Homework Help
• 4

This preview shows page 2 - 4 out of 4 pages.

Your algorithm should iterate until k r k k 2 / k b k 2 is less than tol or the maximum number of iterations maxiter has been reached. For the outputs: x is your solution, and iter is the number of iterations that were performed. Using function handles instead of explicit matrices is easy. Instead of writing r = b - H*x; like you would if H is a matrix, you write r = b - H(x); You will want to debug your code using small (sym+def) matrices that you can construct the inverses to explicitly. When your code is ready for the big-time, download the files imagedeconv experiment.m , imagedeconv data.mat , imconv.m , and imconv transpose.m . In the mat file, you will find a 305 × 305 image Y and a 50 × 50 kernel W . The image Y was created by convolving a 256 × 256 image X with W . It is your job to figure out what X must have been. Of course, the code you wrote for sdsolve operates on and returns vectors, not images. But is is easy to turn a N × N image X into a vector x of length N 2 : >> x = reshape(X, N^2, 1); (the shorter x=X(:); also works) and vice versa: >> X = reshape(x, N, N); I have graciously implemented 2D convolution and its transpose for you in the files imconv.m and imconv transpose.m . I have also created some function handles at the beginning of imagedeconv experiment.m that will help you. All you have to do is add a few lines to imagedeconv experiment.m that calls your code and does the recovery. Your solution must have relative residual error k r k k 2 / k b k 2 less than 10 - 4 Turn in your code, the original image (created using imagesc(Y); colormap(gray) ), your recovered image, and the number of iterations it took you to reduce the relative residual error to less than 10 - 4 from a starting guess of 0 . 2 Last updated 11:14, November 26, 2019

Subscribe to view the full document.

Important note: The pseudo-code at the bottom of page III.36 of the notes should be your guideline. Note that this uses only one application of H per iteration by using our trick for updating the residual (instead of explicitly calculating it). In practice, you will probably want to calculate the residual explicitly once every 50 iterations. To do this, just put in an if-then that substitutes rk = b - H(xk) for rk = rkold - ak*q every fifty iterations. 4. Write a MATLAB function cgsolve.m that implements the method of conjugate gradients.
• Fall '08
• Staff

### 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