matrix_analysis.f90

This example show how use matricial analysis with the matrix module. More details about this example.

00001 
00014 program matrix_analysis
00015 
00016  use mod_matrix         ! use matrix module
00017 
00018 #include "fml_constants.h"
00019   implicit none
00020   !********************************************* declaration  
00021   integer :: m2_rows = 4, m2_cols = 5 !size of m1
00022   integer :: m3_rows = 5, m3_cols = 5 !size of m1
00023   ! declaration of matrix m2
00024   type(matrix) :: m2;  
00025   ! declaration of matrix m3
00026   type(matrix) :: m3;  
00027   ! declaration of matrix m_res
00028   type(matrix) :: m_res;    
00029 
00030   !********************************************* body
00031   !indication:   p_notcast is defined in fml_constants.h (adapt the format)
00032   ! init of a matrix m3 
00033   call init(m3,m3_rows,m3_cols);    !init:=m_init  
00034   ! init of a matrix m2 
00035   call init(m2,m2_rows,m2_cols);    !init:=m_init     
00036     
00037   !initialize m1 by random values between 1.0 and 10.0
00038   call random(m2,low=p_notcast(1.0),high=p_notcast(10.0))  !random:=vc_random
00039   !initialize m3 by random values between 2.0 and 6.0  
00040   call mc_diagDominant(m3,m3_rows,low=p_notcast(1.0),high=p_notcast(1.5))  !dominant diagonal
00041 
00042   print*, "********************************************* display initial data"
00043   print*; !newline 
00044 
00045   print*, "m2=";  
00046   call print(m2);  !print m2  (print:=m_print)  
00047   print*, "m3=";  
00048   call print(m3);  !print m3  (print:=m_print)  
00049 
00050   print*, "********************************************* matrix mathematics proprieties" 
00051       
00052   print*, ">>>> determinant of m3 by gauss-jourdan=", det(m3) !or .det.m3 fo gauss-jourdan method
00053   !determinant by lu decomposition
00054   print*, ">>>> determinant of m3 by lu decomposition=", det(m3,meth_det='lu') 
00055  
00056   print*, ">>>> rank of m2 by gauss-jourdan=", rank(m2) !or .rank.m2 fo gauss-jourdan method
00057   !determinant by  svd decomposition
00058   print*, ">>>> rank of m2 by lu decomposition=", rank(m2,meth_rk='svd') 
00059   !determinant by  gauss-jourdan decomposition
00060   print*, ">>>> rank of m3 by gauss-jourdan method=", rank(m3,meth_rk='gj')  
00061    
00062   print*;print*, "... ... ... ... ... ... ... deallocate matrix"   
00063   call destruct(m2)  ! destruct the matrix m2 (don't forget to destruct the matrix)
00064   call destruct(m3)  ! destruct the matrix m3
00065   call destruct(m_res)  ! destruct the matrix m_res
00066   print*;
00067 end program matrix_analysis
 All Classes Namespaces Files Functions Variables Defines