ExponentialDecaySpikeResponse.h

Go to the documentation of this file.
00001 #ifndef EXPONENTIALDECAYSPIKERESPONSE_H_
00002 #define EXPONENTIALDECAYSPIKERESPONSE_H_
00003 
00004 #include "PCSIMException.h"
00005 #include "FiniteSpikeResponse.h"
00006 
00007 class ExponentialDecaySpikeResponse : public FiniteSpikeResponse
00008 {
00009 
00010         SIMOBJECT ( ExponentialDecaySpikeResponse, AdvancePhase::SpikeDriven )
00011 
00012 public:
00013     ExponentialDecaySpikeResponse(
00014         const float tau=3e-3
00015     ): FiniteSpikeResponse(), tau(tau)
00016     { /* NOOP */ };
00017 
00018     virtual ~ExponentialDecaySpikeResponse()
00019     { /* NOOP */ };
00020 
00022 
00024     float tau;
00025 
00026     // Update internal variables
00027     virtual int adjust( double dt );
00028 
00029     // Reset to initial condition.
00030     virtual int reset( double dt );
00031 
00032     virtual int advance(AdvanceInfo const & );
00033 
00034     virtual int spikeHit( spikeport_t port, SpikeEvent const& spike );
00035 
00037 
00040     virtual int psrLength(double dt) const;
00041 
00042 private:
00044     double decay;
00045 
00046 };
00047 
00048 inline int ExponentialDecaySpikeResponse::adjust( double dt )
00049 {
00050     if ( tau > 0 )
00051         decay = exp( - dt / tau );
00052     else {
00053         throw( PCSIM::Exception( "ExponentialDecaySpikeResponse::adjust", "Time constant not a positive vlaue!" ) );
00054     }
00055     return 0;
00056 }
00057 
00058 inline int ExponentialDecaySpikeResponse::reset( double dt )
00059 {
00060     FiniteSpikeResponse::reset( dt );
00061     adjust( dt );
00062     return 0;
00063 }
00064 
00065 inline int ExponentialDecaySpikeResponse::advance(AdvanceInfo const &)
00066 {
00067     // Do the exponantial decay
00068     psr *= decay;
00069     return advanceReturn();
00070 }
00071 
00072 inline int ExponentialDecaySpikeResponse::spikeHit( spikeport_t port, SpikeEvent const& spike )
00073 {
00074     // 3.) Add weight to psr as if spike had occured at time t and has amplitude weight at time ts    
00075     psr += spike.weight / exp( - spike.delta / tau );
00076      
00077     return spikeHitReturn( AdvanceInfo( spike.dt ) );
00078 }
00079 
00080 inline int ExponentialDecaySpikeResponse::psrLength(double dt) const
00081 {
00082     return (int)( (double)PSR_MULTIPLE_TAU * tau / dt + 0.5 );
00083 }
00084 
00085 #endif /*EXPONENTIALDECAYSPIKERESPONSE_H_*/

Generated on Wed Jul 9 16:34:38 2008 for PCSIM by  doxygen 1.5.5