1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| program main
implicit none
integer :: i
integer, parameter :: n= 4
integer, dimension(:), allocatable :: v, res
integer, dimension(:,:), allocatable :: m
! Matrice identite
allocate( m(n,n), v(n*n), res(n*n) )
v = 0; v(1:n*n:n+1) = 1
m = reshape( source= v, shape= shape(m) )
print '(a)', 'La matrice :'
do i = 1, size(m,1)
print '(99i2)', m(i,:)
enddo
! Le vecteur
v = (/ (i, i = 1, n) /)
print '(/a)', 'Le vecteur :'
print '(i2)', v
! Le produit matriciel
res = matmul(m,v)
print '(/a)', 'Le produit matrice par vecteur :'
print '(i2)', res
deallocate( v, m, res )
end program main |
Partager