From 91e7b686873dee0c773ed410977a48c7a470ceb1 Mon Sep 17 00:00:00 2001 From: Jan Vogelsang Date: Mon, 17 Oct 2022 14:28:54 +0200 Subject: [PATCH 1/3] Converted C-style casts to static_casts --- libnestutil/numerics.cpp | 2 +- libnestutil/stopwatch.h | 4 +-- models/ac_generator.cpp | 2 +- models/aeif_cond_alpha.cpp | 2 +- models/aeif_cond_alpha_multisynapse.cpp | 4 +-- models/aeif_cond_beta_multisynapse.cpp | 4 +-- models/aeif_cond_exp.cpp | 2 +- models/aeif_psc_alpha.cpp | 2 +- models/aeif_psc_delta.cpp | 2 +- models/aeif_psc_delta_clopath.cpp | 2 +- models/aeif_psc_exp.cpp | 2 +- models/amat2_psc_exp.cpp | 2 +- models/binary_neuron.h | 2 +- models/cm_default.cpp | 4 +-- models/dc_generator.cpp | 2 +- models/gamma_sup_generator.cpp | 2 +- models/gif_cond_exp.cpp | 2 +- models/gif_cond_exp_multisynapse.cpp | 4 +-- models/gif_pop_psc_exp.cpp | 4 +-- models/gif_psc_exp.cpp | 2 +- models/gif_psc_exp_multisynapse.cpp | 4 +-- models/hh_cond_beta_gap_traub.cpp | 16 ++++----- models/hh_cond_exp_traub.cpp | 2 +- models/hh_psc_alpha.cpp | 14 ++++---- models/hh_psc_alpha_clopath.cpp | 2 +- models/hh_psc_alpha_gap.cpp | 2 +- models/ht_neuron.cpp | 2 +- models/iaf_chs_2007.cpp | 2 +- models/iaf_chxk_2008.cpp | 2 +- models/iaf_cond_alpha.cpp | 2 +- models/iaf_cond_alpha_mc.cpp | 2 +- models/iaf_cond_beta.cpp | 2 +- models/iaf_cond_exp.cpp | 2 +- models/iaf_cond_exp_sfa_rr.cpp | 2 +- models/iaf_psc_alpha.cpp | 2 +- models/iaf_psc_alpha_multisynapse.cpp | 2 +- models/iaf_psc_delta.cpp | 2 +- models/iaf_psc_exp.cpp | 2 +- models/iaf_psc_exp_htum.cpp | 2 +- models/iaf_psc_exp_multisynapse.cpp | 2 +- models/inhomogeneous_poisson_generator.cpp | 2 +- models/izhikevich.cpp | 2 +- models/mat2_psc_exp.cpp | 2 +- models/noise_generator.cpp | 2 +- models/parrot_neuron.cpp | 2 +- models/poisson_generator.cpp | 2 +- models/poisson_generator_ps.cpp | 2 +- models/pp_cond_exp_mc_urbanczik.cpp | 4 +-- models/pp_pop_psc_delta.cpp | 2 +- models/pp_psc_delta.cpp | 2 +- models/ppd_sup_generator.cpp | 4 +-- models/rate_neuron_ipn_impl.h | 2 +- models/rate_neuron_opn_impl.h | 2 +- models/rate_transformer_node_impl.h | 2 +- models/siegert_neuron.cpp | 2 +- models/sinusoidal_gamma_generator.cpp | 2 +- models/sinusoidal_poisson_generator.cpp | 2 +- models/step_current_generator.cpp | 2 +- models/step_rate_generator.cpp | 2 +- nestkernel/connection_creator_impl.h | 10 +++--- nestkernel/event_delivery_manager.cpp | 4 +-- nestkernel/layer_impl.h | 2 +- nestkernel/model.cpp | 2 +- nestkernel/model.h | 2 +- nestkernel/model_manager.cpp | 2 +- nestkernel/ring_buffer.h | 24 ++++++------- nestkernel/simulation_manager.cpp | 6 ++-- nestkernel/slice_ring_buffer.h | 2 +- sli/interpret.cc | 2 +- sli/scanner.cc | 2 +- sli/sliarray.cc | 38 ++++++++++---------- sli/slicontrol.cc | 10 +++--- sli/slidata.cc | 40 +++++++++++----------- sli/sligraphics.cc | 12 +++---- sli/tarrayobj.cc | 2 +- sli/tarrayobj.h | 4 +-- testsuite/cpptests/test_block_vector.h | 4 +-- 77 files changed, 165 insertions(+), 165 deletions(-) diff --git a/libnestutil/numerics.cpp b/libnestutil/numerics.cpp index b661142928..8eff885f2a 100644 --- a/libnestutil/numerics.cpp +++ b/libnestutil/numerics.cpp @@ -92,7 +92,7 @@ const double numerics::nan = 0.0 / 0.0; long ld_round( double x ) { - return ( long ) std::floor( x + 0.5 ); + return static_cast< long >( std::floor( x + 0.5 ) ); } double diff --git a/libnestutil/stopwatch.h b/libnestutil/stopwatch.h index 00091c7360..2072a533ff 100644 --- a/libnestutil/stopwatch.h +++ b/libnestutil/stopwatch.h @@ -71,7 +71,7 @@ class Stopwatch enum { - MICROSEC = ( timeunit_t ) 1, + MICROSEC = static_cast< timeunit_t >( 1 ), MILLISEC = MICROSEC * 1000, SECONDS = MILLISEC * 1000, MINUTES = SECONDS * 60, @@ -222,7 +222,7 @@ nest::Stopwatch::elapsed_timestamp() const return _end - _beg + _prev_elapsed; } #else - return ( timestamp_t ) 0; + return static_cast< timestamp_t >( 0 ); #endif } diff --git a/models/ac_generator.cpp b/models/ac_generator.cpp index 882ed3aa16..5e0788cbdb 100644 --- a/models/ac_generator.cpp +++ b/models/ac_generator.cpp @@ -202,7 +202,7 @@ nest::ac_generator::pre_run_hook() void nest::ac_generator::update( Time const& origin, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); long start = origin.get_steps(); diff --git a/models/aeif_cond_alpha.cpp b/models/aeif_cond_alpha.cpp index 1d2be29e75..03edf76a9d 100644 --- a/models/aeif_cond_alpha.cpp +++ b/models/aeif_cond_alpha.cpp @@ -448,7 +448,7 @@ nest::aeif_cond_alpha::pre_run_hook() void nest::aeif_cond_alpha::update( Time const& origin, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); assert( State_::V_M == 0 ); diff --git a/models/aeif_cond_alpha_multisynapse.cpp b/models/aeif_cond_alpha_multisynapse.cpp index 837980fad5..86b8c525e1 100644 --- a/models/aeif_cond_alpha_multisynapse.cpp +++ b/models/aeif_cond_alpha_multisynapse.cpp @@ -486,7 +486,7 @@ aeif_cond_alpha_multisynapse::pre_run_hook() void aeif_cond_alpha_multisynapse::update( Time const& origin, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); assert( State_::V_M == 0 ); @@ -592,7 +592,7 @@ aeif_cond_alpha_multisynapse::handle( SpikeEvent& e ) "must be positive." ); } assert( e.get_delay_steps() > 0 ); - assert( ( e.get_rport() > 0 ) and ( ( size_t ) e.get_rport() <= P_.n_receptors() ) ); + assert( ( e.get_rport() > 0 ) and ( static_cast< size_t >( e.get_rport() ) <= P_.n_receptors() ) ); B_.spikes_[ e.get_rport() - 1 ].add_value( e.get_rel_delivery_steps( kernel().simulation_manager.get_slice_origin() ), e.get_weight() * e.get_multiplicity() ); diff --git a/models/aeif_cond_beta_multisynapse.cpp b/models/aeif_cond_beta_multisynapse.cpp index 627e396767..83f56f9c7d 100644 --- a/models/aeif_cond_beta_multisynapse.cpp +++ b/models/aeif_cond_beta_multisynapse.cpp @@ -495,7 +495,7 @@ aeif_cond_beta_multisynapse::pre_run_hook() void aeif_cond_beta_multisynapse::update( Time const& origin, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); assert( State_::V_M == 0 ); @@ -601,7 +601,7 @@ aeif_cond_beta_multisynapse::handle( SpikeEvent& e ) "must be positive." ); } assert( e.get_delay_steps() > 0 ); - assert( ( e.get_rport() > 0 ) and ( ( size_t ) e.get_rport() <= P_.n_receptors() ) ); + assert( ( e.get_rport() > 0 ) and ( static_cast< size_t >( e.get_rport() ) <= P_.n_receptors() ) ); B_.spikes_[ e.get_rport() - 1 ].add_value( e.get_rel_delivery_steps( kernel().simulation_manager.get_slice_origin() ), e.get_weight() * e.get_multiplicity() ); diff --git a/models/aeif_cond_exp.cpp b/models/aeif_cond_exp.cpp index 5bdeef5b46..4fe21f0c18 100644 --- a/models/aeif_cond_exp.cpp +++ b/models/aeif_cond_exp.cpp @@ -441,7 +441,7 @@ nest::aeif_cond_exp::pre_run_hook() void nest::aeif_cond_exp::update( const Time& origin, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); assert( State_::V_M == 0 ); diff --git a/models/aeif_psc_alpha.cpp b/models/aeif_psc_alpha.cpp index 37b45b808b..755714fa68 100644 --- a/models/aeif_psc_alpha.cpp +++ b/models/aeif_psc_alpha.cpp @@ -438,7 +438,7 @@ nest::aeif_psc_alpha::pre_run_hook() void nest::aeif_psc_alpha::update( Time const& origin, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); assert( State_::V_M == 0 ); diff --git a/models/aeif_psc_delta.cpp b/models/aeif_psc_delta.cpp index fe69f51d23..fd8e8e9283 100644 --- a/models/aeif_psc_delta.cpp +++ b/models/aeif_psc_delta.cpp @@ -416,7 +416,7 @@ nest::aeif_psc_delta::pre_run_hook() void nest::aeif_psc_delta::update( const Time& origin, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); assert( State_::V_M == 0 ); const double h = Time::get_resolution().get_ms(); diff --git a/models/aeif_psc_delta_clopath.cpp b/models/aeif_psc_delta_clopath.cpp index e247a30f07..45d0d2d0f5 100644 --- a/models/aeif_psc_delta_clopath.cpp +++ b/models/aeif_psc_delta_clopath.cpp @@ -475,7 +475,7 @@ nest::aeif_psc_delta_clopath::pre_run_hook() void nest::aeif_psc_delta_clopath::update( const Time& origin, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); assert( State_::V_M == 0 ); diff --git a/models/aeif_psc_exp.cpp b/models/aeif_psc_exp.cpp index 78d390045b..92ba25b65b 100644 --- a/models/aeif_psc_exp.cpp +++ b/models/aeif_psc_exp.cpp @@ -431,7 +431,7 @@ nest::aeif_psc_exp::pre_run_hook() void nest::aeif_psc_exp::update( const Time& origin, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); assert( State_::V_M == 0 ); diff --git a/models/amat2_psc_exp.cpp b/models/amat2_psc_exp.cpp index 2b3cf7e0cb..7271be9a5a 100644 --- a/models/amat2_psc_exp.cpp +++ b/models/amat2_psc_exp.cpp @@ -366,7 +366,7 @@ nest::amat2_psc_exp::pre_run_hook() void nest::amat2_psc_exp::update( Time const& origin, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); // evolve from timestep 'from' to timestep 'to' with steps of h each diff --git a/models/binary_neuron.h b/models/binary_neuron.h index 3d34835411..b8733974b0 100644 --- a/models/binary_neuron.h +++ b/models/binary_neuron.h @@ -456,7 +456,7 @@ template < class TGainfunction > void binary_neuron< TGainfunction >::update( Time const& origin, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); for ( long lag = from; lag < to; ++lag ) diff --git a/models/cm_default.cpp b/models/cm_default.cpp index d3b6dc1240..0bf70e8104 100644 --- a/models/cm_default.cpp +++ b/models/cm_default.cpp @@ -290,7 +290,7 @@ nest::cm_default::pre_run_hook() void nest::cm_default::update( Time const& origin, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); for ( long lag = from; lag < to; ++lag ) @@ -322,7 +322,7 @@ nest::cm_default::handle( SpikeEvent& e ) } assert( e.get_delay_steps() > 0 ); - assert( ( e.get_rport() >= 0 ) and ( ( size_t ) e.get_rport() < syn_buffers_.size() ) ); + assert( ( e.get_rport() >= 0 ) and ( static_cast< size_t >( e.get_rport() ) < syn_buffers_.size() ) ); syn_buffers_[ e.get_rport() ].add_value( e.get_rel_delivery_steps( kernel().simulation_manager.get_slice_origin() ), e.get_weight() * e.get_multiplicity() ); diff --git a/models/dc_generator.cpp b/models/dc_generator.cpp index 58969140e3..a05d46c760 100644 --- a/models/dc_generator.cpp +++ b/models/dc_generator.cpp @@ -162,7 +162,7 @@ nest::dc_generator::pre_run_hook() void nest::dc_generator::update( Time const& origin, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); long start = origin.get_steps(); diff --git a/models/gamma_sup_generator.cpp b/models/gamma_sup_generator.cpp index 9763dc0b43..15ed2109be 100644 --- a/models/gamma_sup_generator.cpp +++ b/models/gamma_sup_generator.cpp @@ -232,7 +232,7 @@ nest::gamma_sup_generator::pre_run_hook() void nest::gamma_sup_generator::update( Time const& T, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); if ( P_.rate_ <= 0 or P_.num_targets_ == 0 ) diff --git a/models/gif_cond_exp.cpp b/models/gif_cond_exp.cpp index 95592e1424..21d85c3202 100644 --- a/models/gif_cond_exp.cpp +++ b/models/gif_cond_exp.cpp @@ -478,7 +478,7 @@ void nest::gif_cond_exp::update( Time const& origin, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); for ( long lag = from; lag < to; ++lag ) diff --git a/models/gif_cond_exp_multisynapse.cpp b/models/gif_cond_exp_multisynapse.cpp index 527d22c4ca..86116dac7b 100644 --- a/models/gif_cond_exp_multisynapse.cpp +++ b/models/gif_cond_exp_multisynapse.cpp @@ -480,7 +480,7 @@ void nest::gif_cond_exp_multisynapse::update( Time const& origin, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); for ( long lag = from; lag < to; ++lag ) @@ -595,7 +595,7 @@ nest::gif_cond_exp_multisynapse::handle( SpikeEvent& e ) "must be positive." ); } assert( e.get_delay_steps() > 0 ); - assert( ( e.get_rport() > 0 ) and ( ( size_t ) e.get_rport() <= P_.n_receptors() ) ); + assert( ( e.get_rport() > 0 ) and ( static_cast< size_t >( e.get_rport() ) <= P_.n_receptors() ) ); B_.spikes_[ e.get_rport() - 1 ].add_value( e.get_rel_delivery_steps( kernel().simulation_manager.get_slice_origin() ), e.get_weight() * e.get_multiplicity() ); diff --git a/models/gif_pop_psc_exp.cpp b/models/gif_pop_psc_exp.cpp index 6118ba4535..af2444590a 100644 --- a/models/gif_pop_psc_exp.cpp +++ b/models/gif_pop_psc_exp.cpp @@ -479,7 +479,7 @@ nest::gif_pop_psc_exp::get_history_size() } if ( k * V_.h_ <= P_.t_ref_ ) { - k = ( int ) ( P_.t_ref_ / V_.h_ ) + 1; + k = static_cast< int >( P_.t_ref_ / V_.h_ ) + 1; } return k; } @@ -488,7 +488,7 @@ nest::gif_pop_psc_exp::get_history_size() void nest::gif_pop_psc_exp::update( Time const& origin, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); for ( long lag = from; lag < to; ++lag ) diff --git a/models/gif_psc_exp.cpp b/models/gif_psc_exp.cpp index 4c7193d591..2f27dc6598 100644 --- a/models/gif_psc_exp.cpp +++ b/models/gif_psc_exp.cpp @@ -326,7 +326,7 @@ void nest::gif_psc_exp::update( Time const& origin, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); for ( long lag = from; lag < to; ++lag ) diff --git a/models/gif_psc_exp_multisynapse.cpp b/models/gif_psc_exp_multisynapse.cpp index a1508c6c77..55129019dd 100644 --- a/models/gif_psc_exp_multisynapse.cpp +++ b/models/gif_psc_exp_multisynapse.cpp @@ -348,7 +348,7 @@ void nest::gif_psc_exp_multisynapse::update( Time const& origin, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); for ( long lag = from; lag < to; ++lag ) @@ -431,7 +431,7 @@ void gif_psc_exp_multisynapse::handle( SpikeEvent& e ) { assert( e.get_delay_steps() > 0 ); - assert( ( e.get_rport() > 0 ) and ( ( size_t ) e.get_rport() <= P_.n_receptors_() ) ); + assert( ( e.get_rport() > 0 ) and ( static_cast< size_t >( e.get_rport() ) <= P_.n_receptors_() ) ); B_.spikes_[ e.get_rport() - 1 ].add_value( e.get_rel_delivery_steps( kernel().simulation_manager.get_slice_origin() ), e.get_weight() * e.get_multiplicity() ); diff --git a/models/hh_cond_beta_gap_traub.cpp b/models/hh_cond_beta_gap_traub.cpp index fc922f6bda..b9ac5dabf3 100644 --- a/models/hh_cond_beta_gap_traub.cpp +++ b/models/hh_cond_beta_gap_traub.cpp @@ -476,7 +476,7 @@ nest::hh_cond_beta_gap_traub::update_( Time const& origin, const bool called_from_wfr_update ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); const size_t interpolation_order = kernel().simulation_manager.get_wfr_interpolation_order(); @@ -551,15 +551,15 @@ nest::hh_cond_beta_gap_traub::update_( Time const& origin, { --S_.r_; } - else if ( S_.y_[ State_::V_M ] >= P_.V_T + 30. and U_old > S_.y_[ State_::V_M ] ) // ( threshold and maximum ) - { - S_.r_ = V_.refractory_counts_; + else if ( S_.y_[ State_::V_M ] >= P_.V_T + 30. and U_old > S_.y_[ State_::V_M ] ) // ( threshold and maximum ) + { + S_.r_ = V_.refractory_counts_; - set_spiketime( Time::step( origin.get_steps() + lag + 1 ) ); + set_spiketime( Time::step( origin.get_steps() + lag + 1 ) ); - SpikeEvent se; - kernel().event_delivery_manager.send( *this, se, lag ); - } + SpikeEvent se; + kernel().event_delivery_manager.send( *this, se, lag ); + } // log state data B_.logger_.record_data( origin.get_steps() + lag ); diff --git a/models/hh_cond_exp_traub.cpp b/models/hh_cond_exp_traub.cpp index 34d63ce0f6..ebea86e681 100644 --- a/models/hh_cond_exp_traub.cpp +++ b/models/hh_cond_exp_traub.cpp @@ -388,7 +388,7 @@ nest::hh_cond_exp_traub::pre_run_hook() void nest::hh_cond_exp_traub::update( Time const& origin, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); for ( long lag = from; lag < to; ++lag ) diff --git a/models/hh_psc_alpha.cpp b/models/hh_psc_alpha.cpp index 63bab19994..85af4e0c27 100644 --- a/models/hh_psc_alpha.cpp +++ b/models/hh_psc_alpha.cpp @@ -390,7 +390,7 @@ void nest::hh_psc_alpha::update( Time const& origin, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); for ( long lag = from; lag < to; ++lag ) @@ -436,15 +436,15 @@ nest::hh_psc_alpha::update( Time const& origin, const long from, const long to ) { --S_.r_; } - else if ( S_.y_[ State_::V_M ] >= 0 and U_old > S_.y_[ State_::V_M ] ) // ( threshold and maximum ) + else if ( S_.y_[ State_::V_M ] >= 0 and U_old > S_.y_[ State_::V_M ] ) // ( threshold and maximum ) { - S_.r_ = V_.RefractoryCounts_; + S_.r_ = V_.RefractoryCounts_; - set_spiketime( Time::step( origin.get_steps() + lag + 1 ) ); + set_spiketime( Time::step( origin.get_steps() + lag + 1 ) ); - SpikeEvent se; - kernel().event_delivery_manager.send( *this, se, lag ); - } + SpikeEvent se; + kernel().event_delivery_manager.send( *this, se, lag ); + } // log state data B_.logger_.record_data( origin.get_steps() + lag ); diff --git a/models/hh_psc_alpha_clopath.cpp b/models/hh_psc_alpha_clopath.cpp index 66b0b541b1..78b57d92cb 100644 --- a/models/hh_psc_alpha_clopath.cpp +++ b/models/hh_psc_alpha_clopath.cpp @@ -418,7 +418,7 @@ void nest::hh_psc_alpha_clopath::update( Time const& origin, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); for ( long lag = from; lag < to; ++lag ) diff --git a/models/hh_psc_alpha_gap.cpp b/models/hh_psc_alpha_gap.cpp index 73fc683801..ef347652dc 100644 --- a/models/hh_psc_alpha_gap.cpp +++ b/models/hh_psc_alpha_gap.cpp @@ -454,7 +454,7 @@ bool nest::hh_psc_alpha_gap::update_( Time const& origin, const long from, const long to, const bool called_from_wfr_update ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); const size_t interpolation_order = kernel().simulation_manager.get_wfr_interpolation_order(); diff --git a/models/ht_neuron.cpp b/models/ht_neuron.cpp index cd9f545ce1..917d8e607f 100644 --- a/models/ht_neuron.cpp +++ b/models/ht_neuron.cpp @@ -770,7 +770,7 @@ nest::ht_neuron::set_status( const DictionaryDatum& d ) void ht_neuron::update( Time const& origin, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); for ( long lag = from; lag < to; ++lag ) diff --git a/models/iaf_chs_2007.cpp b/models/iaf_chs_2007.cpp index d0aaeb6a04..98ca50ec60 100644 --- a/models/iaf_chs_2007.cpp +++ b/models/iaf_chs_2007.cpp @@ -222,7 +222,7 @@ nest::iaf_chs_2007::pre_run_hook() void nest::iaf_chs_2007::update( const Time& origin, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); // evolve from timestep 'from' to timestep 'to' with steps of h each diff --git a/models/iaf_chxk_2008.cpp b/models/iaf_chxk_2008.cpp index f8e85565b1..c143719ba1 100644 --- a/models/iaf_chxk_2008.cpp +++ b/models/iaf_chxk_2008.cpp @@ -359,7 +359,7 @@ void nest::iaf_chxk_2008::update( Time const& origin, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); for ( long lag = from; lag < to; ++lag ) diff --git a/models/iaf_cond_alpha.cpp b/models/iaf_cond_alpha.cpp index a2cfb5ca4e..7b712f6b4f 100644 --- a/models/iaf_cond_alpha.cpp +++ b/models/iaf_cond_alpha.cpp @@ -375,7 +375,7 @@ void nest::iaf_cond_alpha::update( Time const& origin, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); for ( long lag = from; lag < to; ++lag ) diff --git a/models/iaf_cond_alpha_mc.cpp b/models/iaf_cond_alpha_mc.cpp index c49d6b8557..3171736006 100644 --- a/models/iaf_cond_alpha_mc.cpp +++ b/models/iaf_cond_alpha_mc.cpp @@ -579,7 +579,7 @@ void nest::iaf_cond_alpha_mc::update( Time const& origin, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); for ( long lag = from; lag < to; ++lag ) diff --git a/models/iaf_cond_beta.cpp b/models/iaf_cond_beta.cpp index 53e1faed09..37fa1aa092 100644 --- a/models/iaf_cond_beta.cpp +++ b/models/iaf_cond_beta.cpp @@ -388,7 +388,7 @@ void nest::iaf_cond_beta::update( Time const& origin, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); for ( long lag = from; lag < to; ++lag ) diff --git a/models/iaf_cond_exp.cpp b/models/iaf_cond_exp.cpp index 4ebfb49dd5..7a5a9599f4 100644 --- a/models/iaf_cond_exp.cpp +++ b/models/iaf_cond_exp.cpp @@ -350,7 +350,7 @@ void nest::iaf_cond_exp::update( Time const& origin, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); for ( long lag = from; lag < to; ++lag ) diff --git a/models/iaf_cond_exp_sfa_rr.cpp b/models/iaf_cond_exp_sfa_rr.cpp index 4eef7ee685..def73ce3f3 100644 --- a/models/iaf_cond_exp_sfa_rr.cpp +++ b/models/iaf_cond_exp_sfa_rr.cpp @@ -386,7 +386,7 @@ void nest::iaf_cond_exp_sfa_rr::update( Time const& origin, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); for ( long lag = from; lag < to; ++lag ) diff --git a/models/iaf_psc_alpha.cpp b/models/iaf_psc_alpha.cpp index 95477a7018..cbae38c59a 100644 --- a/models/iaf_psc_alpha.cpp +++ b/models/iaf_psc_alpha.cpp @@ -306,7 +306,7 @@ iaf_psc_alpha::pre_run_hook() void iaf_psc_alpha::update( Time const& origin, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); for ( long lag = from; lag < to; ++lag ) diff --git a/models/iaf_psc_alpha_multisynapse.cpp b/models/iaf_psc_alpha_multisynapse.cpp index dd44424182..c0b762d1f2 100644 --- a/models/iaf_psc_alpha_multisynapse.cpp +++ b/models/iaf_psc_alpha_multisynapse.cpp @@ -328,7 +328,7 @@ iaf_psc_alpha_multisynapse::pre_run_hook() void iaf_psc_alpha_multisynapse::update( Time const& origin, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); for ( long lag = from; lag < to; ++lag ) diff --git a/models/iaf_psc_delta.cpp b/models/iaf_psc_delta.cpp index f673586250..ab8b771b8a 100644 --- a/models/iaf_psc_delta.cpp +++ b/models/iaf_psc_delta.cpp @@ -270,7 +270,7 @@ nest::iaf_psc_delta::pre_run_hook() void nest::iaf_psc_delta::update( Time const& origin, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); const double h = Time::get_resolution().get_ms(); diff --git a/models/iaf_psc_exp.cpp b/models/iaf_psc_exp.cpp index a5862ba5e3..bf8bb018e9 100644 --- a/models/iaf_psc_exp.cpp +++ b/models/iaf_psc_exp.cpp @@ -287,7 +287,7 @@ nest::iaf_psc_exp::pre_run_hook() void nest::iaf_psc_exp::update( const Time& origin, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); const double h = Time::get_resolution().get_ms(); diff --git a/models/iaf_psc_exp_htum.cpp b/models/iaf_psc_exp_htum.cpp index 8fabcff069..0d5f49642a 100644 --- a/models/iaf_psc_exp_htum.cpp +++ b/models/iaf_psc_exp_htum.cpp @@ -298,7 +298,7 @@ nest::iaf_psc_exp_htum::pre_run_hook() void nest::iaf_psc_exp_htum::update( Time const& origin, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); // evolve from timestep 'from' to timestep 'to' with steps of h each diff --git a/models/iaf_psc_exp_multisynapse.cpp b/models/iaf_psc_exp_multisynapse.cpp index 96ecd7bfe9..1556023d03 100644 --- a/models/iaf_psc_exp_multisynapse.cpp +++ b/models/iaf_psc_exp_multisynapse.cpp @@ -305,7 +305,7 @@ nest::iaf_psc_exp_multisynapse::pre_run_hook() void iaf_psc_exp_multisynapse::update( const Time& origin, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); // evolve from timestep 'from' to timestep 'to' with steps of h each diff --git a/models/inhomogeneous_poisson_generator.cpp b/models/inhomogeneous_poisson_generator.cpp index c2b43df40c..e4f1a35f79 100644 --- a/models/inhomogeneous_poisson_generator.cpp +++ b/models/inhomogeneous_poisson_generator.cpp @@ -240,7 +240,7 @@ nest::inhomogeneous_poisson_generator::pre_run_hook() void nest::inhomogeneous_poisson_generator::update( Time const& origin, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); assert( P_.rate_times_.size() == P_.rate_values_.size() ); diff --git a/models/izhikevich.cpp b/models/izhikevich.cpp index 6821013add..05df127495 100644 --- a/models/izhikevich.cpp +++ b/models/izhikevich.cpp @@ -191,7 +191,7 @@ nest::izhikevich::pre_run_hook() void nest::izhikevich::update( Time const& origin, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); const double h = Time::get_resolution().get_ms(); diff --git a/models/mat2_psc_exp.cpp b/models/mat2_psc_exp.cpp index d17f50cbab..e9ac77f95d 100644 --- a/models/mat2_psc_exp.cpp +++ b/models/mat2_psc_exp.cpp @@ -307,7 +307,7 @@ nest::mat2_psc_exp::pre_run_hook() void nest::mat2_psc_exp::update( Time const& origin, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); // evolve from timestep 'from' to timestep 'to' with steps of h each diff --git a/models/noise_generator.cpp b/models/noise_generator.cpp index ff18fdd792..f8d9008ac8 100644 --- a/models/noise_generator.cpp +++ b/models/noise_generator.cpp @@ -289,7 +289,7 @@ nest::noise_generator::send_test_event( Node& target, rport receptor_type, synin void nest::noise_generator::update( Time const& origin, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); const long start = origin.get_steps(); diff --git a/models/parrot_neuron.cpp b/models/parrot_neuron.cpp index c3e7747d2c..4ab3ec5531 100644 --- a/models/parrot_neuron.cpp +++ b/models/parrot_neuron.cpp @@ -58,7 +58,7 @@ parrot_neuron::init_buffers_() void parrot_neuron::update( Time const& origin, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); for ( long lag = from; lag < to; ++lag ) diff --git a/models/poisson_generator.cpp b/models/poisson_generator.cpp index 00de605b42..e66936eee2 100644 --- a/models/poisson_generator.cpp +++ b/models/poisson_generator.cpp @@ -117,7 +117,7 @@ nest::poisson_generator::pre_run_hook() void nest::poisson_generator::update( Time const& T, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); if ( P_.rate_ <= 0 ) diff --git a/models/poisson_generator_ps.cpp b/models/poisson_generator_ps.cpp index b59c82f915..94e1872a27 100644 --- a/models/poisson_generator_ps.cpp +++ b/models/poisson_generator_ps.cpp @@ -178,7 +178,7 @@ nest::poisson_generator_ps::pre_run_hook() void nest::poisson_generator_ps::update( Time const& T, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); if ( P_.rate_ <= 0 or P_.num_targets_ == 0 ) diff --git a/models/pp_cond_exp_mc_urbanczik.cpp b/models/pp_cond_exp_mc_urbanczik.cpp index c8718f9a82..b8eef0d00d 100644 --- a/models/pp_cond_exp_mc_urbanczik.cpp +++ b/models/pp_cond_exp_mc_urbanczik.cpp @@ -566,7 +566,7 @@ nest::pp_cond_exp_mc_urbanczik::pre_run_hook() // since t_ref >= 0, this can only fail in error assert( V_.RefractoryCounts_ >= 0 ); - assert( ( int ) NCOMP == ( int ) pp_cond_exp_mc_urbanczik_parameters::NCOMP ); + assert( static_cast< int >( NCOMP ) == static_cast< int >( pp_cond_exp_mc_urbanczik_parameters::NCOMP ) ); } @@ -578,7 +578,7 @@ void nest::pp_cond_exp_mc_urbanczik::update( Time const& origin, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); for ( long lag = from; lag < to; ++lag ) diff --git a/models/pp_pop_psc_delta.cpp b/models/pp_pop_psc_delta.cpp index da9fa5ed4a..6df3317a08 100644 --- a/models/pp_pop_psc_delta.cpp +++ b/models/pp_pop_psc_delta.cpp @@ -320,7 +320,7 @@ nest::pp_pop_psc_delta::pre_run_hook() void nest::pp_pop_psc_delta::update( Time const& origin, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); for ( long lag = from; lag < to; ++lag ) diff --git a/models/pp_psc_delta.cpp b/models/pp_psc_delta.cpp index 8c532a8325..6f0feb6254 100644 --- a/models/pp_psc_delta.cpp +++ b/models/pp_psc_delta.cpp @@ -361,7 +361,7 @@ void nest::pp_psc_delta::update( Time const& origin, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); for ( long lag = from; lag < to; ++lag ) diff --git a/models/ppd_sup_generator.cpp b/models/ppd_sup_generator.cpp index 94c94a643f..a9595c9e0b 100644 --- a/models/ppd_sup_generator.cpp +++ b/models/ppd_sup_generator.cpp @@ -231,7 +231,7 @@ nest::ppd_sup_generator::pre_run_hook() void nest::ppd_sup_generator::update( Time const& T, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); if ( P_.rate_ <= 0 or P_.num_targets_ == 0 ) @@ -249,7 +249,7 @@ nest::ppd_sup_generator::update( Time const& T, const long from, const long to ) } // get current (time-dependent) hazard rate and store it. - if ( P_.amplitude_ > 0.0 and P_.frequency_ > 0.0 or P_.frequency_ < 0.0 ) + if ( P_.amplitude_ > 0.0 and P_.frequency_ != 0.0 ) { double t_ms = t.get_ms(); V_.hazard_step_t_ = V_.hazard_step_ * ( 1.0 + P_.amplitude_ * std::sin( V_.omega_ * t_ms ) ); diff --git a/models/rate_neuron_ipn_impl.h b/models/rate_neuron_ipn_impl.h index 42b13a1d06..57125d60d3 100644 --- a/models/rate_neuron_ipn_impl.h +++ b/models/rate_neuron_ipn_impl.h @@ -270,7 +270,7 @@ nest::rate_neuron_ipn< TNonlinearities >::update_( Time const& origin, const long to, const bool called_from_wfr_update ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); const size_t buffer_size = kernel().connection_manager.get_min_delay(); diff --git a/models/rate_neuron_opn_impl.h b/models/rate_neuron_opn_impl.h index 409a5924d1..e339264d0d 100644 --- a/models/rate_neuron_opn_impl.h +++ b/models/rate_neuron_opn_impl.h @@ -246,7 +246,7 @@ nest::rate_neuron_opn< TNonlinearities >::update_( Time const& origin, const long to, const bool called_from_wfr_update ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); const size_t buffer_size = kernel().connection_manager.get_min_delay(); diff --git a/models/rate_transformer_node_impl.h b/models/rate_transformer_node_impl.h index 1b971dab90..33fef3727b 100644 --- a/models/rate_transformer_node_impl.h +++ b/models/rate_transformer_node_impl.h @@ -181,7 +181,7 @@ nest::rate_transformer_node< TNonlinearities >::update_( Time const& origin, const long to, const bool called_from_wfr_update ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); const size_t buffer_size = kernel().connection_manager.get_min_delay(); diff --git a/models/siegert_neuron.cpp b/models/siegert_neuron.cpp index d2c05e0e4c..e9a1d92953 100644 --- a/models/siegert_neuron.cpp +++ b/models/siegert_neuron.cpp @@ -310,7 +310,7 @@ nest::siegert_neuron::pre_run_hook() bool nest::siegert_neuron::update_( Time const& origin, const long from, const long to, const bool called_from_wfr_update ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); const size_t buffer_size = kernel().connection_manager.get_min_delay(); diff --git a/models/sinusoidal_gamma_generator.cpp b/models/sinusoidal_gamma_generator.cpp index 44178fd407..74bc331b78 100644 --- a/models/sinusoidal_gamma_generator.cpp +++ b/models/sinusoidal_gamma_generator.cpp @@ -309,7 +309,7 @@ nest::sinusoidal_gamma_generator::hazard_( port tgt_idx ) const void nest::sinusoidal_gamma_generator::update( Time const& origin, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); for ( long lag = from; lag < to; ++lag ) diff --git a/models/sinusoidal_poisson_generator.cpp b/models/sinusoidal_poisson_generator.cpp index f1e7c1833c..2e2d1cc765 100644 --- a/models/sinusoidal_poisson_generator.cpp +++ b/models/sinusoidal_poisson_generator.cpp @@ -232,7 +232,7 @@ nest::sinusoidal_poisson_generator::pre_run_hook() void nest::sinusoidal_poisson_generator::update( Time const& origin, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); const long start = origin.get_steps(); diff --git a/models/step_current_generator.cpp b/models/step_current_generator.cpp index e4b29d51ca..b5cd2b0bd3 100644 --- a/models/step_current_generator.cpp +++ b/models/step_current_generator.cpp @@ -272,7 +272,7 @@ nest::step_current_generator::pre_run_hook() void nest::step_current_generator::update( Time const& origin, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); assert( P_.amp_time_stamps_.size() == P_.amp_values_.size() ); diff --git a/models/step_rate_generator.cpp b/models/step_rate_generator.cpp index 2cd309aa9d..a591b27f57 100644 --- a/models/step_rate_generator.cpp +++ b/models/step_rate_generator.cpp @@ -273,7 +273,7 @@ nest::step_rate_generator::pre_run_hook() void nest::step_rate_generator::update( Time const& origin, const long from, const long to ) { - assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() ); + assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); assert( from < to ); assert( P_.amp_time_stamps_.size() == P_.amp_values_.size() ); diff --git a/nestkernel/connection_creator_impl.h b/nestkernel/connection_creator_impl.h index eb57c5ecfd..137dcf8cbd 100644 --- a/nestkernel/connection_creator_impl.h +++ b/nestkernel/connection_creator_impl.h @@ -440,7 +440,7 @@ ConnectionCreator::fixed_indegree_( Layer< D >& source, std::vector< bool > is_selected( positions.size() ); // Draw `number_of_connections_` sources - for ( int i = 0; i < ( int ) number_of_connections_; ++i ) + for ( int i = 0; i < static_cast< int >( number_of_connections_ ); ++i ) { index random_id = lottery( rng ); if ( not allow_multapses_ and is_selected[ random_id ] ) @@ -485,7 +485,7 @@ ConnectionCreator::fixed_indegree_( Layer< D >& source, std::vector< bool > is_selected( positions.size() ); // Draw `number_of_connections_` sources - for ( int i = 0; i < ( int ) number_of_connections_; ++i ) + for ( int i = 0; i < static_cast< int >( number_of_connections_ ); ++i ) { index random_id = rng->ulrand( positions.size() ); if ( not allow_multapses_ and is_selected[ random_id ] ) @@ -564,7 +564,7 @@ ConnectionCreator::fixed_indegree_( Layer< D >& source, std::vector< bool > is_selected( positions->size() ); // Draw `number_of_connections_` sources - for ( int i = 0; i < ( int ) number_of_connections_; ++i ) + for ( int i = 0; i < static_cast< int >( number_of_connections_ ); ++i ) { index random_id = lottery( rng ); if ( not allow_multapses_ and is_selected[ random_id ] ) @@ -602,7 +602,7 @@ ConnectionCreator::fixed_indegree_( Layer< D >& source, std::vector< bool > is_selected( positions->size() ); // Draw `number_of_connections_` sources - for ( int i = 0; i < ( int ) number_of_connections_; ++i ) + for ( int i = 0; i < static_cast< int >( number_of_connections_ ); ++i ) { index random_id = rng->ulrand( positions->size() ); if ( not allow_multapses_ and is_selected[ random_id ] ) @@ -736,7 +736,7 @@ ConnectionCreator::fixed_outdegree_( Layer< D >& source, std::vector< bool > is_selected( target_pos_node_id_pairs.size() ); // Draw `number_of_connections_` targets - for ( long i = 0; i < ( long ) number_of_connections_; ++i ) + for ( long i = 0; i < static_cast< long >( number_of_connections_ ); ++i ) { index random_id = lottery( get_rank_synced_rng() ); if ( not allow_multapses_ and is_selected[ random_id ] ) diff --git a/nestkernel/event_delivery_manager.cpp b/nestkernel/event_delivery_manager.cpp index 6776578d5e..51d6634fcc 100644 --- a/nestkernel/event_delivery_manager.cpp +++ b/nestkernel/event_delivery_manager.cpp @@ -251,7 +251,7 @@ EventDeliveryManager::update_moduli() * Note that for updating the modulos, it is sufficient * to rotate the buffer to the left. */ - assert( moduli_.size() == ( index ) ( min_delay + max_delay ) ); + assert( moduli_.size() == static_cast< index >( min_delay + max_delay ) ); std::rotate( moduli_.begin(), moduli_.begin() + min_delay, moduli_.end() ); /* @@ -601,7 +601,7 @@ EventDeliveryManager::deliver_events_( const thread tid, const std::vector< Spik // prepare Time objects for every possible time stamp within min_delay_ std::vector< Time > prepared_timestamps( kernel().connection_manager.get_min_delay() ); - for ( size_t lag = 0; lag < ( size_t ) kernel().connection_manager.get_min_delay(); ++lag ) + for ( size_t lag = 0; lag < static_cast< size_t >( kernel().connection_manager.get_min_delay() ); ++lag ) { prepared_timestamps[ lag ] = kernel().simulation_manager.get_clock() + Time::step( lag + 1 ); } diff --git a/nestkernel/layer_impl.h b/nestkernel/layer_impl.h index ced851de42..f2d64f2cc8 100644 --- a/nestkernel/layer_impl.h +++ b/nestkernel/layer_impl.h @@ -381,7 +381,7 @@ MaskedLayer< D >::check_mask_( Layer< D >& layer, bool allow_oversized ) for ( int i = 0; i < D; ++i ) { oversize |= layer.get_periodic_mask()[ i ] - and ( grid_mask.get_lower_right()[ i ] - grid_mask.get_upper_left()[ i ] ) > ( int ) dims[ i ]; + and ( grid_mask.get_lower_right()[ i ] - grid_mask.get_upper_left()[ i ] ) > static_cast< int >( dims[ i ] ); } if ( oversize ) { diff --git a/nestkernel/model.cpp b/nestkernel/model.cpp index 0e52e2b3b4..22f530d80c 100644 --- a/nestkernel/model.cpp +++ b/nestkernel/model.cpp @@ -69,7 +69,7 @@ Model::set_threads_( thread t ) void Model::reserve_additional( thread t, size_t n ) { - assert( ( size_t ) t < memory_.size() ); + assert( static_cast< size_t >( t ) < memory_.size() ); memory_[ t ].reserve( n ); } diff --git a/nestkernel/model.h b/nestkernel/model.h index 4a074b7209..c8fb12977a 100644 --- a/nestkernel/model.h +++ b/nestkernel/model.h @@ -244,7 +244,7 @@ class Model inline Node* Model::create( thread t ) { - assert( ( size_t ) t < memory_.size() ); + assert( static_cast< size_t >( t ) < memory_.size() ); Node* n = create_(); memory_[ t ].push_back( n ); return n; diff --git a/nestkernel/model_manager.cpp b/nestkernel/model_manager.cpp index 1f7bc763d4..611147818b 100644 --- a/nestkernel/model_manager.cpp +++ b/nestkernel/model_manager.cpp @@ -375,7 +375,7 @@ index ModelManager::get_node_model_id( const Name name ) const { const Name model_name( name ); - for ( int i = 0; i < ( int ) node_models_.size(); ++i ) + for ( int i = 0; i < static_cast< int >( node_models_.size() ); ++i ) { assert( node_models_[ i ] ); if ( model_name == node_models_[ i ]->get_name() ) diff --git a/nestkernel/ring_buffer.h b/nestkernel/ring_buffer.h index d9824d1f5e..d7922b34ee 100644 --- a/nestkernel/ring_buffer.h +++ b/nestkernel/ring_buffer.h @@ -162,8 +162,8 @@ RingBuffer::set_value( const long offs, const double v ) inline double RingBuffer::get_value( const long offs ) { - assert( 0 <= offs and ( size_t ) offs < buffer_.size() ); - assert( ( delay ) offs < kernel().connection_manager.get_min_delay() ); + assert( 0 <= offs and static_cast< size_t >( offs ) < buffer_.size() ); + assert( static_cast< delay >( offs ) < kernel().connection_manager.get_min_delay() ); // offs == 0 is beginning of slice, but we have to // take modulo into account when indexing @@ -176,8 +176,8 @@ RingBuffer::get_value( const long offs ) inline double RingBuffer::get_value_wfr_update( const long offs ) { - assert( 0 <= offs and ( size_t ) offs < buffer_.size() ); - assert( ( delay ) offs < kernel().connection_manager.get_min_delay() ); + assert( 0 <= offs and static_cast< size_t >( offs ) < buffer_.size() ); + assert( static_cast< delay >( offs ) < kernel().connection_manager.get_min_delay() ); // offs == 0 is beginning of slice, but we have to // take modulo into account when indexing @@ -191,7 +191,7 @@ RingBuffer::get_index_( const delay d ) const { const long idx = kernel().event_delivery_manager.get_modulo( d ); assert( 0 <= idx ); - assert( ( size_t ) idx < buffer_.size() ); + assert( static_cast< size_t >( idx ) < buffer_.size() ); return idx; } @@ -250,15 +250,15 @@ class MultRBuffer inline void MultRBuffer::add_value( const long offs, const double v ) { - assert( 0 <= offs and ( size_t ) offs < buffer_.size() ); + assert( 0 <= offs and static_cast< size_t >( offs ) < buffer_.size() ); buffer_[ get_index_( offs ) ] *= v; } inline double MultRBuffer::get_value( const long offs ) { - assert( 0 <= offs and ( size_t ) offs < buffer_.size() ); - assert( ( delay ) offs < kernel().connection_manager.get_min_delay() ); + assert( 0 <= offs and static_cast< size_t >( offs ) < buffer_.size() ); + assert( static_cast< delay >( offs ) < kernel().connection_manager.get_min_delay() ); // offs == 0 is beginning of slice, but we have to // take modulo into account when indexing @@ -272,7 +272,7 @@ inline size_t MultRBuffer::get_index_( const delay d ) const { const long idx = kernel().event_delivery_manager.get_modulo( d ); - assert( 0 <= idx and ( size_t ) idx < buffer_.size() ); + assert( 0 <= idx and static_cast< size_t >( idx ) < buffer_.size() ); return idx; } @@ -335,8 +335,8 @@ ListRingBuffer::append_value( const long offs, const double v ) inline std::list< double >& ListRingBuffer::get_list( const long offs ) { - assert( 0 <= offs and ( size_t ) offs < buffer_.size() ); - assert( ( delay ) offs < kernel().connection_manager.get_min_delay() ); + assert( 0 <= offs and static_cast< size_t >( offs ) < buffer_.size() ); + assert( static_cast< delay >( offs ) < kernel().connection_manager.get_min_delay() ); // offs == 0 is beginning of slice, but we have to // take modulo into account when indexing @@ -349,7 +349,7 @@ ListRingBuffer::get_index_( const delay d ) const { const long idx = kernel().event_delivery_manager.get_modulo( d ); assert( 0 <= idx ); - assert( ( size_t ) idx < buffer_.size() ); + assert( static_cast< size_t >( idx ) < buffer_.size() ); return idx; } diff --git a/nestkernel/simulation_manager.cpp b/nestkernel/simulation_manager.cpp index 39f4667b26..2ad738c068 100644 --- a/nestkernel/simulation_manager.cpp +++ b/nestkernel/simulation_manager.cpp @@ -1078,7 +1078,7 @@ nest::SimulationManager::advance_time_() to_do_ -= to_step_ - from_step_; // advance clock, update modulos, slice counter only if slice completed - if ( ( delay ) to_step_ == kernel().connection_manager.get_min_delay() ) + if ( static_cast< delay >( to_step_ ) == kernel().connection_manager.get_min_delay() ) { clock_ += Time::step( kernel().connection_manager.get_min_delay() ); ++slice_; @@ -1092,7 +1092,7 @@ nest::SimulationManager::advance_time_() long end_sim = from_step_ + to_do_; - if ( kernel().connection_manager.get_min_delay() < ( delay ) end_sim ) + if ( kernel().connection_manager.get_min_delay() < static_cast< delay >( end_sim ) ) { // update to end of time slice to_step_ = kernel().connection_manager.get_min_delay(); @@ -1102,7 +1102,7 @@ nest::SimulationManager::advance_time_() to_step_ = end_sim; // update to end of simulation time } - assert( to_step_ - from_step_ <= ( long ) kernel().connection_manager.get_min_delay() ); + assert( to_step_ - from_step_ <= static_cast< long >( kernel().connection_manager.get_min_delay() ) ); } void diff --git a/nestkernel/slice_ring_buffer.h b/nestkernel/slice_ring_buffer.h index 7380a96320..8da815e4ed 100644 --- a/nestkernel/slice_ring_buffer.h +++ b/nestkernel/slice_ring_buffer.h @@ -154,7 +154,7 @@ inline void SliceRingBuffer::add_spike( const delay rel_delivery, const long stamp, const double ps_offset, const double weight ) { const delay idx = kernel().event_delivery_manager.get_slice_modulo( rel_delivery ); - assert( ( size_t ) idx < queue_.size() ); + assert( static_cast< size_t >( idx ) < queue_.size() ); assert( ps_offset >= 0 ); queue_[ idx ].push_back( SpikeInfo( stamp, ps_offset, weight ) ); diff --git a/sli/interpret.cc b/sli/interpret.cc index 3a75bcd7da..a48bf5f587 100644 --- a/sli/interpret.cc +++ b/sli/interpret.cc @@ -994,7 +994,7 @@ SLIInterpreter::stack_backtrace( int n ) { for ( int p = n - 1; p >= 0; --p ) { - if ( ( size_t ) p > EStack.load() ) + if ( static_cast< size_t >( p ) > EStack.load() ) { continue; } diff --git a/sli/scanner.cc b/sli/scanner.cc index 32599eaef6..0efdd502f1 100644 --- a/sli/scanner.cc +++ b/sli/scanner.cc @@ -140,7 +140,7 @@ Scanner::Scanner( std::istream* is ) code.Group( alpha, "ABCDFGHIJKLMNOPQRSTUVWXYZ" ); code.Group( alpha, "abcdfghijklmopqrsuvwxyz" ); - code.Range( alpha, ( char ) 161, ( char ) 255 ); + code.Range( alpha, static_cast< char >( 161 ), static_cast< char >( 255 ) ); code[ '_' ] = alpha; code.Group( alpha, "~`!@#$^&=|:;'<,>?\"" ); // according to PS diff --git a/sli/sliarray.cc b/sli/sliarray.cc index 30829be12c..95bb2a2a1a 100644 --- a/sli/sliarray.cc +++ b/sli/sliarray.cc @@ -90,13 +90,13 @@ SLIArrayModule::RangeFunction::execute( SLIInterpreter* i ) const { double d = ad->get( 0 ); ad->erase(); - long n = ( long ) std::floor( d ); + long n = static_cast< long >( std::floor( d ) ); if ( n > 0 ) { ad->reserve( n ); for ( long j = 1; j <= n; ++j ) { - ad->push_back( ( double ) j ); + ad->push_back( static_cast< double >( j ) ); } } i->EStack.pop(); @@ -265,7 +265,7 @@ SLIArrayModule::ArangeFunction::execute( SLIInterpreter* i ) const else { double d = ad->get( 0 ); - long n = ( long ) std::floor( d ); + long n = static_cast< long >( std::floor( d ) ); if ( n < 0 ) { i->raiseerror( "RangeCheck" ); @@ -1022,7 +1022,7 @@ SLIArrayModule::IMapFunction::execute( SLIInterpreter* i ) const } } - if ( ( size_t ) procc->get() < proclimit ) + if ( static_cast< size_t >( procc->get() ) < proclimit ) { /* we are still evaluating the procedure. */ i->EStack.push( proc->get( pos ) ); // get next command from the procedure @@ -1049,7 +1049,7 @@ SLIArrayModule::IMapFunction::execute( SLIInterpreter* i ) const } while ( true ); } } - if ( ( size_t ) procc->get() >= proclimit ) + if ( static_cast< size_t >( procc->get() ) >= proclimit ) { ( *procc ) = 0; } @@ -1160,7 +1160,7 @@ SLIArrayModule::IMap_ivFunction::execute( SLIInterpreter* i ) const } } - if ( ( size_t ) procc->get() < proclimit ) + if ( static_cast< size_t >( procc->get() ) < proclimit ) { /* we are still evaluating the procedure. */ i->EStack.push( proc->get( pos ) ); // get next command from the procedure @@ -1187,7 +1187,7 @@ SLIArrayModule::IMap_ivFunction::execute( SLIInterpreter* i ) const } while ( true ); } } - if ( ( size_t ) procc->get() >= proclimit ) + if ( static_cast< size_t >( procc->get() ) >= proclimit ) { ( *procc ) = 0; } @@ -1295,7 +1295,7 @@ SLIArrayModule::IMap_dvFunction::execute( SLIInterpreter* i ) const } } - if ( ( size_t ) procc->get() < proclimit ) + if ( static_cast< size_t >( procc->get() ) < proclimit ) { /* we are still evaluating the procedure. */ i->EStack.push( proc->get( pos ) ); // get next command from the procedure @@ -1322,7 +1322,7 @@ SLIArrayModule::IMap_dvFunction::execute( SLIInterpreter* i ) const } while ( true ); } } - if ( ( size_t ) procc->get() >= proclimit ) + if ( static_cast< size_t >( procc->get() ) >= proclimit ) { ( *procc ) = 0; } @@ -1525,7 +1525,7 @@ SLIArrayModule::IMapIndexedFunction::execute( SLIInterpreter* i ) const } } - if ( ( size_t ) procc->get() < proclimit ) + if ( static_cast< size_t >( procc->get() ) < proclimit ) { /* we are still evaluating the procedure. */ i->EStack.push( proc->get( pos ) ); // get next command from the procedure @@ -1551,7 +1551,7 @@ SLIArrayModule::IMapIndexedFunction::execute( SLIInterpreter* i ) const } while ( true ); } } - if ( ( size_t ) procc->get() >= proclimit ) + if ( static_cast< size_t >( procc->get() ) >= proclimit ) { ( *procc ) = 0; } @@ -1695,7 +1695,7 @@ SLIArrayModule::IMapThreadFunction::execute( SLIInterpreter* i ) const } } - if ( ( size_t ) proccountd->get() < proclimit ) + if ( static_cast< size_t >( proccountd->get() ) < proclimit ) { /* we are still evaluating the procedure. */ // get next command from the procedure @@ -1723,7 +1723,7 @@ SLIArrayModule::IMapThreadFunction::execute( SLIInterpreter* i ) const } while ( true ); } } - if ( ( size_t ) proccountd->get() >= proclimit ) + if ( static_cast< size_t >( proccountd->get() ) >= proclimit ) { ( *proccountd ) = 0; } @@ -1873,7 +1873,7 @@ SLIArrayModule::Put_a_a_tFunction::execute( SLIInterpreter* i ) const return; } - if ( j >= ( int ) source->size() ) + if ( j >= static_cast< int >( source->size() ) ) { i->message( SLIInterpreter::M_ERROR, "Put", "Index out of range." ); i->message( SLIInterpreter::M_ERROR, "Put", "Source array is unchanged." ); @@ -2739,7 +2739,7 @@ SLIArrayModule::GaborFunction::execute( SLIInterpreter* i ) const i->raiseerror( "RangeCheck" ); return; } - if ( ncol < 2 or nrow < 2 ) + if ( ncol < 2 or nrow < 2 ) { i->message( SLIInterpreter::M_ERROR, "Gabor_", "Matrix must have at least two rows and two columns." ); i->raiseerror( "RangeCheck" ); @@ -2764,10 +2764,10 @@ SLIArrayModule::GaborFunction::execute( SLIInterpreter* i ) const result.reserve( nrow ); std::vector< double > col( ncol ); - for ( size_t r = 0; r < ( size_t ) nrow; ++r ) + for ( size_t r = 0; r < static_cast< size_t >( nrow ); ++r ) { const double y = ymin + r * dy; - for ( size_t c = 0; c < ( size_t ) ncol; ++c ) + for ( size_t c = 0; c < static_cast< size_t >( ncol ); ++c ) { const double x = xmin + c * dx; const double x1 = x * cos_phi - y * sin_phi; @@ -2870,11 +2870,11 @@ SLIArrayModule::Gauss2dFunction::execute( SLIInterpreter* i ) const result.reserve( nrow ); std::vector< double > col( ncol ); - for ( size_t r = 0; r < ( size_t ) nrow; ++r ) + for ( size_t r = 0; r < static_cast< size_t >( nrow ); ++r ) { const double y = ymin + r * dy; col.assign( ncol, 0.0 ); // clear contents - for ( size_t c = 0; c < ( size_t ) ncol; ++c ) + for ( size_t c = 0; c < static_cast< size_t >( ncol ); ++c ) { const double x = xmin + c * dx; const double x1 = x * cos_phi - y * sin_phi; diff --git a/sli/slicontrol.cc b/sli/slicontrol.cc index c50afda9bb..fa3803493e 100644 --- a/sli/slicontrol.cc +++ b/sli/slicontrol.cc @@ -1552,11 +1552,11 @@ PclocksFunction::execute( SLIInterpreter* i ) const return; } - Token rtime( ( long ) realtime ); - Token utime( ( long ) foo.tms_utime ); - Token stime( ( long ) foo.tms_stime ); - Token cutime( ( long ) foo.tms_cutime ); - Token cstime( ( long ) foo.tms_cstime ); + Token rtime( static_cast< long >( realtime ) ); + Token utime( static_cast< long >( foo.tms_utime ) ); + Token stime( static_cast< long >( foo.tms_stime ) ); + Token cutime( static_cast< long >( foo.tms_cutime ) ); + Token cstime( static_cast< long >( foo.tms_cstime ) ); ArrayDatum result; result.push_back( rtime ); diff --git a/sli/slidata.cc b/sli/slidata.cc index a1041a3afe..d70506658f 100644 --- a/sli/slidata.cc +++ b/sli/slidata.cc @@ -67,7 +67,7 @@ Get_aFunction::execute( SLIInterpreter* i ) const assert( obj ); - if ( ( idx->get() >= 0 ) and ( ( size_t ) idx->get() < obj->size() ) ) + if ( ( idx->get() >= 0 ) and ( static_cast< size_t >( idx->get() ) < obj->size() ) ) { i->EStack.pop(); Token objT( obj->get( idx->get() ) ); @@ -114,16 +114,16 @@ Get_a_aFunction::execute( SLIInterpreter* i ) const { std::ostringstream sout; - sout << "Index at position " << ( size_t ) ( t - idx->begin() ) << " ignored." << std::ends; + sout << "Index at position " << static_cast< size_t >( ( t - idx->begin() ) ) << " ignored." << std::ends; i->message( SLIInterpreter::M_INFO, "get_a_a", sout.str().c_str() ); i->message( SLIInterpreter::M_INFO, "get_a_a", "Index must be an integer." ); continue; } - if ( not( ( id->get() >= 0 ) and ( ( size_t ) id->get() < obj->size() ) ) ) + if ( not( ( id->get() >= 0 ) and ( static_cast< size_t >( id->get() ) < obj->size() ) ) ) { std::ostringstream sout; - sout << "At position " << ( size_t ) ( t - idx->begin() ) << "." << std::ends; + sout << "At position " << static_cast< size_t >( ( t - idx->begin() ) ) << "." << std::ends; i->message( SLIInterpreter::M_ERROR, "get_a_a", sout.str().c_str() ); i->message( SLIInterpreter::M_ERROR, "get_a_a", "Index out of range." ); i->raiseerror( i->RangeCheckError ); @@ -159,7 +159,7 @@ Get_pFunction::execute( SLIInterpreter* i ) const assert( obj ); - if ( ( idx->get() >= 0 ) and ( ( size_t ) idx->get() < obj->size() ) ) + if ( ( idx->get() >= 0 ) and ( static_cast< size_t >( idx->get() ) < obj->size() ) ) { i->EStack.pop(); Token objT( obj->get( idx->get() ) ); @@ -183,7 +183,7 @@ Get_lpFunction::execute( SLIInterpreter* i ) const LitprocedureDatum* obj = dynamic_cast< LitprocedureDatum* >( i->OStack.pick( 1 ).datum() ); assert( obj ); - if ( ( idx->get() >= 0 ) and ( ( size_t ) idx->get() < obj->size() ) ) + if ( ( idx->get() >= 0 ) and ( static_cast< size_t >( idx->get() ) < obj->size() ) ) { i->EStack.pop(); Token objT( obj->get( idx->get() ) ); @@ -357,7 +357,7 @@ Insert_sFunction::execute( SLIInterpreter* i ) const assert( s1 and id and s2 ); - if ( ( id->get() >= 0 ) and ( ( size_t ) id->get() < s1->size() ) ) + if ( ( id->get() >= 0 ) and ( static_cast< size_t >( id->get() ) < s1->size() ) ) { i->EStack.pop(); s1->insert( id->get(), *s2 ); @@ -393,7 +393,7 @@ InsertElement_sFunction::execute( SLIInterpreter* i ) const assert( s1 and id and c ); - if ( ( id->get() >= 0 ) and ( ( size_t ) id->get() < s1->size() ) ) + if ( ( id->get() >= 0 ) and ( static_cast< size_t >( id->get() ) < s1->size() ) ) { i->EStack.pop(); s1->insert( id->get(), 1, static_cast< char >( c->get() ) ); @@ -449,7 +449,7 @@ Insert_aFunction::execute( SLIInterpreter* i ) const assert( a1 and id and a2 ); - if ( ( id->get() >= 0 ) and ( ( size_t ) id->get() < a1->size() ) ) + if ( ( id->get() >= 0 ) and ( static_cast< size_t >( id->get() ) < a1->size() ) ) { i->EStack.pop(); a1->insert_move( id->get(), *a2 ); // ArrayDatum is a TokenArray. @@ -472,7 +472,7 @@ InsertElement_aFunction::execute( SLIInterpreter* i ) const assert( a1 and id ); - if ( ( id->get() >= 0 ) and ( ( size_t ) id->get() < a1->size() ) ) + if ( ( id->get() >= 0 ) and ( static_cast< size_t >( id->get() ) < a1->size() ) ) { i->EStack.pop(); a1->insert_move( id->get(), i->OStack.top() ); @@ -546,7 +546,7 @@ Replace_sFunction::execute( SLIInterpreter* i ) const assert( s1 and id and n and s2 ); - if ( ( id->get() >= 0 ) and ( ( size_t ) id->get() < s1->size() ) ) + if ( ( id->get() >= 0 ) and ( static_cast< size_t >( id->get() ) < s1->size() ) ) { if ( n->get() >= 0 ) { @@ -578,7 +578,7 @@ Replace_aFunction::execute( SLIInterpreter* i ) const assert( s1 and id and n and s2 ); - if ( ( id->get() >= 0 ) and ( ( size_t ) id->get() < s1->size() ) ) + if ( ( id->get() >= 0 ) and ( static_cast< size_t >( id->get() ) < s1->size() ) ) { if ( n->get() >= 0 ) { @@ -623,7 +623,7 @@ Erase_sFunction::execute( SLIInterpreter* i ) const assert( s1 and id and n ); - if ( ( id->get() >= 0 ) and ( ( size_t ) id->get() < s1->size() ) ) + if ( ( id->get() >= 0 ) and ( static_cast< size_t >( id->get() ) < s1->size() ) ) { if ( n->get() >= 0 ) { @@ -654,7 +654,7 @@ Erase_aFunction::execute( SLIInterpreter* i ) const assert( s1 and id and n ); - if ( ( id->get() >= 0 ) and ( ( size_t ) id->get() < s1->size() ) ) + if ( ( id->get() >= 0 ) and ( static_cast< size_t >( id->get() ) < s1->size() ) ) { if ( n->get() >= 0 ) { @@ -685,7 +685,7 @@ Erase_pFunction::execute( SLIInterpreter* i ) const assert( s1 and id and n ); - if ( ( id->get() >= 0 ) and ( ( size_t ) id->get() < s1->size() ) ) + if ( ( id->get() >= 0 ) and ( static_cast< size_t >( id->get() ) < s1->size() ) ) { if ( n->get() >= 0 ) { @@ -717,7 +717,7 @@ Put_sFunction::execute( SLIInterpreter* i ) const assert( s1 and id and cd ); - if ( ( id->get() >= 0 ) and ( ( size_t ) id->get() < s1->size() ) ) + if ( ( id->get() >= 0 ) and ( static_cast< size_t >( id->get() ) < s1->size() ) ) { i->EStack.pop(); ( *s1 )[ id->get() ] = static_cast< char >( cd->get() ); @@ -741,7 +741,7 @@ Put_aFunction::execute( SLIInterpreter* i ) const assert( ad and id ); - if ( ( id->get() >= 0 ) and ( ( size_t ) id->get() < ad->size() ) ) + if ( ( id->get() >= 0 ) and ( static_cast< size_t >( id->get() ) < ad->size() ) ) { i->EStack.pop(); ad->assign_move( id->get(), i->OStack.top() ); // its safe to empty top() because @@ -765,7 +765,7 @@ Put_pFunction::execute( SLIInterpreter* i ) const assert( ad and id ); - if ( ( id->get() >= 0 ) and ( ( size_t ) id->get() < ad->size() ) ) + if ( ( id->get() >= 0 ) and ( static_cast< size_t >( id->get() ) < ad->size() ) ) { i->EStack.pop(); ad->assign_move( id->get(), i->OStack.top() ); // its safe to empty top() because @@ -789,7 +789,7 @@ Put_lpFunction::execute( SLIInterpreter* i ) const assert( ad and id ); - if ( ( id->get() >= 0 ) and ( ( size_t ) id->get() < ad->size() ) ) + if ( ( id->get() >= 0 ) and ( static_cast< size_t >( id->get() ) < ad->size() ) ) { i->EStack.pop(); ad->assign_move( id->get(), i->OStack.top() ); // its safe to empty top() because @@ -1403,7 +1403,7 @@ Get_sFunction::execute( SLIInterpreter* i ) const assert( obj ); - if ( ( idx->get() >= 0 ) and ( ( size_t ) idx->get() < obj->size() ) ) + if ( ( idx->get() >= 0 ) and ( static_cast< size_t >( idx->get() ) < obj->size() ) ) { i->EStack.pop(); Token objT( new IntegerDatum( ( *obj )[ idx->get() ] ) ); diff --git a/sli/sligraphics.cc b/sli/sligraphics.cc index cecdae6cca..fbc2b6e8e0 100644 --- a/sli/sligraphics.cc +++ b/sli/sligraphics.cc @@ -195,7 +195,7 @@ SLIgraphics::ReadPGMFunction::readImage( std::istream* in, int tmp; while ( ( *in >> tmp ) and not( in->eof() ) ) { - image.push_back( ( long ) tmp ); + image.push_back( static_cast< long >( tmp ) ); } } else if ( std::string( magic ) == std::string( "P5" ) @@ -213,7 +213,7 @@ SLIgraphics::ReadPGMFunction::readImage( std::istream* in, while ( in->read( &tmp, 1 ) and not( in->eof() ) ) { tmp2 = ( unsigned char ) tmp; - image.push_back( ( long ) tmp2 ); + image.push_back( static_cast< long >( tmp2 ) ); } } else @@ -279,9 +279,9 @@ SLIgraphics::WritePGMFunction::execute( SLIInterpreter* i ) const ArrayDatum* image = dynamic_cast< ArrayDatum* >( i->OStack.pick( 3 ).datum() ); StringDatum* filename = dynamic_cast< StringDatum* >( i->OStack.pick( 4 ).datum() ); - long width = ( long ) w->get(); - long height = ( long ) h->get(); - long maxval = ( long ) m->get(); + long width = static_cast< long >( w->get() ); + long height = static_cast< long >( h->get() ); + long maxval = static_cast< long >( m->get() ); std::ostream* out = nullptr; @@ -294,7 +294,7 @@ SLIgraphics::WritePGMFunction::execute( SLIInterpreter* i ) const throw std::string( "Error when opening file for writing." ); } - if ( ( long ) image->size() != width * height ) + if ( static_cast< long >( image->size() ) != width * height ) { throw std::string( "Array size does not match given dimensions." ); } diff --git a/sli/tarrayobj.cc b/sli/tarrayobj.cc index ded44e05cf..d647592f3f 100644 --- a/sli/tarrayobj.cc +++ b/sli/tarrayobj.cc @@ -363,7 +363,7 @@ TokenArrayObj::reduce( Token* first, Token* last ) i->clear(); i++; } - begin_of_free_storage = p + ( size_t ) ( last - first ); + begin_of_free_storage = p + static_cast< size_t >( ( last - first ) ); // shrink(); } diff --git a/sli/tarrayobj.h b/sli/tarrayobj.h index c36730c4bc..abaeee5193 100644 --- a/sli/tarrayobj.h +++ b/sli/tarrayobj.h @@ -80,13 +80,13 @@ class TokenArrayObj size_t size() const { - return ( size_t ) ( begin_of_free_storage - p ); + return static_cast< size_t >( begin_of_free_storage - p ); } size_t capacity() const { - return ( size_t ) ( end_of_free_storage - p ); + return static_cast< size_t >( end_of_free_storage - p ); } Token& diff --git a/testsuite/cpptests/test_block_vector.h b/testsuite/cpptests/test_block_vector.h index ba6e9cc507..83e1a1c3e7 100644 --- a/testsuite/cpptests/test_block_vector.h +++ b/testsuite/cpptests/test_block_vector.h @@ -73,8 +73,8 @@ BOOST_AUTO_TEST_CASE( test_size ) block_vector_b.push_back( i ); } - BOOST_REQUIRE( block_vector_a.size() == ( size_t ) N_a ); - BOOST_REQUIRE( block_vector_b.size() == ( size_t ) N_b ); + BOOST_REQUIRE( block_vector_a.size() == static_cast< size_t >( N_a ) ); + BOOST_REQUIRE( block_vector_b.size() == static_cast< size_t >( N_b ) ); } BOOST_AUTO_TEST_CASE( test_random_access ) From 758f02fa4c4e649764bc36666c4c5b511f456445 Mon Sep 17 00:00:00 2001 From: Jan Vogelsang Date: Wed, 30 Nov 2022 18:45:16 +0100 Subject: [PATCH 2/3] Removed re-introduced files --- models/iaf_psc_alpha_canon.cpp | 666 ------------------ models/iaf_psc_alpha_canon.h | 538 -------------- models/pp_pop_psc_delta.cpp | 471 ------------- models/pp_pop_psc_delta.h | 404 ----------- testsuite/unittests/test_pp_pop_psc_delta.sli | 200 ------ 5 files changed, 2279 deletions(-) delete mode 100644 models/iaf_psc_alpha_canon.cpp delete mode 100644 models/iaf_psc_alpha_canon.h delete mode 100644 models/pp_pop_psc_delta.cpp delete mode 100644 models/pp_pop_psc_delta.h delete mode 100755 testsuite/unittests/test_pp_pop_psc_delta.sli diff --git a/models/iaf_psc_alpha_canon.cpp b/models/iaf_psc_alpha_canon.cpp deleted file mode 100644 index 213b614e3b..0000000000 --- a/models/iaf_psc_alpha_canon.cpp +++ /dev/null @@ -1,666 +0,0 @@ -/* - * iaf_psc_alpha_canon.cpp - * - * This file is part of NEST. - * - * Copyright (C) 2004 The NEST Initiative - * - * NEST is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * NEST is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with NEST. If not, see . - * - */ - -#include "iaf_psc_alpha_canon.h" - -// C++ includes: -#include - -// Includes from libnestutil: -#include "dict_util.h" -#include "numerics.h" -#include "propagator_stability.h" - -// Includes from nestkernel: -#include "exceptions.h" -#include "kernel_manager.h" -#include "universal_data_logger_impl.h" - -// Includes from sli: -#include "dictutils.h" - -/* ---------------------------------------------------------------- - * Recordables map - * ---------------------------------------------------------------- */ - -nest::RecordablesMap< nest::iaf_psc_alpha_canon > nest::iaf_psc_alpha_canon::recordablesMap_; - -namespace nest -{ -/* - * Override the create() method with one call to RecordablesMap::insert_() - * for each quantity to be recorded. - */ -template <> -void -RecordablesMap< iaf_psc_alpha_canon >::create() -{ - // use standard names wherever you can for consistency! - insert_( names::V_m, &iaf_psc_alpha_canon::get_V_m_ ); -} -} - -/* ---------------------------------------------------------------- - * Default constructors defining default parameters and state - * ---------------------------------------------------------------- */ - -nest::iaf_psc_alpha_canon::Parameters_::Parameters_() - : tau_m_( 10.0 ) // ms - , tau_syn_( 2.0 ) // ms - , c_m_( 250.0 ) // pF - , t_ref_( 2.0 ) // ms - , E_L_( -70.0 ) // mV - , I_e_( 0.0 ) // pA - , U_th_( -55.0 - E_L_ ) // mV, rel to E_L_ - , U_min_( -std::numeric_limits< double >::infinity() ) // mV - , U_reset_( -70.0 - E_L_ ) // mV, rel to E_L_ - , Interpol_( iaf_psc_alpha_canon::LINEAR ) -{ -} - -nest::iaf_psc_alpha_canon::State_::State_() - : y0_( 0.0 ) - , y1_( 0.0 ) - , y2_( 0.0 ) - , y3_( 0.0 ) - , is_refractory_( false ) - , last_spike_step_( -1 ) - , last_spike_offset_( 0.0 ) -{ -} - -/* ---------------------------------------------------------------- - * Parameter and state extractions and manipulation functions - * ---------------------------------------------------------------- */ - -void -nest::iaf_psc_alpha_canon::Parameters_::get( DictionaryDatum& d ) const -{ - def< double >( d, names::E_L, E_L_ ); - def< double >( d, names::I_e, I_e_ ); - def< double >( d, names::V_th, U_th_ + E_L_ ); - def< double >( d, names::V_min, U_min_ + E_L_ ); - def< double >( d, names::V_reset, U_reset_ + E_L_ ); - def< double >( d, names::C_m, c_m_ ); - def< double >( d, names::tau_m, tau_m_ ); - def< double >( d, names::tau_syn, tau_syn_ ); - def< double >( d, names::t_ref, t_ref_ ); - def< long >( d, names::Interpol_Order, Interpol_ ); -} - -double -nest::iaf_psc_alpha_canon::Parameters_::set( const DictionaryDatum& d, Node* node ) -{ - // if E_L_ is changed, we need to adjust all variables defined relative to - // E_L_ - const double ELold = E_L_; - updateValueParam< double >( d, names::E_L, E_L_, node ); - const double delta_EL = E_L_ - ELold; - - updateValueParam< double >( d, names::tau_m, tau_m_, node ); - updateValueParam< double >( d, names::tau_syn, tau_syn_, node ); - updateValueParam< double >( d, names::C_m, c_m_, node ); - updateValueParam< double >( d, names::t_ref, t_ref_, node ); - updateValueParam< double >( d, names::I_e, I_e_, node ); - - if ( updateValueParam< double >( d, names::V_th, U_th_, node ) ) - { - U_th_ -= E_L_; - } - else - { - U_th_ -= delta_EL; - } - - if ( updateValueParam< double >( d, names::V_min, U_min_, node ) ) - { - U_min_ -= E_L_; - } - else - { - U_min_ -= delta_EL; - } - - if ( updateValueParam< double >( d, names::V_reset, U_reset_, node ) ) - { - U_reset_ -= E_L_; - } - else - { - U_reset_ -= delta_EL; - } - - long tmp; - if ( updateValueParam< long >( d, names::Interpol_Order, tmp, node ) ) - { - if ( NO_INTERPOL <= tmp and tmp < END_INTERP_ORDER ) - { - Interpol_ = static_cast< interpOrder >( tmp ); - } - else - { - throw BadProperty( - "Invalid interpolation order. " - "Valid orders are 0, 1, 2, 3." ); - } - } - if ( U_reset_ >= U_th_ ) - { - throw BadProperty( "Reset potential must be smaller than threshold." ); - } - if ( U_reset_ < U_min_ ) - { - throw BadProperty( "Reset potential must be greater equal minimum potential." ); - } - if ( c_m_ <= 0 ) - { - throw BadProperty( "Capacitance must be strictly positive." ); - } - - if ( Time( Time::ms( t_ref_ ) ).get_steps() < 1 ) - { - throw BadProperty( "Refractory time must be at least one time step." ); - } - if ( tau_m_ <= 0 or tau_syn_ <= 0 ) - { - throw BadProperty( "All time constants must be strictly positive." ); - } - - return delta_EL; -} - -void -nest::iaf_psc_alpha_canon::State_::get( DictionaryDatum& d, const Parameters_& p ) const -{ - def< double >( d, names::V_m, y3_ + p.E_L_ ); // Membrane potential - def< double >( d, names::y1, y1_ ); // y1 state - def< double >( d, names::y2, y2_ ); // y2 state - def< bool >( d, names::is_refractory, is_refractory_ ); -} - -void -nest::iaf_psc_alpha_canon::State_::set( const DictionaryDatum& d, const Parameters_& p, double delta_EL, Node* node ) -{ - if ( updateValueParam< double >( d, names::V_m, y3_, node ) ) - { - y3_ -= p.E_L_; - } - else - { - y3_ -= delta_EL; - } - - updateValueParam< double >( d, names::y1, y1_, node ); - updateValueParam< double >( d, names::y2, y2_, node ); -} - -nest::iaf_psc_alpha_canon::Buffers_::Buffers_( iaf_psc_alpha_canon& n ) - : logger_( n ) -{ -} - -nest::iaf_psc_alpha_canon::Buffers_::Buffers_( const Buffers_&, iaf_psc_alpha_canon& n ) - : logger_( n ) -{ -} - - -/* ---------------------------------------------------------------- - * Default and copy constructor for node - * ---------------------------------------------------------------- */ - -nest::iaf_psc_alpha_canon::iaf_psc_alpha_canon() - : ArchivingNode() - , P_() - , S_() - , B_( *this ) -{ - recordablesMap_.create(); -} - -nest::iaf_psc_alpha_canon::iaf_psc_alpha_canon( const iaf_psc_alpha_canon& n ) - : ArchivingNode( n ) - , P_( n.P_ ) - , S_( n.S_ ) - , B_( n.B_, *this ) -{ -} - -/* ---------------------------------------------------------------- - * Node initialization functions - * ---------------------------------------------------------------- */ - -void -nest::iaf_psc_alpha_canon::init_buffers_() -{ - B_.events_.resize(); - B_.events_.clear(); - B_.currents_.clear(); // includes resize - B_.logger_.reset(); - - ArchivingNode::clear_history(); -} - -void -nest::iaf_psc_alpha_canon::pre_run_hook() -{ - B_.logger_.init(); - - V_.h_ms_ = Time::get_resolution().get_ms(); - - V_.PSCInitialValue_ = 1.0 * numerics::e / P_.tau_syn_; - - V_.gamma_ = 1 / P_.c_m_ / ( 1 / P_.tau_syn_ - 1 / P_.tau_m_ ); - V_.gamma_sq_ = 1 / P_.c_m_ / ( ( 1 / P_.tau_syn_ - 1 / P_.tau_m_ ) * ( 1 / P_.tau_syn_ - 1 / P_.tau_m_ ) ); - - // pre-compute matrix for full time step - V_.expm1_tau_m_ = numerics::expm1( -V_.h_ms_ / P_.tau_m_ ); - V_.expm1_tau_syn_ = numerics::expm1( -V_.h_ms_ / P_.tau_syn_ ); - V_.P30_ = -P_.tau_m_ / P_.c_m_ * V_.expm1_tau_m_; - // these are determined according to a numeric stability criterion - V_.P31_ = propagator_31( P_.tau_syn_, P_.tau_m_, P_.c_m_, V_.h_ms_ ); - V_.P32_ = propagator_32( P_.tau_syn_, P_.tau_m_, P_.c_m_, V_.h_ms_ ); - - // t_ref_ is the refractory period in ms - // refractory_steps_ is the duration of the refractory period in whole - // steps, rounded down - V_.refractory_steps_ = Time( Time::ms( P_.t_ref_ ) ).get_steps(); - // since t_ref_ >= sim step size, this can only fail in error - assert( V_.refractory_steps_ >= 1 ); -} - -/* ---------------------------------------------------------------- - * Update and spike handling functions - * ---------------------------------------------------------------- */ - -void -nest::iaf_psc_alpha_canon::update( Time const& origin, const long from, const long to ) -{ - assert( to >= 0 ); - assert( static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); - assert( from < to ); - - // at start of slice, tell input queue to prepare for delivery - if ( from == 0 ) - { - B_.events_.prepare_delivery(); - } - - /* Neurons may have been initialized to superthreshold potentials. - We need to check for this here and issue spikes at the beginning of - the interval. - */ - if ( S_.y3_ >= P_.U_th_ ) - { - emit_instant_spike_( origin, from, V_.h_ms_ * ( 1 - std::numeric_limits< double >::epsilon() ) ); - } - - for ( long lag = from; lag < to; ++lag ) - { - // time at start of update step - const long T = origin.get_steps() + lag; - // if neuron returns from refractoriness during this step, place - // pseudo-event in queue to mark end of refractory period - if ( S_.is_refractory_ and T + 1 - S_.last_spike_step_ == V_.refractory_steps_ ) - { - B_.events_.add_refractory( T, S_.last_spike_offset_ ); - } - - // save state at beginning of interval for spike-time interpolation - V_.y0_before_ = S_.y0_; - V_.y2_before_ = S_.y2_; - V_.y3_before_ = S_.y3_; - - // get first event - double ev_offset; - double ev_weight; - bool end_of_refract; - - if ( not B_.events_.get_next_spike( T, true, ev_offset, ev_weight, end_of_refract ) ) - { // No incoming spikes, handle with fixed propagator matrix. - // Handling this case separately improves performance significantly - // if there are many steps without input spikes. - - // update membrane potential - if ( not S_.is_refractory_ ) - { - S_.y3_ = - V_.P30_ * ( P_.I_e_ + S_.y0_ ) + V_.P31_ * S_.y1_ + V_.P32_ * S_.y2_ + V_.expm1_tau_m_ * S_.y3_ + S_.y3_; - - // lower bound of membrane potential - S_.y3_ = ( S_.y3_ < P_.U_min_ ? P_.U_min_ : S_.y3_ ); - } - - // update synaptic currents - S_.y2_ = V_.expm1_tau_syn_ * V_.h_ms_ * S_.y1_ + V_.expm1_tau_syn_ * S_.y2_ + V_.h_ms_ * S_.y1_ + S_.y2_; - S_.y1_ = V_.expm1_tau_syn_ * S_.y1_ + S_.y1_; - - /* The following must not be moved before the y1_, y2_ update, - since the spike-time interpolation within emit_spike_ depends - on all state variables having their values at the end of the - interval. - */ - if ( S_.y3_ >= P_.U_th_ ) - { - emit_spike_( origin, lag, 0, V_.h_ms_ ); - } - } - else - { - // We only get here if there is at least on event, - // which has been read above. We can therefore use - // a do-while loop. - - // Time within step is measured by offsets, which are h at the beginning - // and 0 at the end of the step. - double last_offset = V_.h_ms_; // start of step - - do - { - // time is measured backward: inverse order in difference - const double ministep = last_offset - ev_offset; - - propagate_( ministep ); - - // check for threshold crossing during ministep - // this must be done before adding the input, since - // interpolation requires continuity - if ( S_.y3_ >= P_.U_th_ ) - { - emit_spike_( origin, lag, V_.h_ms_ - last_offset, ministep ); - } - - // handle event - if ( end_of_refract ) - { - S_.is_refractory_ = false; - } // return from refractoriness - else - { - S_.y1_ += V_.PSCInitialValue_ * ev_weight; - } // spike input - - // store state - V_.y2_before_ = S_.y2_; - V_.y3_before_ = S_.y3_; - last_offset = ev_offset; - - } while ( B_.events_.get_next_spike( T, true, ev_offset, ev_weight, end_of_refract ) ); - - // no events remaining, plain update step across remainder - // of interval - if ( last_offset > 0 ) // not at end of step, do remainder - { - propagate_( last_offset ); - if ( S_.y3_ >= P_.U_th_ ) - { - emit_spike_( origin, lag, V_.h_ms_ - last_offset, last_offset ); - } - } - } // else - - // Set new input current. The current change occurs at the - // end of the interval and thus must come AFTER the threshold- - // crossing interpolation - S_.y0_ = B_.currents_.get_value( lag ); - - - // logging - B_.logger_.record_data( origin.get_steps() + lag ); - } // from lag = from ... -} - - -// function handles exact spike times -void -nest::iaf_psc_alpha_canon::handle( SpikeEvent& e ) -{ - assert( e.get_delay_steps() > 0 ); - - /* We need to compute the absolute time stamp of the delivery time - of the spike, since spikes might spend longer than min_delay_ - in the queue. The time is computed according to Time Memo, Rule 3. - */ - const long Tdeliver = e.get_stamp().get_steps() + e.get_delay_steps() - 1; - B_.events_.add_spike( e.get_rel_delivery_steps( nest::kernel().simulation_manager.get_slice_origin() ), - Tdeliver, - e.get_offset(), - e.get_weight() * e.get_multiplicity() ); -} - -void -nest::iaf_psc_alpha_canon::handle( CurrentEvent& e ) -{ - assert( e.get_delay_steps() > 0 ); - - const double c = e.get_current(); - const double w = e.get_weight(); - - // add weighted current; HEP 2002-10-04 - B_.currents_.add_value( e.get_rel_delivery_steps( nest::kernel().simulation_manager.get_slice_origin() ), w * c ); -} - -void -nest::iaf_psc_alpha_canon::handle( DataLoggingRequest& e ) -{ - B_.logger_.handle( e ); -} - -// auxiliary functions --------------------------------------------- - -void -nest::iaf_psc_alpha_canon::propagate_( const double dt ) -{ - // needed in any case - const double ps_e_TauSyn = numerics::expm1( -dt / P_.tau_syn_ ); - - // y3_ remains unchanged at 0.0 while neuron is refractory - if ( not S_.is_refractory_ ) - { - const double ps_e_Tau = numerics::expm1( -dt / P_.tau_m_ ); - const double ps_P30 = -P_.tau_m_ / P_.c_m_ * ps_e_Tau; - const double ps_P31 = - V_.gamma_sq_ * ps_e_Tau - V_.gamma_sq_ * ps_e_TauSyn - dt * V_.gamma_ * ps_e_TauSyn - dt * V_.gamma_; - const double ps_P32 = V_.gamma_ * ps_e_Tau - V_.gamma_ * ps_e_TauSyn; - S_.y3_ = ps_P30 * ( P_.I_e_ + S_.y0_ ) + ps_P31 * S_.y1_ + ps_P32 * S_.y2_ + ps_e_Tau * S_.y3_ + S_.y3_; - - // lower bound of membrane potential - S_.y3_ = ( S_.y3_ < P_.U_min_ ? P_.U_min_ : S_.y3_ ); - } - - // now the synaptic components - S_.y2_ = ps_e_TauSyn * dt * S_.y1_ + ps_e_TauSyn * S_.y2_ + dt * S_.y1_ + S_.y2_; - S_.y1_ = ps_e_TauSyn * S_.y1_ + S_.y1_; - - return; -} - -void -nest::iaf_psc_alpha_canon::emit_spike_( Time const& origin, const long lag, const double t0, const double dt ) -{ - // we know that the potential is subthreshold at t0, super at t0+dt - - // compute spike time relative to beginning of step - S_.last_spike_step_ = origin.get_steps() + lag + 1; - S_.last_spike_offset_ = V_.h_ms_ - ( t0 + thresh_find_( dt ) ); - - // reset neuron and make it refractory - S_.y3_ = P_.U_reset_; - S_.is_refractory_ = true; - - // send spike - set_spiketime( Time::step( S_.last_spike_step_ ), S_.last_spike_offset_ ); - SpikeEvent se; - se.set_offset( S_.last_spike_offset_ ); - kernel().event_delivery_manager.send( *this, se, lag ); - - return; -} - -void -nest::iaf_psc_alpha_canon::emit_instant_spike_( Time const& origin, const long lag, const double spike_offs ) -{ - assert( S_.y3_ >= P_.U_th_ ); // ensure we are superthreshold - - // set stamp and offset for spike - S_.last_spike_step_ = origin.get_steps() + lag + 1; - S_.last_spike_offset_ = spike_offs; - - // reset neuron and make it refractory - S_.y3_ = P_.U_reset_; - S_.is_refractory_ = true; - - // send spike - set_spiketime( Time::step( S_.last_spike_step_ ), S_.last_spike_offset_ ); - SpikeEvent se; - se.set_offset( S_.last_spike_offset_ ); - kernel().event_delivery_manager.send( *this, se, lag ); - - return; -} - -// finds threshpassing -inline double -nest::iaf_psc_alpha_canon::thresh_find_( double const dt ) const -{ - switch ( P_.Interpol_ ) - { - case NO_INTERPOL: - return dt; - case LINEAR: - return thresh_find1_( dt ); - case QUADRATIC: - return thresh_find2_( dt ); - case CUBIC: - return thresh_find3_( dt ); - default: - throw BadProperty( "Invalid interpolation order in iaf_psc_alpha_canon." ); - } -} - -// finds threshpassing via linear interpolation -double -nest::iaf_psc_alpha_canon::thresh_find1_( double const dt ) const -{ - double tau = ( P_.U_th_ - V_.y3_before_ ) * dt / ( S_.y3_ - V_.y3_before_ ); - return tau; -} - -// finds threshpassing via quadratic interpolation -double -nest::iaf_psc_alpha_canon::thresh_find2_( double const dt ) const -{ - const double h_sq = dt * dt; - const double derivative = -V_.y3_before_ / P_.tau_m_ + ( P_.I_e_ + V_.y0_before_ + V_.y2_before_ ) / P_.c_m_; - - const double a = ( -V_.y3_before_ / h_sq ) + ( S_.y3_ / h_sq ) - ( derivative / dt ); - const double b = derivative; - const double c = V_.y3_before_; - - const double sqr_ = std::sqrt( b * b - 4 * a * c + 4 * a * P_.U_th_ ); - const double tau1 = ( -b + sqr_ ) / ( 2 * a ); - const double tau2 = ( -b - sqr_ ) / ( 2 * a ); - if ( tau1 >= 0 ) - { - return tau1; - } - else if ( tau2 >= 0 ) - { - return tau2; - } - else - { - return thresh_find1_( dt ); - } -} - -double -nest::iaf_psc_alpha_canon::thresh_find3_( double const dt ) const -{ - const double h_ms = dt; - const double h_sq = h_ms * h_ms; - const double h_cb = h_sq * h_ms; - - const double deriv_t1 = -V_.y3_before_ / P_.tau_m_ + ( P_.I_e_ + V_.y0_before_ + V_.y2_before_ ) / P_.c_m_; - const double deriv_t2 = -S_.y3_ / P_.tau_m_ + ( P_.I_e_ + S_.y0_ + S_.y2_ ) / P_.c_m_; - - const double w3_ = ( 2 * V_.y3_before_ / h_cb ) - ( 2 * S_.y3_ / h_cb ) + ( deriv_t1 / h_sq ) + ( deriv_t2 / h_sq ); - const double w2_ = - -( 3 * V_.y3_before_ / h_sq ) + ( 3 * S_.y3_ / h_sq ) - ( 2 * deriv_t1 / h_ms ) - ( deriv_t2 / h_ms ); - const double w1_ = deriv_t1; - const double w0_ = V_.y3_before_; - - // normal form : x^3 + r*x^2 + s*x + t with coefficients : r, s, t - const double r = w2_ / w3_; - const double s = w1_ / w3_; - const double t = ( w0_ - P_.U_th_ ) / w3_; - const double r_sq = r * r; - - // substitution y = x + r/3 : y^3 + p*y + q == 0 - const double p = -r_sq / 3 + s; - const double q = 2 * ( r_sq * r ) / 27 - r * s / 3 + t; - - // discriminante - const double D = std::pow( ( p / 3 ), 3 ) + std::pow( ( q / 2 ), 2 ); - - double tau1; - double tau2; - double tau3; - - if ( D < 0 ) - { - const double roh = std::sqrt( -( p * p * p ) / 27 ); - const double phi = std::acos( -q / ( 2 * roh ) ); - const double a = 2 * std::pow( roh, ( 1.0 / 3.0 ) ); - tau1 = ( a * std::cos( phi / 3 ) ) - r / 3; - tau2 = ( a * std::cos( phi / 3 + 2 * numerics::pi / 3 ) ) - r / 3; - tau3 = ( a * std::cos( phi / 3 + 4 * numerics::pi / 3 ) ) - r / 3; - } - else - { - const double sgnq = ( q >= 0 ? 1 : -1 ); - const double u = -sgnq * std::pow( std::fabs( q ) / 2.0 + std::sqrt( D ), 1.0 / 3.0 ); - const double v = -p / ( 3 * u ); - tau1 = ( u + v ) - r / 3; - if ( tau1 >= 0 ) - { - return tau1; - } - else - { - return thresh_find2_( dt ); - } - } - - // set tau to the smallest root above 0 - - double tau = ( tau1 >= 0 ) ? tau1 : 2 * h_ms; - if ( tau2 >= 0 and tau2 < tau ) - { - tau = tau2; - } - if ( tau3 >= 0 and tau3 < tau ) - { - tau = tau3; - } - return ( tau <= V_.h_ms_ ) ? tau : thresh_find2_( dt ); -} diff --git a/models/iaf_psc_alpha_canon.h b/models/iaf_psc_alpha_canon.h deleted file mode 100644 index 3a27fb9e2b..0000000000 --- a/models/iaf_psc_alpha_canon.h +++ /dev/null @@ -1,538 +0,0 @@ -/* - * iaf_psc_alpha_canon.h - * - * This file is part of NEST. - * - * Copyright (C) 2004 The NEST Initiative - * - * NEST is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * NEST is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with NEST. If not, see . - * - */ - -#ifndef IAF_PSC_ALPHA_CANON_H -#define IAF_PSC_ALPHA_CANON_H - -// C++ includes: -#include - -// Generated includes: -#include "config.h" - -// Includes from nestkernel: -#include "archiving_node.h" -#include "connection.h" -#include "event.h" -#include "nest_types.h" -#include "ring_buffer.h" -#include "slice_ring_buffer.h" -#include "universal_data_logger.h" - -namespace nest -{ - -/* BeginUserDocs: neuron, integrate-and-fire, current-based, precise - -Short description -+++++++++++++++++ - -Current-based leaky integrate-and-fire neuron with alpha-shaped -postsynaptic currents - canonical implementation of precise spike -timing version - -Description -+++++++++++ - -.. note:: - - This model is deprecated and will be removed in NEST 3. - Please use ``iaf_psc_alpha_ps`` instead. - -``iaf_psc_alpha_canon`` is the "canonical" implementatoin of the leaky -integrate-and-fire model neuron with alpha-shaped postsynaptic -currents in the sense of [1]_. This is the most exact implementation -available. - -PSCs are normalized to an amplitude of 1pA. - -The canonical implementation handles neuronal dynamics in a locally -event-based manner with in coarse time grid defined by the minimum -delay in the network, see [1]_. Incoming spikes are applied at the -precise moment of their arrival, while the precise time of outgoing -spikes is determined by interpolation once a threshold crossing has -been detected. Return from refractoriness occurs precisly at spike -time plus refractory period. - -This implementation is more complex than the plain ``iaf_psc_alpha`` -neuron, but achieves much higher precision. In particular, it does not -suffer any binning of spike times to grid points. Depending on your -application, the canonical application may provide superior overall -performance given an accuracy goal; see [1]_ for details. Subthreshold -dynamics are integrated using exact integration between events [2]_. - -.. note:: - - Please note that this node is capable of sending precise spike - times to target nodes (on-grid spike time plus offset). - - A further improvement of precise simulation is implemented in - ``iaf_psc_exp_ps`` based on [3]_. - -.. note:: - - - If ``tau_m`` is very close to ``tau_syn_ex`` or ``tau_syn_in``, the model - will numerically behave as if ``tau_m`` is equal to ``tau_syn_ex`` or - ``tau_syn_in``, respectively, to avoid numerical instabilities. - - For implementation details see the - `IAF_neurons_singularity <../model_details/IAF_neurons_singularity.ipynb>`_ notebook. - -This model transmits precise spike times to target nodes (on-grid spike -time and offset). If this node is connected to a ``spike_recorder``, the -property "precise_times" of the ``spike_recorder`` has to be set to true in -order to record the offsets in addition to the on-grid spike times. - -The ``iaf_psc_delta_ps`` neuron accepts connections transmitting -``CurrentEvents``. These events transmit stepwise-constant currents which -can only change at on-grid times. - -For details about exact subthreshold integration, please see -:doc:`../neurons/exact-integration`. - -Parameters -++++++++++ - -The following parameters can be set in the status dictionary. - -=============== ====== ========================================================== - V_m mV Membrane potential - E_L mV Resting membrane potential - V_min mV Absolute lower value for the membrane potential. - C_m pF Capacity of the membrane - tau_m ms Membrane time constant - t_ref ms Duration of refractory period - V_th mV Spike threshold - V_reset mV Reset potential of the membrane - tau_syn ms Rise time of the synaptic alpha function - I_e pA Constant external input current - Interpol_Order (int) Interpolation order for spike time: - 0-none, 1-linear, 2-quadratic, 3-cubic -=============== ====== ========================================================== - -References -++++++++++ - -.. [1] Morrison A, Straube S, Plesser H E, & Diesmann M (2006) Exact Subthreshold - Integration with Continuous Spike Times in Discrete Time Neural Network - Simulations. To appear in Neural Computation. -.. [2] Rotter S & Diesmann M (1999) Exact simulation of time-invariant linear - systems with applications to neuronal modeling. Biologial Cybernetics - 81:381-402. -.. [3] Hanuschkin A, Kunkel S, Helias M, Morrison A & Diesmann M (2010) - A general and efficient method for incorporating exact spike times in - globally time-driven simulations Front Neuroinformatics, 4:113 - -Sends -+++++ - -SpikeEvent - -Receives -++++++++ - -SpikeEvent, CurrentEvent, DataLoggingRequest - -See also -++++++++ - -iaf_psc_alpha_ps, iaf_psc_alpha, iaf_psc_alpha_presc, iaf_psc_exp_ps - -EndUserDocs */ - -class iaf_psc_alpha_canon : public ArchivingNode -{ -public: - /** Basic constructor. - This constructor should only be used by GenericModel to create - model prototype instances. - */ - iaf_psc_alpha_canon(); - - /** Copy constructor. - GenericModel::create_() uses the copy constructor to clone - actual model instances from the prototype instance. - - @note The copy constructor MUST NOT be used to create nodes based - on nodes that have been placed in the network. - */ - iaf_psc_alpha_canon( const iaf_psc_alpha_canon& ); - - /** - * Import sets of overloaded virtual functions. - * @see Technical Issues / Virtual Functions: Overriding, Overloading, and - * Hiding - */ - using Node::handle; - using Node::handles_test_event; - - port send_test_event( Node&, rport, synindex, bool ) override; - - port handles_test_event( SpikeEvent&, rport ) override; - port handles_test_event( CurrentEvent&, rport ) override; - port handles_test_event( DataLoggingRequest&, rport ) override; - - void handle( SpikeEvent& ) override; - void handle( CurrentEvent& ) override; - void handle( DataLoggingRequest& ) override; - - bool - is_off_grid() const override - { - return true; - } // uses off_grid events - - void get_status( DictionaryDatum& ) const override; - void set_status( const DictionaryDatum& ) override; - -private: - /** @name Interface functions - * @note These functions are private, so that they can be accessed - * only through a Node*. - */ - //@{ - void init_buffers_() override; - void pre_run_hook() override; - - /** - * Time Evolution Operator. - * - * update() promotes the state of the neuron from origin+from to origin+to. - * It does so in steps of the resolution h. Within each step, time is - * advanced from event to event, as retrieved from the spike queue. - * - * Return from refractoriness is handled as a special event in the - * queue, which is marked by a weight that is GSL_NAN. This greatly - * simplifies the code. - * - * For steps, during which no events occur, the precomputed propagator matrix - * is used. For other steps, the propagator matrix is computed as needed. - * - * While the neuron is refractory, membrane potential (y3_) is - * clamped to U_reset_. - */ - void update( Time const& origin, const long from, const long to ) override; - - //@} - - /** - * Propagate neuron state. - * Propagate the neuron's state by dt. - * @param dt Interval over which to propagate - */ - void propagate_( const double dt ); - - /** - * Trigger interpolation method to find the precise spike time - * within the mini-timestep (t0,t0+dt] assuming that the membrane - * potential was below threshold at t0 and above at t0+dt. Emit - * the spike and reset the neuron. - * - * @param origin Time stamp at beginning of slice - * @param lag Time step within slice - * @param t0 Beginning of mini-timestep - * @param dt Duration of mini-timestep - */ - void emit_spike_( Time const& origin, const long lag, const double t0, const double dt ); - - /** - * Instantaneously emit a spike at the precise time defined by - * origin, lag and spike_offset and reset the neuron. - * - * @param origin Time stamp at beginning of slice - * @param lag Time step within slice - * @param spike_offset Time offset for spike - */ - void emit_instant_spike_( Time const& origin, const long lag, const double spike_offset ); - - /** @name Threshold-crossing interpolation - * These functions determine the time of threshold crossing using - * interpolation, one function per interpolation - * order. thresh_find() is the driver function and the only one to - * be called directly. - */ - //@{ - - /** Interpolation orders. */ - enum interpOrder - { - NO_INTERPOL, - LINEAR, - QUADRATIC, - CUBIC, - END_INTERP_ORDER - }; - - /** - * Localize threshold crossing. - * Driver function to invoke the correct interpolation function - * for the chosen interpolation order. - * @param double length of interval since previous event - * @returns time from previous event to threshold crossing - */ - double thresh_find_( double const ) const; - double thresh_find1_( double const ) const; - double thresh_find2_( double const ) const; - double thresh_find3_( double const ) const; - //@} - - - // The next two classes need to be friends to access the State_ class/member - friend class RecordablesMap< iaf_psc_alpha_canon >; - friend class UniversalDataLogger< iaf_psc_alpha_canon >; - - // ---------------------------------------------------------------- - - /** - * Independent parameters of the model. - */ - struct Parameters_ - { - - /** Membrane time constant in ms. */ - double tau_m_; - - /** Time constant of synaptic current in ms. */ - double tau_syn_; - - /** Membrane capacitance in pF. */ - double c_m_; - - /** Refractory period in ms. */ - double t_ref_; - - /** Resting potential in mV. */ - double E_L_; - - /** External DC current [pA] */ - double I_e_; - - /** Threshold, RELATIVE TO RESTING POTENTAIL(!). - I.e. the real threshold is U_th_ + E_L_. */ - double U_th_; - - /** Lower bound, RELATIVE TO RESTING POTENTAIL(!). - I.e. the real lower bound is U_min_+E_L_. */ - double U_min_; - - /** Reset potential. - At threshold crossing, the membrane potential is reset to this - value. Relative to resting potential. - */ - double U_reset_; - - /** Interpolation order */ - interpOrder Interpol_; - - Parameters_(); //!< Sets default parameter values - - void get( DictionaryDatum& ) const; //!< Store current values in dictionary - - /** Set values from dictionary. - * @returns Change in reversal potential E_L, to be passed to State_::set() - */ - double set( const DictionaryDatum&, Node* ); - }; - - // ---------------------------------------------------------------- - - /** - * State variables of the model. - */ - struct State_ - { - double y0_; //!< external input current - double y1_; //!< alpha current, first component - double y2_; //!< alpha current, second component - double y3_; //!< Membrane pot. rel. to resting pot. E_L_. - bool is_refractory_; //!< true while refractory - long last_spike_step_; //!< time stamp of most recent spike - double last_spike_offset_; //!< offset of most recent spike - - State_(); //!< Default initialization - - void get( DictionaryDatum&, const Parameters_& ) const; - - /** Set values from dictionary. - * @param dictionary to take data from - * @param current parameters - * @param Change in reversal potential E_L specified by this dict - */ - void set( const DictionaryDatum&, const Parameters_&, double, Node* ); - }; - - // ---------------------------------------------------------------- - - /** - * Buffers of the model. - */ - struct Buffers_ - { - Buffers_( iaf_psc_alpha_canon& ); - Buffers_( const Buffers_&, iaf_psc_alpha_canon& ); - - /** - * Queue for incoming events. - * @note Handles also pseudo-events marking return from refractoriness. - */ - SliceRingBuffer events_; - RingBuffer currents_; - - //! Logger for all analog data - UniversalDataLogger< iaf_psc_alpha_canon > logger_; - }; - - // ---------------------------------------------------------------- - - /** - * Internal variables of the model. - */ - struct Variables_ - { - double h_ms_; //!< time resolution in ms - double PSCInitialValue_; //!< e / tau_syn - long refractory_steps_; //!< refractory time in steps - double gamma_; //!< 1/c_m * 1/(1/tau_syn - 1/tau_m) - double gamma_sq_; //!< 1/c_m * 1/(1/tau_syn - 1/tau_m)^2 - double expm1_tau_m_; //!< exp(-h/tau_m) - 1 - double expm1_tau_syn_; //!< exp(-h/tau_syn) - 1 - double P30_; //!< progagator matrix elem, 3rd row - double P31_; //!< progagator matrix elem, 3rd row - double P32_; //!< progagator matrix elem, 3rd row - double y0_before_; //!< y0_ at beginning of mini-step, forinterpolation - double y2_before_; //!< y2_ at beginning of mini-step, for interpolation - double y3_before_; //!< y3_ at beginning of mini-step, for interpolation - }; - - // Access functions for UniversalDataLogger ------------------------------- - - //! Read out the real membrane potential - double - get_V_m_() const - { - return S_.y3_ + P_.E_L_; - } - - //! Read out state variable y1 - double - get_y1_() const - { - return S_.y1_; - } - - //! Read out state variable y2 - double - get_y2_() const - { - return S_.y2_; - } - - // ---------------------------------------------------------------- - - /** - * @defgroup iaf_psc_alpha_data - * Instances of private data structures for the different types - * of data pertaining to the model. - * @note The order of definitions is important for speed. - * @{ - */ - Parameters_ P_; - State_ S_; - Variables_ V_; - Buffers_ B_; - /** @} */ - - //! Mapping of recordables names to access functions - static RecordablesMap< iaf_psc_alpha_canon > recordablesMap_; -}; - -inline port -nest::iaf_psc_alpha_canon::send_test_event( Node& target, rport receptor_type, synindex, bool ) -{ - SpikeEvent e; - e.set_sender( *this ); - return target.handles_test_event( e, receptor_type ); -} - -inline port -iaf_psc_alpha_canon::handles_test_event( SpikeEvent&, rport receptor_type ) -{ - if ( receptor_type != 0 ) - { - throw UnknownReceptorType( receptor_type, get_name() ); - } - return 0; -} - -inline port -iaf_psc_alpha_canon::handles_test_event( CurrentEvent&, rport receptor_type ) -{ - if ( receptor_type != 0 ) - { - throw UnknownReceptorType( receptor_type, get_name() ); - } - return 0; -} - -inline port -iaf_psc_alpha_canon::handles_test_event( DataLoggingRequest& dlr, rport receptor_type ) -{ - if ( receptor_type != 0 ) - { - throw UnknownReceptorType( receptor_type, get_name() ); - } - return B_.logger_.connect_logging_device( dlr, recordablesMap_ ); -} - -inline void -iaf_psc_alpha_canon::get_status( DictionaryDatum& d ) const -{ - P_.get( d ); - S_.get( d, P_ ); - ArchivingNode::get_status( d ); - - ( *d )[ names::recordables ] = recordablesMap_.get_list(); -} - -inline void -iaf_psc_alpha_canon::set_status( const DictionaryDatum& d ) -{ - Parameters_ ptmp = P_; // temporary copy in case of errors - const double delta_EL = ptmp.set( d, this ); // throws if BadProperty - State_ stmp = S_; // temporary copy in case of errors - stmp.set( d, ptmp, delta_EL, this ); // throws if BadProperty - - // We now know that (ptmp, stmp) are consistent. We do not - // write them back to (P_, S_) before we are also sure that - // the properties to be set in the parent class are internally - // consistent. - ArchivingNode::set_status( d ); - - // if we get here, temporaries contain consistent set of properties - P_ = ptmp; - S_ = stmp; -} - -} // namespace - -#endif // IAF_PSC_ALPHA_CANON_H diff --git a/models/pp_pop_psc_delta.cpp b/models/pp_pop_psc_delta.cpp deleted file mode 100644 index ef88c4d2a1..0000000000 --- a/models/pp_pop_psc_delta.cpp +++ /dev/null @@ -1,471 +0,0 @@ -/* - * pp_pop_psc_delta.cpp - * - * This file is part of NEST. - * - * Copyright (C) 2004 The NEST Initiative - * - * NEST is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * NEST is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with NEST. If not, see . - * - */ - -#include "pp_pop_psc_delta.h" - -// C++ includes: -#include - -// Includes from libnestutil: -#include "compose.hpp" -#include "dict_util.h" -#include "numerics.h" - -// Includes from nestkernel: -#include "exceptions.h" -#include "kernel_manager.h" -#include "universal_data_logger_impl.h" - -// Includes from sli: -#include "dict.h" -#include "dictutils.h" - -namespace nest -{ -/* ---------------------------------------------------------------- - * Recordables map - * ---------------------------------------------------------------- */ - -RecordablesMap< pp_pop_psc_delta > pp_pop_psc_delta::recordablesMap_; - -// Override the create() method with one call to RecordablesMap::insert_() -// for each quantity to be recorded. -template <> -void -RecordablesMap< pp_pop_psc_delta >::create() -{ - // use standard names whereever you can for consistency! - insert_( names::V_m, &pp_pop_psc_delta::get_V_m_ ); - // n_events instead of E_sfa - insert_( names::n_events, &pp_pop_psc_delta::get_n_events_ ); -} - -/* ---------------------------------------------------------------- - * Default constructors defining default parameters and state - * ---------------------------------------------------------------- */ - -nest::pp_pop_psc_delta::Parameters_::Parameters_() - : N_( 100 ) - , tau_m_( 10.0 ) // ms - , c_m_( 250.0 ) // pF - , rho_0_( 10.0 ) // 1/s - , delta_u_( 1.0 ) // mV - , len_kernel_( 5.0 ) - , I_e_( 0.0 ) // pA -{ - tau_eta_.push_back( 10.0 ); - val_eta_.push_back( 0.0 ); -} - -nest::pp_pop_psc_delta::State_::State_() - : y0_( 0.0 ) - , h_( 0.0 ) - , p_age_occupations_( 0 ) - , p_n_spikes_past_( 0 ) - , initialized_( false ) -{ - age_occupations_.clear(); - thetas_ages_.clear(); - n_spikes_past_.clear(); - n_spikes_ages_.clear(); - rhos_ages_.clear(); -} - -/* ---------------------------------------------------------------- - * Parameter and state extractions and manipulation functions - * ---------------------------------------------------------------- */ - -void -nest::pp_pop_psc_delta::Parameters_::get( DictionaryDatum& d ) const -{ - def< long >( d, names::N, N_ ); - def< double >( d, names::rho_0, rho_0_ ); - def< double >( d, names::delta_u, delta_u_ ); - def< double >( d, names::I_e, I_e_ ); - def< double >( d, names::C_m, c_m_ ); - def< double >( d, names::tau_m, tau_m_ ); - def< double >( d, names::len_kernel, len_kernel_ ); - - ArrayDatum tau_eta_list_ad( tau_eta_ ); - def< ArrayDatum >( d, names::tau_eta, tau_eta_list_ad ); - - ArrayDatum val_eta_list_ad( val_eta_ ); - def< ArrayDatum >( d, names::val_eta, val_eta_list_ad ); -} - -void -nest::pp_pop_psc_delta::Parameters_::set( const DictionaryDatum& d, Node* node ) -{ - - updateValueParam< long >( d, names::N, N_, node ); - updateValueParam< double >( d, names::rho_0, rho_0_, node ); - updateValueParam< double >( d, names::delta_u, delta_u_, node ); - updateValueParam< double >( d, names::len_kernel, len_kernel_, node ); - - updateValueParam< double >( d, names::I_e, I_e_, node ); - updateValueParam< double >( d, names::C_m, c_m_, node ); - updateValueParam< double >( d, names::tau_m, tau_m_, node ); - updateValue< std::vector< double > >( d, names::tau_eta, tau_eta_ ); - updateValue< std::vector< double > >( d, names::val_eta, val_eta_ ); - - - if ( tau_eta_.size() != val_eta_.size() ) - { - throw BadProperty( - String::compose( "'tau_eta' and 'val_eta' need to have the same dimension.\nSize of " - "tau_eta: %1\nSize of val_eta: %2", - tau_eta_.size(), - val_eta_.size() ) ); - } - if ( c_m_ <= 0 ) - { - throw BadProperty( "Capacitance must be strictly positive." ); - } - if ( tau_m_ <= 0 ) - { - throw BadProperty( "The time constants must be strictly positive." ); - } - - for ( unsigned int i = 0; i < tau_eta_.size(); i++ ) - { - if ( tau_eta_[ i ] <= 0 ) - { - throw BadProperty( "All time constants must be strictly positive." ); - } - } - if ( N_ <= 0 ) - { - throw BadProperty( "Number of neurons must be positive." ); - } - if ( rho_0_ < 0 ) - { - throw BadProperty( "Rho_0 cannot be negative." ); - } - if ( delta_u_ <= 0 ) - { - throw BadProperty( "Delta_u must be positive." ); - } -} - -void -nest::pp_pop_psc_delta::State_::get( DictionaryDatum& d, const Parameters_& ) const -{ - def< double >( d, names::V_m, h_ ); // Filterd version of input - int n_spikes = n_spikes_past_.size() > 0 ? n_spikes_past_[ p_n_spikes_past_ ] - : 0; // return 0 if n_spikes_past_ has not been initialized yet - def< long >( d, names::n_events, n_spikes ); // Number of generated spikes -} - -void -nest::pp_pop_psc_delta::State_::set( const DictionaryDatum& d, const Parameters_&, Node* node ) -{ - updateValueParam< double >( d, names::V_m, h_, node ); - initialized_ = false; // vectors of the state should be initialized with new parameter set. -} - -nest::pp_pop_psc_delta::Buffers_::Buffers_( pp_pop_psc_delta& n ) - : logger_( n ) -{ -} - -nest::pp_pop_psc_delta::Buffers_::Buffers_( const Buffers_&, pp_pop_psc_delta& n ) - : logger_( n ) -{ -} - -/* ---------------------------------------------------------------- - * Default and copy constructor for node - * ---------------------------------------------------------------- */ - -nest::pp_pop_psc_delta::pp_pop_psc_delta() - : Node() - , P_() - , S_() - , B_( *this ) -{ - recordablesMap_.create(); -} - -nest::pp_pop_psc_delta::pp_pop_psc_delta( const pp_pop_psc_delta& n ) - : Node( n ) - , P_( n.P_ ) - , S_( n.S_ ) - , B_( n.B_, *this ) -{ -} - -/* ---------------------------------------------------------------- - * Node initialization functions - * ---------------------------------------------------------------- */ - -void -nest::pp_pop_psc_delta::init_buffers_() -{ - B_.spikes_.clear(); //!< includes resize - B_.currents_.clear(); //!< includes resize - B_.logger_.reset(); //!< includes resize -} - - -void -nest::pp_pop_psc_delta::pre_run_hook() -{ - - if ( P_.tau_eta_.size() == 0 ) - { - throw BadProperty( "Time constant array should not be empty. " ); - } - - if ( P_.val_eta_.size() == 0 ) - { - throw BadProperty( "Adaptation value array should not be empty. " ); - } - - B_.logger_.init(); - - V_.h_ = Time::get_resolution().get_ms(); - V_.rng_ = get_vp_specific_rng( get_thread() ); - V_.min_double_ = std::numeric_limits< double >::min(); - - double tau_eta_max = -1; // finding max of tau_eta_ - - for ( unsigned int j = 0; j < P_.tau_eta_.size(); j++ ) - { - if ( P_.tau_eta_.at( j ) > tau_eta_max ) - { - tau_eta_max = P_.tau_eta_.at( j ); - } - } - - V_.len_eta_ = tau_eta_max * ( P_.len_kernel_ / V_.h_ ); - - V_.P33_ = std::exp( -V_.h_ / P_.tau_m_ ); - V_.P30_ = 1 / P_.c_m_ * ( 1 - V_.P33_ ) * P_.tau_m_; - - // initializing internal state - if ( not S_.initialized_ ) - { - - V_.len_eta_ = tau_eta_max * ( P_.len_kernel_ / V_.h_ ); - - for ( int j = 0; j < V_.len_eta_; j++ ) - { - S_.n_spikes_past_.push_back( 0 ); - } - - std::vector< double > ts; - ts.clear(); - for ( int j = 0; j < V_.len_eta_; j++ ) - { - ts.push_back( j * V_.h_ ); - } - - double temp = 0; - - for ( int j = 0; j < V_.len_eta_; j++ ) - { - for ( unsigned int i = 0; i < P_.tau_eta_.size(); i++ ) - { - temp += std::exp( -ts[ j ] / P_.tau_eta_.at( i ) ) * ( -P_.val_eta_.at( i ) ); - } - - V_.theta_kernel_.push_back( temp ); - V_.eta_kernel_.push_back( std::exp( temp ) - 1 ); - temp = 0; - } - - // Set all except last state vector elements to zero, then fill last element with initial value - for ( int j = 0; j < V_.len_eta_ - 1; j++ ) - { - S_.age_occupations_.push_back( 0 ); - S_.thetas_ages_.push_back( 0 ); - S_.n_spikes_ages_.push_back( 0 ); - S_.rhos_ages_.push_back( 0 ); - } - S_.age_occupations_.push_back( P_.N_ ); - S_.thetas_ages_.push_back( 0 ); - S_.n_spikes_ages_.push_back( 0 ); - S_.rhos_ages_.push_back( 0 ); - - S_.initialized_ = true; - } -} - -/* ---------------------------------------------------------------- - * Update and spike handling functions - */ - -void -nest::pp_pop_psc_delta::update( Time const& origin, const long from, const long to ) -{ - assert( to >= 0 and static_cast< delay >( from ) < kernel().connection_manager.get_min_delay() ); - assert( from < to ); - - for ( long lag = from; lag < to; ++lag ) - { - - - S_.h_ = S_.h_ * V_.P33_ + V_.P30_ * ( S_.y0_ + P_.I_e_ ) + B_.spikes_.get_value( lag ); - - - // get_thetas_ages - std::vector< double > tmp_vector; - double integral = 0; - tmp_vector.clear(); - - - for ( unsigned int i = 0; i < V_.eta_kernel_.size(); i++ ) - { - tmp_vector.push_back( V_.eta_kernel_[ i ] - * S_.n_spikes_past_[ ( S_.p_n_spikes_past_ + i ) % S_.n_spikes_past_.size() ] * V_.h_ * 0.001 ); - integral += tmp_vector[ i ]; - } - - S_.thetas_ages_.clear(); - S_.thetas_ages_.push_back( integral ); - - for ( unsigned int i = 1; i < V_.eta_kernel_.size(); i++ ) - { - S_.thetas_ages_.push_back( S_.thetas_ages_[ i - 1 ] - tmp_vector[ i - 1 ] ); - } - - for ( unsigned int i = 0; i < V_.eta_kernel_.size(); i++ ) - { - S_.thetas_ages_[ i ] += V_.theta_kernel_[ i ]; - } - - S_.thetas_ages_.push_back( 0 ); - - // get_escape_rate - for ( unsigned int i = 0; i < S_.rhos_ages_.size(); i++ ) - { - S_.rhos_ages_[ i ] = P_.rho_0_ * std::exp( ( S_.h_ + S_.thetas_ages_[ i ] ) / P_.delta_u_ ); - } - - - double p_argument; - - // generate_spikes - for ( unsigned int i = 0; i < S_.age_occupations_.size(); i++ ) - { - - if ( S_.age_occupations_[ ( S_.p_age_occupations_ + i ) % S_.age_occupations_.size() ] > 0 ) - { - - p_argument = -numerics::expm1( -S_.rhos_ages_[ i ] * V_.h_ * 0.001 ); // V_.h_ is in ms, S_.rhos_ages_ is in Hz - - if ( p_argument > V_.min_double_ ) - { - const auto n = S_.age_occupations_[ ( S_.p_age_occupations_ + i ) % S_.age_occupations_.size() ]; - binomial_distribution::param_type param( n, p_argument ); - S_.n_spikes_ages_[ i ] = V_.bino_dist_( V_.rng_, param ); - } - else - { - S_.n_spikes_ages_[ i ] = 0; - } - } - else - { - S_.n_spikes_ages_[ i ] = 0; - } - } - - - S_.p_n_spikes_past_ = - ( S_.p_n_spikes_past_ - 1 + S_.n_spikes_past_.size() ) % S_.n_spikes_past_.size(); // shift to the right - - int temp_sum = 0; - for ( unsigned int i = 0; i < S_.n_spikes_ages_.size(); i++ ) // cumulative sum - { - temp_sum += S_.n_spikes_ages_[ i ]; - } - - S_.n_spikes_past_[ S_.p_n_spikes_past_ ] = temp_sum; - - - // update_age_occupations - for ( unsigned int i = 0; i < S_.age_occupations_.size(); i++ ) - { - S_.age_occupations_[ ( S_.p_age_occupations_ + i ) % S_.age_occupations_.size() ] -= S_.n_spikes_ages_[ i ]; - } - - int last_element_value = S_.age_occupations_[ ( S_.p_age_occupations_ - 1 + S_.age_occupations_.size() ) - % S_.age_occupations_.size() ]; // save the last element - - S_.p_age_occupations_ = - ( S_.p_age_occupations_ - 1 + S_.age_occupations_.size() ) % S_.age_occupations_.size(); // shift to the right - S_.age_occupations_[ ( S_.p_age_occupations_ - 1 + S_.age_occupations_.size() ) % S_.age_occupations_.size() ] += - last_element_value; - S_.age_occupations_[ S_.p_age_occupations_ ] = S_.n_spikes_past_[ S_.p_n_spikes_past_ ]; - - // Set new input current - S_.y0_ = B_.currents_.get_value( lag ); - - // Voltage logging - B_.logger_.record_data( origin.get_steps() + lag ); - - - // test if S_.n_spikes_past_[S_.p_n_spikes_past_]!=0, generate spike and - // send this number as the parameter - - if ( S_.n_spikes_past_[ S_.p_n_spikes_past_ ] > 0 ) // Is there any spike? - { - SpikeEvent se; - se.set_multiplicity( S_.n_spikes_past_[ S_.p_n_spikes_past_ ] ); - kernel().event_delivery_manager.send( *this, se, lag ); - } - } -} - -void -nest::pp_pop_psc_delta::handle( SpikeEvent& e ) -{ - assert( e.get_delay_steps() > 0 ); - - // EX: We must compute the arrival time of the incoming spike - // explicitly, since it depends on delay and offset within - // the update cycle. The way it is done here works, but - // is clumsy and should be improved. - B_.spikes_.add_value( - e.get_rel_delivery_steps( kernel().simulation_manager.get_slice_origin() ), e.get_weight() * e.get_multiplicity() ); -} - -void -nest::pp_pop_psc_delta::handle( CurrentEvent& e ) -{ - assert( e.get_delay_steps() > 0 ); - - const double c = e.get_current(); - const double w = e.get_weight(); - - // Add weighted current; HEP 2002-10-04 - B_.currents_.add_value( e.get_rel_delivery_steps( kernel().simulation_manager.get_slice_origin() ), w * c ); -} - -void -nest::pp_pop_psc_delta::handle( DataLoggingRequest& e ) -{ - B_.logger_.handle( e ); -} - -} // namespace diff --git a/models/pp_pop_psc_delta.h b/models/pp_pop_psc_delta.h deleted file mode 100644 index 0f1295eaff..0000000000 --- a/models/pp_pop_psc_delta.h +++ /dev/null @@ -1,404 +0,0 @@ -/* - * pp_pop_psc_delta.h - * - * This file is part of NEST. - * - * Copyright (C) 2004 The NEST Initiative - * - * NEST is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * NEST is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with NEST. If not, see . - * - */ - -#ifndef PP_POP_PSC_DELTA_H -#define PP_POP_PSC_DELTA_H - -// Includes from nestkernel: -#include "archiving_node.h" -#include "connection.h" -#include "event.h" -#include "nest_types.h" -#include "random_generators.h" -#include "ring_buffer.h" -#include "universal_data_logger.h" - -namespace nest -{ - -/* BeginUserDocs: neuron, point process, current-based - -Short description -+++++++++++++++++ - -Population of point process neurons with leaky integration of delta-shaped PSCs - -Description -+++++++++++ - -``pp_pop_psc_delta`` is an effective model of a population of neurons. The -:math:`N` component neurons are assumed to be spike-response models with escape -noise, also known as generalized linear models. We follow closely the -nomenclature of [1]_. The component neurons are a special case of -``pp_psc_delta`` (with purely exponential rate function, no reset and no -random deadtime). All neurons in the population share the inputs that it -receives, and the output is the pooled spike train. - -The instantaneous firing rate of the :math:`N` component neurons is defined as - -.. math:: - - r(t) = \rho_0 \exp \frac{h(t) - \eta(t)}{\delta_u}\;, - -where :math:`h(t)` is the input potential (synaptic delta currents convolved with -an exponential kernel with time constant :math:`tau_m`), :math:`\eta(t)` models the effect -of refractoriness and adaptation (the neuron's own spike train convolved with -a sum of exponential kernels with time constants :math:`\tau_{\eta}`), and :math:`\delta_u` -sets the scale of the voltages. - -To represent a (homogeneous) population of :math:`N` inhomogeneous renewal process -neurons, we can keep track of the numbers of neurons that fired a certain -number of time steps in the past. These neurons will have the same value of -the hazard function (instantaneous rate), and we draw a binomial random -number for each of these groups. This algorithm is thus very similar to -``ppd_sup_generator`` and ``gamma_sup_generator``, see also [2]_. - -However, the adapting threshold :math:`\eta(t)` of the neurons generally makes the -neurons non-renewal processes. We employ the quasi-renewal approximation -[1]_, to be able to use the above algorithm. For the extension of [1]_ to -coupled populations see [3]_. - -In effect, in each simulation time step, a binomial random number for each -of the groups of neurons has to be drawn, independent of the number of -represented neurons. For large :math:`N`, it should be much more efficient than -simulating :math:`N` individual ``pp_psc_delta`` models. - -The internal variable ``n_events`` gives the number of -spikes emitted in a time step, and can be monitored using a ``multimeter``. - - -Parameters -++++++++++ - -The following parameters can be set in the status dictionary. - -=========== =============== =========================================== - N integer Number of represented neurons - tau_m ms Membrane time constant - C_m pF Capacitance of the membrane - rho_0 1/s Base firing rate - delta_u mV Voltage scale parameter - I_e pA Constant input current - tau_eta list of ms Time constants of post-spike kernel - val_eta list of mV Amplitudes of exponentials in - post-spike-kernel - len_kernel real Post-spike kernel eta is truncated after - max(tau_eta) * len_kernel -=========== =============== =========================================== - -The parameters correspond to the ones of pp_psc_delta as follows. - -================== ============================ - c_1 0.0 - c_2 rho_0 - c_3 1/delta_u - q_sfa val_eta - tau_sfa tau_eta - I_e I_e - dead_time simulation resolution - dead_time_random False - with_reset False - t_ref_remaining 0.0 -================== ============================ - -.. admonition:: Deprecated model - - ``pp_pop_psc_delta`` is deprecated because a new and presumably much faster - population model implementation is now available (see :doc:`gif_pop_psc_exp `). - - -References -++++++++++ - -.. [1] Naud R, Gerstner W (2012). Coding and decoding with adapting neurons: - a population approach to the peri-stimulus time histogram. - PLoS Compututational Biology 8: e1002711. - DOI: https://doi.org/10.1371/journal.pcbi.1002711 -.. [2] Deger M, Helias M, Boucsein C, Rotter S (2012). Statistical properties - of superimposed stationary spike trains. Journal of Computational - Neuroscience 32:3, 443-463. - DOI: https://doi.org/10.1007/s10827-011-0362-8 -.. [3] Deger M, Schwalger T, Naud R, Gerstner W (2014). Fluctuations and - information filtering in coupled populations of spiking neurons with - adaptation. Physical Review E 90:6, 062704. - DOI: https://doi.org/10.1103/PhysRevE.90.062704 - -Sends -+++++ - -SpikeEvent - -Receives -++++++++ - -SpikeEvent, CurrentEvent, DataLoggingRequest - -See also -++++++++ - - -EndUserDocs */ - -class pp_pop_psc_delta : public Node -{ - -public: - pp_pop_psc_delta(); - pp_pop_psc_delta( const pp_pop_psc_delta& ); - - /** - * Import sets of overloaded virtual functions. - * @see Technical Issues / Virtual Functions: Overriding, Overloading, and - * Hiding - */ - using Node::handle; - using Node::handles_test_event; - - port send_test_event( Node&, rport, synindex, bool ) override; - - void handle( SpikeEvent& ) override; - void handle( CurrentEvent& ) override; - void handle( DataLoggingRequest& ) override; - - port handles_test_event( SpikeEvent&, rport ) override; - port handles_test_event( CurrentEvent&, rport ) override; - port handles_test_event( DataLoggingRequest&, rport ) override; - - void get_status( DictionaryDatum& ) const override; - void set_status( const DictionaryDatum& ) override; - -private: - void init_buffers_() override; - void pre_run_hook() override; - - void update( Time const&, const long, const long ) override; - - // The next two classes need to be friends to access the State_ class/member - friend class RecordablesMap< pp_pop_psc_delta >; - friend class UniversalDataLogger< pp_pop_psc_delta >; - - // ---------------------------------------------------------------- - - /** - * Independent parameters of the model. - */ - struct Parameters_ - { - /** Number of neurons in the population. */ - int N_; // by Hesam - - /** Membrane time constant in ms. */ - double tau_m_; - - /** Membrane capacitance in pF. */ - double c_m_; - - /** ------------ */ - double rho_0_; - - /** ------------ */ - double delta_u_; - - /** Length of kernel */ - int len_kernel_; - - /** External DC current. */ - double I_e_; - - /** Array of time constants */ - std::vector< double > tau_eta_; - - /** -------------- */ - std::vector< double > val_eta_; - - Parameters_(); //!< Sets default parameter values - void get( DictionaryDatum& ) const; //!< Store current values in dictionary - void set( const DictionaryDatum&, Node* node ); //!< Set values from dictionary - }; - - // ---------------------------------------------------------------- - - /** - * State variables of the model. - */ - struct State_ - { - double y0_; - double h_; - - std::vector< int > age_occupations_; - std::vector< double > thetas_ages_; - std::vector< int > n_spikes_past_; - std::vector< int > n_spikes_ages_; - std::vector< double > rhos_ages_; - - // ring array pointers - int p_age_occupations_; - int p_n_spikes_past_; - - bool initialized_; // it is true if the vectors are initialized - - State_(); //!< Default initialization - - void get( DictionaryDatum&, const Parameters_& ) const; - void set( const DictionaryDatum&, const Parameters_&, Node* ); - }; - - // ---------------------------------------------------------------- - - /** - * Buffers of the model. - */ - struct Buffers_ - { - Buffers_( pp_pop_psc_delta& ); - Buffers_( const Buffers_&, pp_pop_psc_delta& ); - - /** buffers and sums up incoming spikes/currents */ - RingBuffer spikes_; - RingBuffer currents_; - - //! Logger for all analog data - UniversalDataLogger< pp_pop_psc_delta > logger_; - }; - - // ---------------------------------------------------------------- - - /** - * Internal variables of the model. - */ - struct Variables_ - { - double P30_; - double P33_; - - int len_eta_; - std::vector< double > theta_kernel_; - std::vector< double > eta_kernel_; - - double h_; //!< simulation time step in ms - double min_double_; - - RngPtr rng_; // random number generator of my own thread - binomial_distribution bino_dist_; // binomial distribution - - int DeadTimeCounts_; - }; - - // Access functions for UniversalDataLogger ----------------------- - - //! Read out the real membrane potential - double - get_V_m_() const - { - return S_.h_; - } // filtered input - - //! Read out the adaptive threshold potential - double - get_n_events_() const - { - return S_.n_spikes_past_[ S_.p_n_spikes_past_ ]; - } // number of generated spikes - - // ---------------------------------------------------------------- - - /** - * @defgroup iaf_psc_alpha_data - * Instances of private data structures for the different types - * of data pertaining to the model. - * @note The order of definitions is important for speed. - * @{ - */ - Parameters_ P_; - State_ S_; - Variables_ V_; - Buffers_ B_; - /** @} */ - - //! Mapping of recordables names to access functions - static RecordablesMap< pp_pop_psc_delta > recordablesMap_; -}; - -inline port -pp_pop_psc_delta::send_test_event( Node& target, rport receptor_type, synindex, bool ) -{ - SpikeEvent e; - e.set_sender( *this ); - - return target.handles_test_event( e, receptor_type ); -} - -inline port -pp_pop_psc_delta::handles_test_event( SpikeEvent&, rport receptor_type ) -{ - if ( receptor_type != 0 ) - { - throw UnknownReceptorType( receptor_type, get_name() ); - } - return 0; -} - -inline port -pp_pop_psc_delta::handles_test_event( CurrentEvent&, rport receptor_type ) -{ - if ( receptor_type != 0 ) - { - throw UnknownReceptorType( receptor_type, get_name() ); - } - return 0; -} - -inline port -pp_pop_psc_delta::handles_test_event( DataLoggingRequest& dlr, rport receptor_type ) -{ - if ( receptor_type != 0 ) - { - throw UnknownReceptorType( receptor_type, get_name() ); - } - return B_.logger_.connect_logging_device( dlr, recordablesMap_ ); -} - -inline void -pp_pop_psc_delta::get_status( DictionaryDatum& d ) const -{ - P_.get( d ); - S_.get( d, P_ ); - ( *d )[ names::recordables ] = recordablesMap_.get_list(); -} - -inline void -pp_pop_psc_delta::set_status( const DictionaryDatum& d ) -{ - Parameters_ ptmp = P_; // temporary copy in case of errors - ptmp.set( d, this ); // throws if BadProperty - State_ stmp = S_; // temporary copy in case of errors - stmp.set( d, ptmp, this ); // throws if BadProperty - - // if we get here, temporaries contain consistent set of properties - P_ = ptmp; - S_ = stmp; -} - -} // namespace - -#endif /* #ifndef PP_POP_PSC_DELTA_H */ diff --git a/testsuite/unittests/test_pp_pop_psc_delta.sli b/testsuite/unittests/test_pp_pop_psc_delta.sli deleted file mode 100755 index bf7792595f..0000000000 --- a/testsuite/unittests/test_pp_pop_psc_delta.sli +++ /dev/null @@ -1,200 +0,0 @@ -/* - * test_pp_pop_psc_delta.sli - * - * This file is part of NEST. - * - * Copyright (C) 2004 The NEST Initiative - * - * NEST is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * NEST is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with NEST. If not, see . - * - */ - - -/** @BeginDocumentation -Name: testsuite::test_pp_pop_psc_delta - sli script for test of pp_pop_psc_delta - -Synopsis: (test_pp_pop_psc_delta) run -> compare numbers of generated spikes of the model and a group of pp_psc_delta neurons - -Description: - - This script simulate three point process population models with different sets of parameters. After each simulation, it compares - the number of generated spikes by the model and the same quantity of a group of pp_psc_delta neurons. The parameters of - pp_psc_delta neurons (including the number of neurons) are the same as represented in the point process population model. - The ratio of number of spikes must not be less than 1-err and greater than 1+err. Here we choose err=0.2. - - - -Author: May 2014, Setareh, Deger -SeeAlso: pp_pop_psc_delta, testsuite::test_pp_psc_delta - -*/ - - -(unittest) run -/unittest using - - -0.2 /err Set -10000.0 /T Set - - -/first_test -{ - - ResetKernel - << - /resolution 1.0 - >> SetKernelStatus - - /pp_pop_psc_delta Create /node Set - - << - /N 500 - /rho_0 1.0 - /delta_u 1.0 - /tau_m 10.0 - /C_m 15.0 - /tau_eta [10.0 300.0] - /val_eta [3.0 1.0 ] - /len_kernel 5.0 - /I_e -0.5 - >> /params_pop Set - - node params_pop SetStatus - - /dc_generator Create /current Set - - << - /amplitude 3.0 - >> /params_cur Set - - current params_cur SetStatus - - /spike_recorder Create /sr Set - - current node Connect - node sr Connect - T Simulate - - sr /n_events get - - 13179.0 % expected number of generated spikes (generated by a group of pp_psc_delta neurons with the same parameter set) - div /ratio Set - 1.0 err sub ratio lt - ratio 1.0 err add lt - and assert_or_die - -} def - - -/second_test -{ - - ResetKernel - << - /resolution 1.0 - >> SetKernelStatus - - /pp_pop_psc_delta Create /node Set - - << - /N 300 - /rho_0 1.0 - /delta_u 5.0 - /tau_m 9.0 - /C_m 5.0 - /tau_eta [15.0 200.0] - /val_eta [4.0 2.0 ] - /len_kernel 5.0 - /I_e 1.0 - >> /params_pop Set - - node params_pop SetStatus - - /dc_generator Create /current Set - - << - /amplitude 3.0 - >> /params_cur Set - - current params_cur SetStatus - - /spike_recorder Create /sr Set - - current node Connect - node sr Connect - T Simulate - - sr /n_events get - - 9667.0 % expected number of generated spikes (generated by a group of pp_psc_delta neurons with the same parameter set) - div /ratio Set - 1.0 err sub ratio lt - ratio 1.0 err add lt - and assert_or_die - -} def - - -/third_test -{ - - ResetKernel - << - /resolution 1.0 - >> SetKernelStatus - - /pp_pop_psc_delta Create /node Set - - << - /N 400 - /rho_0 1.0 - /delta_u 3.0 - /tau_m 5.0 - /C_m 10.0 - /tau_eta [25.0 100.0] - /val_eta [5.0 1.0 ] - /len_kernel 7.0 - /I_e 8.0 - >> /params_pop Set - - node params_pop SetStatus - - /dc_generator Create /current Set - - << - /amplitude 3.0 - >> /params_cur Set - - current params_cur SetStatus - - /spike_recorder Create /sr Set - - current node Connect - node sr Connect - T Simulate - - sr /n_events get - - 19128.0 % expected number of generated spikes (generated by a group of pp_psc_delta neurons with the same parameter set) - div /ratio Set - 1.0 err sub ratio lt - ratio 1.0 err add lt - and assert_or_die - -} def - -first_test -second_test -third_test From 721837aa316e52f7128079b9b26131f12e936aa8 Mon Sep 17 00:00:00 2001 From: Jan Vogelsang <47158055+JanVogelsang@users.noreply.github.com> Date: Thu, 20 Jul 2023 15:58:10 +0200 Subject: [PATCH 3/3] Removed unnecessary casts --- nestkernel/model.cpp | 2 +- nestkernel/model.h | 2 +- nestkernel/ring_buffer.h | 8 ++++---- nestkernel/simulation_manager.cpp | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/nestkernel/model.cpp b/nestkernel/model.cpp index 4cd2a2a3f8..08d2a342a3 100644 --- a/nestkernel/model.cpp +++ b/nestkernel/model.cpp @@ -69,7 +69,7 @@ Model::set_threads_( size_t t ) void Model::reserve_additional( size_t t, size_t n ) { - assert( static_cast< size_t >( t ) < memory_.size() ); + assert( t < memory_.size() ); memory_[ t ].reserve( n ); } diff --git a/nestkernel/model.h b/nestkernel/model.h index 60dc7439ef..231228f7ce 100644 --- a/nestkernel/model.h +++ b/nestkernel/model.h @@ -255,7 +255,7 @@ class Model inline Node* Model::create( size_t t ) { - assert( static_cast< size_t >( t ) < memory_.size() ); + assert( t < memory_.size() ); Node* n = create_(); memory_[ t ].emplace_back( n ); return n; diff --git a/nestkernel/ring_buffer.h b/nestkernel/ring_buffer.h index 273dd4b9d4..9e7328f766 100644 --- a/nestkernel/ring_buffer.h +++ b/nestkernel/ring_buffer.h @@ -170,7 +170,7 @@ inline double RingBuffer::get_value( const long offs ) { assert( 0 <= offs and static_cast< size_t >( offs ) < buffer_.size() ); - assert( static_cast< long >( offs ) < kernel().connection_manager.get_min_delay() ); + assert( offs < kernel().connection_manager.get_min_delay() ); // offs == 0 is beginning of slice, but we have to // take modulo into account when indexing @@ -184,7 +184,7 @@ inline double RingBuffer::get_value_wfr_update( const long offs ) { assert( 0 <= offs and static_cast< size_t >( offs ) < buffer_.size() ); - assert( static_cast< long >( offs ) < kernel().connection_manager.get_min_delay() ); + assert( offs < kernel().connection_manager.get_min_delay() ); // offs == 0 is beginning of slice, but we have to // take modulo into account when indexing @@ -266,7 +266,7 @@ inline double MultRBuffer::get_value( const long offs ) { assert( 0 <= offs and static_cast< size_t >( offs ) < buffer_.size() ); - assert( static_cast< long >( offs ) < kernel().connection_manager.get_min_delay() ); + assert( offs < kernel().connection_manager.get_min_delay() ); // offs == 0 is beginning of slice, but we have to // take modulo into account when indexing @@ -347,7 +347,7 @@ inline std::list< double >& ListRingBuffer::get_list( const long offs ) { assert( 0 <= offs and static_cast< size_t >( offs ) < buffer_.size() ); - assert( static_cast< long >( offs ) < kernel().connection_manager.get_min_delay() ); + assert( offs < kernel().connection_manager.get_min_delay() ); // offs == 0 is beginning of slice, but we have to // take modulo into account when indexing diff --git a/nestkernel/simulation_manager.cpp b/nestkernel/simulation_manager.cpp index 91fad2f84c..adc7c67bb6 100644 --- a/nestkernel/simulation_manager.cpp +++ b/nestkernel/simulation_manager.cpp @@ -1080,7 +1080,7 @@ nest::SimulationManager::advance_time_() to_do_ -= to_step_ - from_step_; // advance clock, update modulos, slice counter only if slice completed - if ( static_cast< long >( to_step_ ) == kernel().connection_manager.get_min_delay() ) + if ( to_step_ == kernel().connection_manager.get_min_delay() ) { clock_ += Time::step( kernel().connection_manager.get_min_delay() ); ++slice_; @@ -1094,7 +1094,7 @@ nest::SimulationManager::advance_time_() long end_sim = from_step_ + to_do_; - if ( kernel().connection_manager.get_min_delay() < static_cast< long >( end_sim ) ) + if ( kernel().connection_manager.get_min_delay() < end_sim ) { // update to end of time slice to_step_ = kernel().connection_manager.get_min_delay(); @@ -1104,7 +1104,7 @@ nest::SimulationManager::advance_time_() to_step_ = end_sim; // update to end of simulation time } - assert( to_step_ - from_step_ <= static_cast< long >( kernel().connection_manager.get_min_delay() ) ); + assert( to_step_ - from_step_ <= kernel().connection_manager.get_min_delay() ); } void