This preview shows pages 1–4. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Eng101W07 Sec 100 Homework 8: Strange vectors and Random walks Due Friday, March 30, 2007, by 6 PM EDT Upload to CTools Site Name: FILLIN Lab GSI: FILLIN Lab Section #: FILLIN REMINDER: HONOR CODE REMAINS IN EFFECT. SERIOUSLY! ADDITIONAL PROBLEMS (FOR EXTRA CREDIT) WILL BE POSTED 3/25. COMPLETE THESE ASSIGNED PROBLEMS BEFORE TACKLING THE EXTRA CREDIT. A. Preparatory work . Read through Eckels Chapter 3. Pay particular attention to functions and the syntax of functions, operators, and looping structures. When in doubt, look things up on http://www.cplusplus.com/reference/ and look at the example code under the member function (skip the front stuff drop to the bottom of the page). Dont be disappointed, the length of this assignment has been cut but the points remain the same. Use the sample code provided and use it liberally! B. Answer the following questions. 1. [15 pts.] General purpose matrix addition Modify the C++ code in Lecture 26 (see Lec2628 under Resources>Lecture Notes on the CTools website) to create a function that returns the matrix D , where D = aA + bB , A and B are RxC matrices, and a and b are real numbers. Using your function, write a simple main() program that evaluates and print out your result to the console using the outputMat function found in powerVer3.cpp . Provide a copy of your generalpurposematrixaddition function below along with a copy of the console output for the given values of a, A, b, and B above. Solution gregoryw% .//a.out [ 1 196.5 36.5 78.5] B. Answer the following questions. 1. [15 pts.] General purpose matrix addition Modify the C++ code in Lecture 26 (see Lec2628 under Resources>Lecture Notes on the CTools website) to create a function that returns the matrix D , where D = aA + bB , A and B are RxC matrices, and a and b are real numbers. Using your function, write a simple main() program that evaluates and print out your result to the console using the outputMat function found in powerVer3.cpp . Provide a copy of your generalpurposematrixaddition function below along with a copy of the console output for the given values of a, A, b, and B above. Solution gregoryw% .//a.out [ 1 196.5 36.5 78.5] (See also HW8_1.cpp code included in HW8 solutions folder) 2. [20 pts.] Power method: Dependence on initial vector In class, we demonstrated that repeated multiplication of a normalized vector by a matrix converged after just a few iterations to a constant vector. In matrix algebra, we learn that this constant vector is one of the eigenvectors of the matrix. The code, powerVer3.cpp, creates a random matrix and a random vector, and loops until the distance between the current and updated normalized vectors falls below a threshold. What we cant tell from this code is whether we always converge to the same eigenvector when we perform this iteration....
View Full
Document
 Fall '07
 Ringenberg

Click to edit the document details