write a C++ Program for matrix operations which include: 1. constructor in the form-- matrix::matrix(int numRows,...

70.2K

Verified Solution

Question

Programming

write a C++ Program for matrix operations which include:

1. constructor in the form-- matrix::matrix(int numRows, intnumColumns)

2. Implement a setter method of the form: -- voidmatrix::setElement(int row, int col)

3 Implement a getter method of the form: -- floatmatrix::getElement(int row, int col)

4. Make a threaded version of the matrix/matrix additionmethod.

5. Make a threaded version of the matrix/scalar multiplicationmethod.

6. Matrix/matrix addition methods of the form: -- matrixmatrix::matrixAdd(matrix inMatrix) // non-threaded version

matrix matrix::matrixAdd_threaded(matrix inMatrix) // threadedversion

7. Matrix/scalar multiplication methods of the form: -- matrixmatrix::scalarMult(float scalar) // non-threaded version

matrix matrix::scalarMult_threaded(float scalar) // threadedversion

8. The vector reduce operation method should be of the form:

float matrix::reduceVec()

The reduce operation must use parallelization with the followingalgorithm. Use eight threads to compute this. Begin by splittingthe vector (a 1xM matrix with one row and M columns) into 8 parts.Compute the sum of those parts and store them. Then, launch eightthreads to sum the sums. Do this until you have a single numberremaining.

Answer & Explanation Solved by verified expert
4.3 Ratings (619 Votes)
Summary Implemented Threaded and Nonthreaded method functions forAddition scalar multiplication For threaded version it spawns thread number of rows andwaits for them to return which in turn iterate over that row andcalculate the values Cppinclude include include include include include include include include include include include matriceshinclude using namespace    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students