Question: PLEASE DO NOT COPY PASTE FROM CHEGG/OTHERWISE I'LL REPORT YOU OR GIVE OU A DISLIKE [Q-6] Phase 1 Write a C++ program that multiplies a

PLEASE DO NOT COPY PASTE FROM CHEGG/OTHERWISE I'LL REPORT YOU OR GIVE OU A DISLIKEPLEASE DO NOT COPY PASTE FROM CHEGG/OTHERWISE I'LL REPORT YOU OR GIVE

[Q-6] Phase 1 Write a C++ program that multiplies a matrix by a vector. The program should read the number of rows and columns of the matrix from the command line Ex. s\$ /8 a.out -rows cint s>s-cols $ Phase 1 Write a C++ program that multiplies a matrix by a vector. The program should read the number of rows and columns of the matrix from the command line. $ /a.out-rows cint> -cols Ex Dynamically allocate space for the matrix and vector. The matrix and vector should both be declared to store integers. The vector should have the same size as the number of columns. Be sure to allocate "number of rows" integers for a vector to hold the product vector. Initialize each element of the matrix and vector to 1. This should be considered a test mode. Next, perform the matrix-vector multiplication operation. Finally, print the product vector on a single line with one space between elements. Confirm that the product is correct. The product vector should have as many elements as matrix rows. Each product vector element should equal the number of columns. Phase II Enable a compile-time flag to control how the matrix and vector are initialized the matrix for normal mode use. In test mode initialize the input matrix and vector as above. In normal mode Initialize the matrix and vector with random numbers in the range [-5, 5). Use the C++11 random number facilities, an example follows. DO NOT USE STANDARD C rand FUNCTION. Please keep the engine seed = 1; this will make grading much easier. #include dist(-5, 5); #ifdef TEST mat[][] - 1; #else mat[i] - dist(engine), Fendif Compile for TEST mode as follows $9++ stdC++11-DTEST mat-vec.cpp -o mat-vec.exe Compile for normal mode by omitting the "-DTEST" string

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!