Skip to content
Snippets Groups Projects
Commit 868c793a authored by Martin Beseda's avatar Martin Beseda
Browse files

ENH: Enhanced formatting in module connection_m

parent 7faceb58
No related branches found
No related tags found
No related merge requests found
...@@ -70,23 +70,6 @@ module connection_m ...@@ -70,23 +70,6 @@ module connection_m
end type connection_t end type connection_t
!> Represents a connection between two neurons.
!! Able to pass a signal from an input neuron to
!! an output one.
type, extends(connection_t) :: interval_connection_t
contains
!> Passes (assigns) the product
!! input neuron state * weight)
!! to an output neuron.
!! @todo Rewrite implementation to "interval"
procedure :: pass_signal => pass_signal_interval_impl
end type interval_connection_t
!------------!------------------------------------------------------------------------------
! Interfaces !
!------------!
interface connection_t interface connection_t
!> Constructor of connection_t class !> Constructor of connection_t class
!! @param input_neuron Pointer to the input neuron (instance of neuron_t) !! @param input_neuron Pointer to the input neuron (instance of neuron_t)
...@@ -100,6 +83,20 @@ module connection_m ...@@ -100,6 +83,20 @@ module connection_m
module procedure :: new_connection_3 module procedure :: new_connection_3
end interface connection_t end interface connection_t
!> Represents a connection between two neurons.
!! Able to pass a signal from an input neuron to
!! an output one.
type, extends(connection_t) :: interval_connection_t
contains
!> Passes (assigns) the product
!! input neuron state * weight)
!! to an output neuron.
!! @todo Rewrite implementation to "interval"
procedure :: pass_signal => pass_signal_interval_impl
end type interval_connection_t
interface interval_connection_t interface interval_connection_t
!> Constructor of interval_connection_t class !> Constructor of interval_connection_t class
!! @param input_neuron Pointer to the input neuron (instance of neuron_t) !! @param input_neuron Pointer to the input neuron (instance of neuron_t)
...@@ -167,6 +164,82 @@ module connection_m ...@@ -167,6 +164,82 @@ module connection_m
#endif #endif
end function new_connection_3 end function new_connection_3
!-------------!--------------------------------------------------------------------------
! Destructors !
!-------------!
subroutine destroy_connection(this)
type(connection_t), intent(inout) :: this
#ifdef TIME_PROFILING
real :: start_time
call time_profiling_start(start_time)
#endif
call this%nullify_pointers()
#ifdef TIME_PROFILING
call time_profiling_start(start_time, 'destroy_connection')
#endif
end subroutine destroy_connection
subroutine destroy_connection_array(this)
type(connection_t), intent(inout) :: this(:)
integer :: i
#ifdef TIME_PROFILING
real :: start_time
call time_profiling_start(start_time)
#endif
do i = 1, size(this)
call this(i)%nullify_pointers()
end do
#ifdef TIME_PROFILING
call time_profiling_stop(start_time, 'destroy_connection_array')
#endif
end subroutine destroy_connection_array
!-------------------!-------------------------------------------------------------------
! Getters & Setters !
!-------------------!
function get_input_neuron_impl(this) result (input_neuron)
class(connection_t), target, intent(in) :: this
class(neuron_t), pointer :: input_neuron
#ifdef TIME_PROFILING
real :: start_time
call time_profiling_start(start_time)
#endif
input_neuron => this%input_neuron
#ifdef TIME_PROFILING
call time_profiling_stop(start_time,'get_input_neuron_impl')
#endif
end function get_input_neuron_impl
function get_output_neuron_impl(this) result (output_neuron)
class(connection_t), target, intent(in) :: this
class(neuron_t), pointer :: output_neuron
#ifdef TIME_PROFILING
real :: start_time
call time_profiling_start(start_time)
#endif
output_neuron => this%output_neuron
#ifdef TIME_PROFILING
call time_profiling_stop(start_time, 'get_output_neuron_impl')
#endif
end function get_output_neuron_impl
function get_weight_impl(this) result (weight)
class(connection_t), intent(in) :: this
real :: weight
#ifdef TIME_PROFILING
real :: start_time
call time_profiling_start(start_time)
#endif
weight = this%weight
#ifdef TIME_PROFILING
call time_profiling_stop(start_time, 'get_weight_impl')
#endif
end function get_weight_impl
!----------------!-------------------------------------------------------------------------
! Common methods !
!----------------!
subroutine init_components_impl(this, input_neuron, output_neuron, weight) subroutine init_components_impl(this, input_neuron, output_neuron, weight)
class(connection_t), intent(inout) :: this class(connection_t), intent(inout) :: this
type(neuron_t), pointer :: input_neuron type(neuron_t), pointer :: input_neuron
...@@ -225,37 +298,6 @@ module connection_m ...@@ -225,37 +298,6 @@ module connection_m
#endif #endif
end subroutine pass_signal_impl end subroutine pass_signal_impl
!-------------!--------------------------------------------------------------------------
! Destructors !
!-------------!
subroutine destroy_connection(this)
type(connection_t), intent(inout) :: this
#ifdef TIME_PROFILING
real :: start_time
call time_profiling_start(start_time)
#endif
call this%nullify_pointers()
#ifdef TIME_PROFILING
call time_profiling_start(start_time, 'destroy_connection')
#endif
end subroutine destroy_connection
subroutine destroy_connection_array(this)
type(connection_t), intent(inout) :: this(:)
integer :: i
#ifdef TIME_PROFILING
real :: start_time
call time_profiling_start(start_time)
#endif
do i = 1, size(this)
call this(i)%nullify_pointers()
end do
#ifdef TIME_PROFILING
call time_profiling_stop(start_time, 'destroy_connection_array')
#endif
end subroutine destroy_connection_array
!-----------------------------! !-----------------------------!
! class interval_connection_t ! ! class interval_connection_t !
!-----------------------------! !-----------------------------!
...@@ -312,48 +354,6 @@ module connection_m ...@@ -312,48 +354,6 @@ module connection_m
#endif #endif
end function new_interval_connection_3 end function new_interval_connection_3
!-------------------!-------------------------------------------------------------------
! Getters & Setters !
!-------------------!
function get_input_neuron_impl(this) result (input_neuron)
class(connection_t), target, intent(in) :: this
class(neuron_t), pointer :: input_neuron
#ifdef TIME_PROFILING
real :: start_time
call time_profiling_start(start_time)
#endif
input_neuron => this%input_neuron
#ifdef TIME_PROFILING
call time_profiling_stop(start_time,'get_input_neuron_impl')
#endif
end function get_input_neuron_impl
function get_output_neuron_impl(this) result (output_neuron)
class(connection_t), target, intent(in) :: this
class(neuron_t), pointer :: output_neuron
#ifdef TIME_PROFILING
real :: start_time
call time_profiling_start(start_time)
#endif
output_neuron => this%output_neuron
#ifdef TIME_PROFILING
call time_profiling_stop(start_time, 'get_output_neuron_impl')
#endif
end function get_output_neuron_impl
function get_weight_impl(this) result (weight)
class(connection_t), intent(in) :: this
real :: weight
#ifdef TIME_PROFILING
real :: start_time
call time_profiling_start(start_time)
#endif
weight = this%weight
#ifdef TIME_PROFILING
call time_profiling_stop(start_time, 'get_weight_impl')
#endif
end function get_weight_impl
end module connection_m end module connection_m
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment