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 objectoriented programming principles in
C
Apply multithreading std::thread to enhance computational efficiency for large matrix
multiplication.
Compare the performance of singlethreaded and multithreaded computations.
Tasks: Design Matrix Class for Matrix Multplication
Design and implement a Matrix class that supports dynamic memory management to handle large matrices.
The class should include default constructors and destructor.
The default constructor is used to initialize a matrix with
A member function fillrandvalue to initialize a matrix with random values.
Include methods for matrix multiplication in mathematics, ensuring the class can
handle nonsquare matrices as well.a Extend the matrix multiplication method to use multithreading, where each thread computes a portion of the result matrix.
Singlethreaded Multiplication Implementation
a Implement the standard matrix multiplication algorithm in a singlethreaded
manner within the Matrix class.
b Ensure the method handles exceptions eg mismatched size correctly.
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 eg mismatched size correctly.
The input and output should be like below:
Input:
Based on the given weekcpp 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:
Enter the number of cols of Matrix A:
Enter the number of rows of Matrix B:
Enter the number of cols of Matrix B:
Enter the number of threads:
Matrix dimensions must match!
Quit :
Enter the number of rows of Matrix A:
Enter the number of cols of Matrix A:
Enter the number of rows of Matrix B:
Enter the number of cols of Matrix B:
Enter the number of threads:
Singlethreaded multiplication took
Multithreaded multiplication took ms
Validating results...
Results are identical!
Quit :
Enter the number of rows of Matrix A:
Enter the number of cols of Matrix A:
Enter the number of rows of Matrix B:
Enter the number of cols of Matrix B:
Enter the number of threads:
Singlethreaded multiplication took
Multithreaded multiplication took
Validating results...
Results are identical!
Quit YN: y
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
