Question: Please do not copy of the internet. Instead be an original code that follows the requirements of the assignment. Thanks in advance! Matrix multiplication theory:
Matrix multiplication theory: Given two matrices. A and B, where matrix A contains m rows and k columns and matrix B contains k rows and n columns, the matrix product of A and B is matrix P, where P contains m rows and n columns. Entries in matrix P for row i and columnj (the cell (i, j)) is the sum of the products of the corresponding elements from it row in A and jth column in B. Multi-threaded matrix multiplication: In this problem, you are required to write a multi-threaded program for matrix product. Calculate each cell of the product matrix P in a separate worker thread. This will involve creating m x n worker threads. The main (or, parent thread will initialize the matrices A and Band allocate space to hold the matrix P. Ideally, these matrices should be declared as global data so that each worker thread has access to these matrices. The parent thread will create m x n worker threads, passing each worker the row i from first matrix and column j from the second matrix that it uses in calculating the matrix product. Once all worker threads have completed, the main thread will output the product contained in matrix P. This requires the main thread to wait for all worker threads to finish before it can output the value of the matrix product. Program requirements: Your program should read the data from a file. The file name is provided as command line argument at execution time. That is the user may use the following command after compilation, on a console to execute your program: java program-name>
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
