Question: Objective: Implement a robust matrix class using object - oriented programming principles in C + + . Apply multithreading std::thread to enhance computational efficiency for

Objective:
Implement a robust matrix class using object-oriented programming principles in
C++.
Apply multithreading std::thread to enhance computational efficiency for large matrix
multiplication.
Compare the performance of single-threaded and multithreaded computations.
Tasks: Design Matrix Class for Matrix Multplication
1. Design and implement a Matrix class that supports dynamic memory management to handle large matrices.
2. The class should include default constructors and destructor.
3. The default constructor is used to initialize a matrix with 0.
4. A member function fill_rand_value to initialize a matrix with random values.
5. Include methods for matrix multiplication in mathematics, ensuring the class can
handle non-square matrices as well.a. Extend the matrix multiplication method to use multithreading, where each thread computes a portion of the result matrix.
6. Single-threaded Multiplication Implementation
a. Implement the standard matrix multiplication algorithm in a single-threaded
manner within the Matrix class.
b. Ensure the method handles exceptions (e.g., mismatched size) correctly.
7. Multithreaded Multiplication Implementation
a. Extend the matrix multiplication method to use multithreading, where each
thread computes a portion of the result matrix
b. Consider dividing the workload by rows or blocks of rows to distribute the multiplication tasks among threads.
c. Ensure the method handles exceptions (e.g., mismatched size) correctly.
The input and output should be like below:
Input:
Based on the given week8.cpp to develop your program. Must not change the supplied
code.
Output
Test at least three cases, as shown below. Please note that the running time may vary
depending on the specifications of different computers.
Enter the number of rows of Matrix A: 10
Enter the number of cols of Matrix A: 20
Enter the number of rows of Matrix B: 10
Enter the number of cols of Matrix B: 20
Enter the number of threads: 2
Matrix dimensions must match!
Quit (YN):n
Enter the number of rows of Matrix A: 100
Enter the number of cols of Matrix A: 50
Enter the number of rows of Matrix B: 50
Enter the number of cols of Matrix B: 100
Enter the number of threads: 2
Single-threaded multiplication took 3.355ms.
Multithreaded multiplication took 18.6884 ms.
Validating results...
Results are identical!
Quit (YN):n
Enter the number of rows of Matrix A: 500
Enter the number of cols of Matrix A: 500
Enter the number of rows of Matrix B: 500
Enter the number of cols of Matrix B: 500
Enter the number of threads: 2
Single-threaded multiplication took 973.992ms.
Multithreaded multiplication took 482.789ms.
Validating results...
Results are identical!
Quit (Y/N): y
Objective: Implement a robust matrix class using

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 Programming Questions!