module Matice

! Modul pro vytvo5en9 jednotkov0 matice

use std_type

implicit none
private

public :: JednotkovaM,JednotkovaM_I,JednotkovaM_SP,JednotkovaM_DP

interface JednotkovaM
    module procedure JednotkovaM_I,JednotkovaM_SP,JednotkovaM_DP
end interface


contains

subroutine JednotkovaM_I (dimA,A)
    integer,intent(in) :: dimA
    integer,dimension(:,:),intent(out) :: A
    
    integer :: i,j
    
    do i = 1,dimA
        do j = 1,dimA
            if (i==j) then
                A(i,j) = 1
            else
                A(i,j) = 0
            end if
        end do
    end do

end subroutine JednotkovaM_I

subroutine JednotkovaM_SP (dimA,A)
    integer,intent(in) :: dimA
    real(kind=SP),dimension(:,:),intent(out) :: A
    
    integer :: i,j
    
    do i = 1,dimA
        do j = 1,dimA
            if (i==j) then
                A(i,j) = 1
            else
                A(i,j) = 0
            end if
        end do
    end do

end subroutine JednotkovaM_SP

subroutine JednotkovaM_DP (dimA,A)
    integer,intent(in) :: dimA
    real(kind=DP),dimension(:,:),intent(out) :: A
    
    integer :: i,j
    
    do i = 1,dimA
        do j = 1,dimA
            if (i==j) then
                A(i,j) = 1
            else
                A(i,j) = 0
            end if
        end do
    end do

end subroutine JednotkovaM_DP


end module Matice
