Starting from:

$30

EE328-Project 8: Matrix Multiplication Solved

1.1 DESCRIPTION
Writeaprogramthatcalculatesthematrixmultiplicationwithallthesituationconsidering. You canseethedetailintheendofchapter4ofOPERATINGSYSTEMCONCEPTSWITHJAVA(Seventh Edition), page 162.

2 ALGORITHM
be described as follows:
  
 
 a11 a12 ···  a21 a22 ···



               ...            ...             ...



 am1 am[1] ···

where
a1n   b11

a2n   b21

 

... × ...

  amn                       bn1
b12 b22

...

bn2
··· ···

...

···
b1q   c11

b2q   c21

 

... = ...

  bnq      cm1
c12                ··· c22                ···

...          ... cm2 ···
c1q 

c2q  

... 



cmq
(1)
n
 
 
 
 
 
 
(2)
ci j = X airbr j = ai1b1j +ai2b2j +···+a1nbnj,i = 1,2,··· ,m; j = 1,2,··· ,q

r=1

2.2 MULTI-THREAD PROGRAMMING
1


Figure 3.1: Screenshot of Matrix Multiplication

2.3 ROBUSTNESS CONSIDERATION
The user input process requires great efforts to avoid illegal input and make sure the program execute normally. First we require user to input 4 integers to denote the rows and columns and create 2 zero matrices. The column number of [A] needs to be the same as the row number of [B] and thus a detection is needed. In the meantime we require the user to input a row at a time so if any illegal input exists the user is supposed to input this row again until he finishes input.

3 RESULTS
3.1 ENVIRONMENT
•   Windows 10

•   Java Development Kit 1.8.0_131

•   Eclipse

3.2 SCREENSHOTS OF THE RESULT

We use command line to compile and execute the program. The result is shown in Fig. 3.1.

3.3 THOUGHTS
It is the first time that I learn multi-thread programming. Although the algorithm is easy it still consumed me lots of time to master multi-thread programming, which benefits me a great deal.

 
[1] .1 MATRIX MULTIPLICATION

Matrix multiplication is able to be executed when the matrices are like [A]m×n×[B]n×q and can

We create m×q threads to calculate each element in the result matrix [C]m×q using the formula above. After all sub-threads have been terminated, the main thread will print the result. Class CalMatrix is supposed to extend class Thread and override the method run(). Method join() is necessary in the main thread as well.

More products