function tracef(M)
implicit none
integer::i
real(kind=8), dimension(:,:), intent(in)::M
real(kind=8)::tracef
tracef=0
if ( size(M(:,1)) /= size(M(1,:)) ) then
print*,"Error in tracef: You have to put a square table"
else
do i=1, size(M(1,:))
tracef = tracef + M(i,i)
end do
endif
end function tracef
subroutine factorielle(n, fact)
implicit none
integer::n_1
integer, intent(in)::n
integer, intent(out)::fact
if ( n == 0 ) then
fact = 1
else
n_1 = n - 1
call factorielle(n_1, fact)
fact = n * fact
endif
end subroutine factorielle
program principal
implicit none
integer::i, j, k, n, fact
real(kind=8)::bignumber, trace, determinant
real(kind=8), dimension(:), allocatable::A
real(kind=8), dimension(:,:), allocatable::matrice, matrice2, matchol
interface
function tracef(M)
real(kind=8), dimension(:,:), intent(in)::M
real(kind=8)::tracef
end function tracef
end interface
read*,n
allocate(A(n), matrice2(n,n), matrice(n,n), matchol(n,n))
do i = 1, n
A(i) = i
!!$ print*,A(i)
do j = 1,n
matrice(i,j) = i * j
end do
print*,matrice(i,:)
end do
trace=tracef(matrice)
print*,"La trace est : ",trace
deallocate(A, matrice2, matrice, matchol)
call factorielle(n, fact)
print*,"Factorielle de ",n," = ",fact
end program principal