find_best_match_unit Subroutine

public subroutine find_best_match_unit(kohonen_map, current_prototype, ihit, jhit, khit, dist_hit)

Subroutine to calculate the best match unit

Type Bound

two_level_self_organizing_map

Arguments

Type IntentOptional Attributes Name
class(two_level_self_organizing_map) :: kohonen_map

A two_level_self_organizing_map object

type(kohonen_prototype), intent(inout) :: current_prototype

A kohonen_prototype object

integer, intent(out) :: ihit

Integer variables

integer, intent(out) :: jhit

Integer variables

integer, intent(out) :: khit

Integer variables

real(kind=wp), intent(out) :: dist_hit

A real variable


Calls

proc~~find_best_match_unit~2~~CallsGraph proc~find_best_match_unit~2 two_level_self_organizing_map%find_best_match_unit float float proc~find_best_match_unit~2->float none~distance~8 kohonen_prototype%distance proc~find_best_match_unit~2->none~distance~8 calculate calculate none~distance~8->calculate none~get_prototype kohonen_prototype%get_prototype none~distance~8->none~get_prototype

Variables

Type Visibility Attributes Name Initial
integer, public :: debug_option
integer, public :: idbg
integer, public :: ix
integer, public :: iy
integer, public :: iz
integer, public :: number_variables
real(kind=wp), public :: dist

Source Code

   subroutine find_best_match_unit(kohonen_map,current_prototype,ihit,jhit,khit,dist_hit)
   !========================================================================================
!!    Subroutine to calculate the best match unit  
      class(two_level_self_organizing_map) :: kohonen_map
!! A `two_level_self_organizing_map` object
      type(kohonen_prototype),intent(inout) :: current_prototype
!! A `kohonen_prototype` object
      integer,intent(out) :: ihit,jhit,khit
!! Integer variables
      real(kind=wp),intent(out) :: dist_hit
!! A real variable
      integer :: debug_option,idbg,ix,iy,iz,number_variables
      real(kind=wp) :: dist
   !
      idbg=kohonen_map%parameters(1)%idbg;
      debug_option=kohonen_map%parameters(1)%debug_level;
      number_variables=kohonen_map%parameters(1)%number_variables1*kohonen_map%parameters(1)%number_variables2
      ihit = 0;
      jhit = 0;
      khit = 0;
      dist_hit = 1.0e6;
      do iz = 1, size(kohonen_map%grid,3)  
         do iy = 1, size(kohonen_map%grid,2)
            do ix = 1,size(kohonen_map%grid,1)
               dist = 0.0_wp;
               dist=kohonen_map%grid(ix,iy,iz)%distance(current_prototype,kohonen_map%distance_function);
               if(debug_option .gt. 0) then
                  call kohonen_map%grid(ix,iy,iz)%print(idbg)
                  write(idbg,*) ix,iy,iz,dist
               endif
               dist = dist/float(number_variables);
               if (dist .lt. dist_hit) then
                  dist_hit = dist
                  ihit = ix
                  jhit = iy
                  khit = iz
                  !write(*,*)' fbmu= ',ihit,jhit,khit,dist
               endif
            enddo!ix
         enddo!iy
      enddo!iz
   !
   return
   !
   end subroutine find_best_match_unit