void ConvertVecttoState(const MexVector<uint32_t> &SeedState) { this->w = (SeedState.size() > 0) ? SeedState[0] : (uint32_t)chrono::system_clock::now().time_since_epoch().count(); this->x = (SeedState.size() > 1) ? SeedState[1] : (uint32_t)chrono::system_clock::now().time_since_epoch().count(); this->y = (SeedState.size() > 2) ? SeedState[2] : (uint32_t)chrono::system_clock::now().time_since_epoch().count(); this->z = (SeedState.size() > 3) ? SeedState[3] : (uint32_t)chrono::system_clock::now().time_since_epoch().count(); }
void ConvertStatetoVect(const MexVector<uint32_t> &SeedState){ if (SeedState.size() != 4) throw ExOps::EXCEPTION_CONST_MOD; SeedState[0] = w; SeedState[1] = x; SeedState[2] = y; SeedState[3] = z; }
void ConvertStatetoVect(MexVector<uint32_t> &SeedState){ if (SeedState.size() != 4) SeedState.resize(4); SeedState[0] = w; SeedState[1] = x; SeedState[2] = y; SeedState[3] = z; }
InternalVars(InputArgs &IArgs) : N (IArgs.a.size()), M (IArgs.NStart.size()), i (0), Time (IArgs.InitialState.Time), nSteps (onemsbyTstep*NoOfms), NoOfSpikes (0), CurrentQIndex (IArgs.InitialState.CurrentQIndex), OutputControl (IArgs.OutputControl), OutputControlString (IArgs.OutputControlString), StorageStepSize (IArgs.StorageStepSize), StatusDisplayInterval (IArgs.StatusDisplayInterval), Network (N), Neurons (M), InterestingSyns (IArgs.InterestingSyns), V (IArgs.InitialState.V), U (IArgs.InitialState.U), Iin1(N), // Iin is defined separately as an atomic vect. Iin2(N), WeightDeriv (IArgs.InitialState.WeightDeriv), IextInterface (), SpikeQueue (), LSTNeuron (IArgs.InitialState.LSTNeuron), LSTSyn (IArgs.InitialState.LSTSyn), AuxArray (M), PreSynNeuronSectionBeg (N, -1), PreSynNeuronSectionEnd (N, -1), PostSynNeuronSectionBeg (N, -1), PostSynNeuronSectionEnd (N, -1), BinningBuffer (CacheBuffering*onemsbyTstep*DelayRange / 4), BufferInsertIndex (onemsbyTstep*DelayRange, 0), AddressOffset (onemsbyTstep*DelayRange, 0), onemsbyTstep (IArgs.onemsbyTstep), NoOfms (IArgs.NoOfms), DelayRange (IArgs.DelayRange), CacheBuffering (128), I0 (IArgs.I0), CurrentDecayFactor1(IArgs.CurrentDecayFactor1), CurrentDecayFactor2(IArgs.CurrentDecayFactor2){ // Setting up Network and Neurons Network.resize(M); MexTransform(IArgs.NStart.begin(), IArgs.NStart.end(), Network.begin(), FFL([ ](Synapse &Syn, int &NStart)->void{Syn.NStart = NStart ; })); MexTransform(IArgs.NEnd .begin(), IArgs.NEnd .end(), Network.begin(), FFL([ ](Synapse &Syn, int &NEnd )->void{Syn.NEnd = NEnd ; })); MexTransform(IArgs.Weight.begin(), IArgs.Weight.end(), Network.begin(), FFL([ ](Synapse &Syn, float &Weight)->void{Syn.Weight = Weight ; })); MexTransform(IArgs.Delay .begin(), IArgs.Delay .end(), Network.begin(), FFL([&](Synapse &Syn, float &Delay )->void{Syn.DelayinTsteps = Delay*IArgs.onemsbyTstep + 0.5f; })); Neurons.resize(N); MexTransform(IArgs.a.begin(), IArgs.a.end(), Neurons.begin(), FFL([](Neuron &Neu, float &a)->void{Neu.a = a; })); MexTransform(IArgs.b.begin(), IArgs.b.end(), Neurons.begin(), FFL([](Neuron &Neu, float &b)->void{Neu.b = b; })); MexTransform(IArgs.c.begin(), IArgs.c.end(), Neurons.begin(), FFL([](Neuron &Neu, float &c)->void{Neu.c = c; })); MexTransform(IArgs.d.begin(), IArgs.d.end(), Neurons.begin(), FFL([](Neuron &Neu, float &d)->void{Neu.d = d; })); // Setting Initial Conditions of V and U if (U.istrulyempty()){ U.resize(N); for (int j = 0; j<N; ++j) U[j] = Neurons[j].b*(Neurons[j].b - 5.0f - sqrt((5.0f - Neurons[j].b)*(5.0f - Neurons[j].b) - 22.4f)) / 0.08f; } else if (U.size() != N){ // GIVE ERROR MESSAGE HERE return; } if (V.istrulyempty()){ V.resize(N); for (int j = 0; j<N; ++j){ V[j] = (Neurons[j].b - 5.0f - sqrt((5.0f - Neurons[j].b)*(5.0f - Neurons[j].b) - 22.4f)) / 0.08f; } } else if (V.size() != N){ // GIVE ERROR MESSAGE HEREx return; } // Setting Initial Conditions for INTERNAL CURRENT 1 if (IArgs.InitialState.Iin1.size() == N){ for (int j = 0; j < N; ++j){ Iin1[j] = (long long int)(IArgs.InitialState.Iin1[j] * (1i64 << 32)); } } else if (IArgs.InitialState.Iin1.size()){ // GIVE ERROR MESSAGE HERE return; } //else{ // Iin1 is already initialized to zero by tbb::zero_allocator<long long> //} // Setting Initial Conditions for INTERNAL CURRENT 2 if (IArgs.InitialState.Iin2.size() == N){ for (int j = 0; j < N; ++j){ Iin2[j] = (long long int)(IArgs.InitialState.Iin2[j] * (1i64 << 32)); } } else if (IArgs.InitialState.Iin2.size()){ // GIVE ERROR MESSAGE HERE return; } //else{ // Iin2 is already initialized to zero by tbb::zero_allocator<long long> //} // Setting Initial Conditions for Weight Derivative if (WeightDeriv.istrulyempty()){ WeightDeriv.resize(M, 0.0f); } else if (WeightDeriv.size() != M){ // Return Exception return; } // Initializing InternalVars for IextInternal giving it // 1. The IExtInterface::InternalVarsStruct in InternalVars // 2. The IExtInterface::InputVarsStruct in InputVars // 3. The IExtInterface::SingleStateStruct (Initial State) in InputVars // 4. InputVars itself to take parameters such as N, onemsbyTstep, // Noofms etc. IExtInterface::initInternalVariables( IextInterface, IArgs.IextInterface, IArgs.InitialState.IextInterface, IArgs ); // Setting Initial Conditions of SpikeQueue if (IArgs.InitialState.SpikeQueue.istrulyempty()){ SpikeQueue = MexVector<MexVector<int> >(onemsbyTstep * DelayRange, MexVector<int>()); } else if (IArgs.InitialState.SpikeQueue.depth() == 1 && IArgs.InitialState.SpikeQueue.LevelSize(0) == onemsbyTstep*DelayRange) { IArgs.InitialState.SpikeQueue.getVectTree(SpikeQueue); } else { //GIVE ERROR MESSAGE HERE return; } // Setting Initial Conditions for LSTs if (LSTNeuron.istrulyempty()){ LSTNeuron = MexVector<int>(N, -1); } else if (LSTNeuron.size() != N){ //GIVE ERROR MESSAGE HERE return; } if (LSTSyn.istrulyempty()){ LSTSyn = MexVector<int>(M, -1); } else if (LSTSyn.size() != M){ //GIVE ERROR MESSAGE HERE return; } }