📄 axon.cpp
字号:
/*************************************************************************** axon.cpp - description ------------------- begin : Thu Sep 19 2002 copyright : (C) 2002 by Matt Grover email : mgrover@amygdala.org ***************************************************************************//*************************************************************************** * * * This program 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. * * * ***************************************************************************/#include <iostream>#include <string>#include <stdexcept>#include "axon.h"#include "axonnode.h"#include "network.h"#include "synapse.h"using namespace Amygdala;using namespace std;Axon::Axon() {}Axon::~Axon(){}void Axon::AddSynapse(Synapse* syn, unsigned int synSize, AmTimeInt delay){ //Check to see that no axon nodes have been built yet if (nodes.size()) { throw runtime_error("Synapses cannot be added to an axon after BuildNodes() is called."); } AxonNodeKey key; key.className = syn->GetClassName(); key.delay = delay; key.size = synSize; // add the synapse to the tempSynStore tempSynStore[key].push_back(syn);}unsigned int Axon::SynapseCount() const{ unsigned int count=0; for (unsigned int i=0; i<nodes.size(); ++i) { count += nodes[i]->Size(); } return count;}void Axon::BuildNodes(){ if (tempSynStore.size() == 0) { // nothing to do return; } if (nodes.size()) { // BuildNodes() has already been called throw runtime_error("BuildNodes() can only be called once"); } map<AxonNodeKey, std::vector<Synapse*> >::iterator itr; for (itr=tempSynStore.begin(); itr != tempSynStore.end(); itr++) { vector<Synapse*> svec = itr->second; Synapse* syn = svec[0]; LOGGER(6, "creating AxonNode with size " << itr->first.size) AxonNode* anode = new AxonNode(itr->first.delay, itr->first.size, svec.size()); nodes.push_back(anode); Network::GetNetworkRef()->SetMaxSpikeDelay(itr->first.delay); for (unsigned int i=0; i<svec.size(); ++i) { syn = svec[i]; anode->AddSynapse(syn); delete syn; } svec.clear(); } tempSynStore.clear();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -