Commit cb0fb526 authored by Martin Beseda's avatar Martin Beseda
Browse files

ENH: Added an array desctructor to the class connection_t.

parent ef73e2ab
......@@ -9,6 +9,7 @@
!! @todo Change generating random connection weights from uniform to Gaussian distribution
module connection_m
use neuron_dummy_m
use time_measurement_m
implicit none
......@@ -58,8 +59,8 @@ module connection_m
!! @return Weight of the connection (type real)
procedure :: get_weight => get_weight_impl
!> Desctructor for instances of the class connection_t
final :: destroy_connection
!> Desctructors for instances of the class connection_t
final :: destroy_connection, destroy_connection_array
end type connection_t
......@@ -113,6 +114,10 @@ module connection_m
!--------------------!
! class connection_t !
!--------------------!
!--------------!----------------------------------------------------------------------------
! Constructors !
!--------------!
function new_connection_2(input_neuron, output_neuron) result(new_obj)
type(neuron_t), pointer, intent(in) :: input_neuron
type(neuron_t), pointer, intent(in) :: output_neuron
......@@ -147,8 +152,8 @@ module connection_m
real, intent(in) :: weight
#ifdef TIME_PROFILING
real :: t1, t2 !< Variables used for time measurement
call cpu_time(t1)
real :: start_time
call time_profiling_start(start_time);
#endif
this%input_neuron => input_neuron
......@@ -157,10 +162,7 @@ module connection_m
#ifdef TIME_PROFILING
call cpu_time(t2)
write(*, "(A)") '+----------------+'
write(*, "(A, E15.7, A)") '| TIME PROFILING | Function init_components() was running for ', t2-t1, 's.'
write(*, "(A)") '+----------------+'
call time_profiling_stop(start_time, 'init_components_impl');
#endif
end subroutine init_components_impl
......@@ -178,12 +180,25 @@ module connection_m
this%weight = this%weight + added_value
end subroutine adjust_weight_impl
!-------------!--------------------------------------------------------------------------
! Destructors !
!-------------!
subroutine destroy_connection(this)
type(connection_t), intent(inout) :: this
call this%nullify_pointers()
end subroutine destroy_connection
subroutine destroy_connection_array(this)
type(connection_t), intent(inout) :: this(:)
integer :: i
do i = 1, size(this)
call this(i)%nullify_pointers()
end do
end subroutine destroy_connection_array
!-----------------------------!
! class interval_connection_t !
!-----------------------------!
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment