Blame view

fvn_test/test_matinv.f90 856 Bytes
27d3b84d6   daniau   git-svn-id: https...
1
  program test_matinv
2919a9e2d   daniau   git-svn-id: https...
2
  use fvn_linear
27d3b84d6   daniau   git-svn-id: https...
3
  implicit none
f6bacaf83   cwaterkeyn   ChW 11/09: ANSI c...
4
5
6
7
  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
27d3b84d6   daniau   git-svn-id: https...
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
  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