# Program multiplies two matrices AxB. (Sample Programs)

This program multiplies two matrices AxB.

Any rows or colunmas.

Eg:

A)

1 2 3

4 5 6

7 8 9

B)

9 8 7

6 5 4

3 2 1

Note:

Jim, to assign the tag value of anonymous array,

working without declaring arrays. Is that right?

See you the init program !!!

**************************************************************************

#matrices multiplication

#dim a(8) #<<< >>> !!!!!!!!! ?????????? and run

#dim b(8) #<<< >>> !!!!!!!!! ?????????? and run

a = {1,2,3,4,5,6,7,8,9}

b = {9,8,7,6,5,4,3,2,1}

redim a(3,3)

redim b(3,3)

cls

gosub show

for row = 0 to a[?,]-1

for col = 0 to b[,?]-1

t = 0

for h1 = 0 to a[,?]-1

t = t + (a[row,h1] * b[h1,col])

print "("+ string(a[row,h1]) + " x " + string (b[h1,col]) +") + ";

next h1

print " = "+t

next col

print

next row

print

print "*****************"

print

for row = 0 to a[?,]-1

for col = 0 to b[,?]-1

t = 0

for h1 = 0 to a[,?]-1

t = t + (a[row,h1] * b[h1,col])

print "("+ string(a[row,h1]* b[h1,col])+") + ";

next h1

print " = "+t

next col

print

next row

end

#*********************

show:

print "A"

for row = 0 to a[?,]-1

for col = 0 to a[,?]-1

print a[row,col] + " ";

next col

print

next row

print

print "x"

print

print "B"

for row = 0 to a[?,]-1

for col = 0 to a[,?]-1

print b[col,row] + " ";

next col

print

next row

print

print "="

print

return

******************************************************

Out Screen

A

1 2 3

4 5 6

7 8 9

x

B

9 6 3

8 5 2

7 4 1

=

(1 x 9) + (2 x 6) + (3 x 3) + = 30

(1 x 8) + (2 x 5) + (3 x 2) + = 24

(1 x 7) + (2 x 4) + (3 x 1) + = 18

(4 x 9) + (5 x 6) + (6 x 3) + = 84

(4 x 8) + (5 x 5) + (6 x 2) + = 69

(4 x 7) + (5 x 4) + (6 x 1) + = 54

(7 x 9) + (8 x 6) + (9 x 3) + = 138

(7 x 8) + (8 x 5) + (9 x 2) + = 114

(7 x 7) + (8 x 4) + (9 x 1) + = 90

*****************

(9) + (12) + (9) + = 30

(8) + (10) + (6) + = 24

(7) + (8) + (3) + = 18

(36) + (30) + (18) + = 84

(32) + (25) + (12) + = 69

(28) + (20) + (6) + = 54

(63) + (48) + (27) + = 138

(56) + (40) + (18) + = 114

(49) + (32) + (9) + = 90

*****************************************************************

Regards!