FISH.





Warning: include() [function.include]: URL file-access is disabled in the server configuration in /home/virtwww/w_beloshenko-org-ua_e2c5fc46/http/topp.php on line 8

Warning: include(http://www.beloshenko.org.ua/panel.html) [function.include]: failed to open stream: no suitable wrapper could be found in /home/virtwww/w_beloshenko-org-ua_e2c5fc46/http/topp.php on line 8

Warning: include() [function.include]: Failed opening 'http://www.beloshenko.org.ua/panel.html' for inclusion (include_path='.:') in /home/virtwww/w_beloshenko-org-ua_e2c5fc46/http/topp.php on line 8







Matrix multiplication. (FORTRAN)

Beloshenko + 2007
----------------------------------------------------------------------------------------
Matrix.for

Matrix multiplication
program MATRIX
integer A(50,50), B(50,50), C(50,50)

integer m,n,k,l,g,z
real sum

c Input data from the file MatrixIn.txt
open(unit=1,file='MatrixIn.txt',status='OLD')
open(unit=2,file='MOut.txt',status='OLD')

read(1,*)(m)
read(1,*)(n)
read(1,*)((A(i,j),j=1,n),i=1,m)
read(1,*)(k)
read(1,*)(l)
read(1,*)((B(i,j),j=1,l),i=1,k)

c Test matrix
c m=3
c n=2
c A(1,1)=1
c A(1,2)=2
c A(2,1)=3
c A(2,2)=4
c A(3,1)=5
c A(3,2)=6
c
c k=2
c l=2
c B(1,1)=2
c B(1,2)=1
c B(2,1)=1
c B(2,2)=3
c
c Module test
c C(1,1)=4
c C(1,2)=7
c C(2,1)=10
c C(2,2)=15
c C(3,1)=16
c C(3,2)=23


c Is matrix spriyageni?
if(n.NE.k)go to 1

c Matrix multiplication
do 2 i=1,m
do 3 j=1,l
sum=0
do 4 g=1,n
c Multiplication "ryadok na stovpchik".
sum=sum+A(i,g)*B(g,j)
4 continue
C(i,j)=sum
3 continue
2 continue


1 continue

c Output data to file MOut.txt
write(2,5)m
5 format(I3)
write(2,6)l
6 format(I3)

do 7 r=1,m
write(2,9)(C(r,i),i=1,l)
9 format(I3,I3,I3,I3,I3,I3,I3,I3,I3,I3,I3)



7 continue

c Close files
close(1)
close(2)

end

---------------------------------------------------------------------------------
MatrixIn.txt

3
2

1
2
3
4
5
6

2
2

2
1
1
3

--------------------------------------------------------------------------------
MOut.txt

3
2
4 7
10 15
16 23


FREE VIRAL OF YOU SITE.

 









Click Here for Free Traffic!

FISH.