-
git-svn-id: https://lxsd.femto-st.fr/svn/fvn@59 b657c933-2333-4658-acf2-d3c7c2708721
test_matinv.f90
856 Bytes
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
31
32
33
34
35
36
37
38
program test_matinv
use fvn_linear
implicit none
integer(kind=ip_kind), parameter :: n=3
integer(kind=ip_kind) :: status,i
complex(kind=dp_kind),dimension(n,n) :: m,im,prod
real(kind=dp_kind),dimension(n,n) :: rtmp,itmp
character(len=80) :: fmreal,fmcmplx
fmcmplx='(3("(",f8.5,",",f8.5,") "))'
! initialize pseudo random generator
call init_random_seed()
! fill real and imaginary part
call random_number(rtmp)
call random_number(itmp)
! create the complex matrix (fvn_i is defined in the fvn module)
m=rtmp+fvn_i*itmp
write(*,*) "Matrix M"
do i=1,n
write(*,fmcmplx) m(i,:)
end do
! Invertion
call fvn_matinv(n,m,im)
write(*,*) "Inverse of M"
do i=1,n
write(*,fmcmplx) im(i,:)
end do
! Result should be identity matrix
write(*,*) "Product of M and inverse of M :"
prod=matmul(m,im)
do i=1,n
write (*,fmcmplx) prod(i,:)
end do
end program