Subroutine to calculate the best match unit
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(self_organizing_map) | :: | kohonen_map |
A |
|||
type(kohonen_prototype), | intent(inout) | :: | current_prototype |
A |
||
integer, | intent(out) | :: | ihit |
Integer variables for the coordinates of the BMU |
||
integer, | intent(out) | :: | jhit |
Integer variables for the coordinates of the BMU |
||
integer, | intent(out) | :: | khit |
Integer variables for the coordinates of the BMU |
||
real(kind=wp), | intent(out) | :: | dist_hit |
Real variable with the distance to the BMU |
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 |
subroutine find_best_match_unit(kohonen_map,current_prototype,ihit,jhit,khit,dist_hit) !======================================================================================== !! Subroutine to calculate the best match unit class(self_organizing_map) :: kohonen_map !! A `self_organizing_map` object type(kohonen_prototype),intent(inout) :: current_prototype !! A `kohonen_prototype` object integer,intent(out) :: ihit,jhit,khit !! Integer variables for the coordinates of the BMU real(kind=wp),intent(out) :: dist_hit !! Real variable with the distance to the BMU integer :: debug_option,idbg,ix,iy,iz,number_variables real(kind=wp) :: dist ! idbg=kohonen_map%parameters%idbg; debug_option=kohonen_map%parameters%debug_level; number_variables=kohonen_map%parameters%number_variables1*& kohonen_map%parameters%number_variables2 ihit = 0; jhit = 0; khit = 0; dist_hit = 1.0e7; !$OMP parallel do 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); !write(*,*) 'dist= ',dist if(debug_option > 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 < dist_hit) then dist_hit = dist; ihit = ix; jhit = iy; khit = iz; endif enddo!ix enddo!iy enddo!iz !$OMP end parallel do ! ! write(*,*) 'find= ',ihit,jhit,khit,dist_hit return ! end subroutine find_best_match_unit