Thursday, June 2, 2011

Algorithm of Matrix multiplication

0 comments
1.Start
2.If(n not equal to p) goto step3 else goto step4
3.Print "Matrices not compatible" goto step36
4.If(n=p) goto step5 else goto step11
5.Assign i=1
6.If i<=n then i=1 and goto7 else goto11
7.If j<=n then goto8 else goto10
8.Read a[i][j]
9.Assign j=j+1 goto step7
10.Assign i=i+1 goto step6
11.Assign i=1
12.If i<=p then j=1 and goto 13 else goto14
13.If j<=q then goto12 else goto16
14.Read b[i][j]
15.Assign j=j+1 goto step13
16.Assign i=i+1 goto step12
17.Print "The product of two matrices A anb B are "
18.Assign i=1
19.If i<=m then j=1 and goto step20 else goto step24
20.If j<=q then k=1 and goto step21 else goto step23
21.Assign c[i][j]=0,if k<=n and k=k+1 goto step21 else goto22
22.j=j+1 goto step20
23.i=i+1 goto step19
24.Assign i=1
25.If i<=n then j=1 and goto26 else goto31
26.If j<=q then k=1 and goto27 else goto30
27.If k<=n then assign c[i][j]=a[i][j]*b[i][j]
28.k=k+1 goto step27
29.j=j+1 goto step26
30.i=i+1 and goto step25
31.Assign i=1
32.If i<=n,i=1 and goto33 else goto32
33.If j<=q goto step34 else goto35
34.Print c[i][j],j=j+1 and goto step33
35.i=i+1 goto step32
36.stop


Leave a Reply