00001 #include "SquarePulseSpikeResponse.h" 00002 00003 #include <iostream> 00004 00005 using std::cout; 00006 using std::endl; 00007 00008 int SquarePulseSpikeResponse::reset( double dt ) 00009 { 00010 FiniteSpikeResponse::reset( dt ); 00011 while (!pulseEndings.empty()) 00012 pulseEndings.pop(); 00013 while (!pulseWeights.empty()) 00014 pulseWeights.pop(); 00015 return 0; 00016 } 00017 00018 int SquarePulseSpikeResponse::advance(AdvanceInfo const & ai) 00019 { 00020 while (!pulseEndings.empty() && ai.t.in_sec() + ai.dt.in_sec() >= pulseEndings.front()) { 00021 pulseEndings.pop(); 00022 psr -= A * pulseWeights.front(); 00023 pulseWeights.pop(); 00024 } 00025 return advanceReturn(); 00026 } 00027 00028 int SquarePulseSpikeResponse::spikeHit( spikeport_t port, SpikeEvent const& spike ) 00029 { 00030 psr += A * spike.weight; 00031 pulseEndings.push(spike.time() + tau); 00032 pulseWeights.push(spike.weight); 00033 return spikeHitReturn( AdvanceInfo( spike.dt ) ); 00034 } 00035 00036 int SquarePulseSpikeResponse::psrLength(double dt) const 00037 { 00038 return (int)(tau/dt + 2); 00039 } 00040