matrix_eigenvalvect.f90

This example show how calculate eigen values and vectors with the matrix module. More details about this example.

00001 
00014 program matrix_eigenvalvect
00015 #include "fml_constants.h" 
00016  use mod_matrix     ! use matrix module
00017   implicit none
00018 
00019   !********************************************* declaration  
00020   integer, parameter :: A_rows = 4, A_cols = 4 !size of A
00021   ! declaration of matrix A
00022   type(matrix) :: A;  
00023   type(t_poweig) :: poweig !power eigen value
00024   type(t_eig) :: eigvalvect !eigen value and vectors
00025   !********************************************* body
00026   
00027   ! init of a matrix A 
00028   call init(A,A_rows,A_cols);   !init:=m_init
00029   !initialize A by random values between 1.0 and 10.0
00030   call random(A,low=p_notcast(1.0),high=p_notcast(10.0))   !random:=mc_random
00031     
00032   print*; !newline
00033   print*,"* A=";
00034   call print(A);   !print A  (print:=m_print)
00035   print*, "********************************************* power eigen value"  
00036   poweig=m_pow_eig(A,eps=p_notcast(1.e-5),iter_max=500) !error precision = 1.e-5
00037   print*, ">>>>>>>>>>>>>>> power eigenvalue = ", poweig%lambda,  & 
00038                         " obtains after ", poweig%iter, "iterations" 
00039   print*, ">>>>>>>>>>>>>>> correspondance eigenvector = " 
00040   call print(poweig%v_lambda)
00041   print*, ">>>>>>>>>>>>>>> iteration errors = " 
00042   call print(poweig%v_err)
00043   print*; !newline
00044   
00045   print*, "********************* eigen value and vector (deflation method), not work now"      
00046   eigvalvect=m_eig_deflation(A,eps=p_notcast(1.e-5),iter_max=500)  !deflation method
00047   print*, ">>>>>>>>>>>>>>> eigenvalues = " 
00048   call print(eigvalvect%v_eigvalues)
00049   print*, ">>>>>>>>>>>>>>> eigenvectors = "
00050   call print(eigvalvect%m_eigvectors)
00051   
00052   print*; !newline
00053       
00054    call destruct(A)  ! destruct the matrix A  (don't forget to destruct the matrix)
00055    call destruct(poweig)
00056    call destruct(eigvalvect)
00057 end program matrix_eigenvalvect
 All Classes Namespaces Files Functions Variables Defines