Class Matrix_Calc
In: matrix_calc.f90

行列に関する基本的な計算を行うモジュール 各引数の型で同じ名前を呼び出せるように, interface で定義しておく.

Methods

Included Modules

Inter_Face

Public Instance methods

Function :recursive
res :real
a :real, dimension(2,2), intent(in)
: 2x2 の正方行列

2x2 の正方行列の行列式を計算する関数(実数版)

[Source]

recursive function determ_2d_f( a ) result(res)
! 2x2 の正方行列の行列式を計算する関数(実数版)
  use Inter_Face
  implicit none
  real, dimension(2,2), intent(in) :: a  ! 2x2 の正方行列
  real :: res

  res=a(1,1)*a(2,2)-a(1,2)*a(2,1)

  return
end function
Function :recursive
res :integer
a :integer, dimension(2,2), intent(in)
: 2x2 の正方行列

2x2 の正方行列の行列式を計算する関数(整数版)

[Source]

recursive function determ_2d_i( a ) result(res)
! 2x2 の正方行列の行列式を計算する関数(整数版)
  use Inter_Face
  implicit none
  integer, dimension(2,2), intent(in) :: a  ! 2x2 の正方行列
  integer :: res

  res=a(1,1)*a(2,2)-a(1,2)*a(2,1)

  return
end function
Subroutine :
a :real, intent(inout), dimension(:,:)
: 入力行列
 行列成分の転置を返す(実数版)

[Source]

subroutine trans_mat_f( a )
!  行列成分の転置を返す(実数版)
  use Inter_Face
  implicit none
  real, intent(inout), dimension(:,:) :: a  ! 入力行列
  integer :: i, j, nx, ny
  real :: tmp

  nx=size(a,1)
  ny=size(a,2)

  do j=1,ny
     do i=1,nx
        if(i<j)then
           tmp=a(j,i)
           a(j,i)=a(i,j)
           a(i,j)=tmp
        end if
     end do
  end do

end subroutine
Subroutine :
a :integer, intent(inout), dimension(:,:)
: 入力行列
 行列成分の転置を返す

[Source]

subroutine trans_mat_i( a )
!  行列成分の転置を返す
  use Inter_Face
  implicit none
  integer, intent(inout), dimension(:,:) :: a  ! 入力行列
  integer :: i, j, tmp, nx, ny

  nx=size(a,1)
  ny=size(a,2)

  do j=1,ny
     do i=1,nx
        if(i<j)then
           tmp=a(j,i)
           a(j,i)=a(i,j)
           a(i,j)=tmp
        end if
     end do
  end do

end subroutine