C++_HW8_Solutions - Eng101W07 Sec 100 Homework 8: Strange...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the 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: FILL-IN Lab GSI: FILL-IN Lab Section #: FILL-IN 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 Lec26-28 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 general-purpose-matrix-addition 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 Lec26-28 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 general-purpose-matrix-addition 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

Page1 / 7

C++_HW8_Solutions - Eng101W07 Sec 100 Homework 8: Strange...

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

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