📄 neuron.cpp
字号:
/*************************************************************************** neuron.cpp - description ------------------- copyright : (C) 2001, 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 <cmath>#include <stdexcept>#include "neuron.h"#include "network.h"#include "spikeoutput.h"#include "axon.h"#include "axonnode.h"#include "synapse.h"#include "dendrite.h"#include "outputmanager.h"#include "neuronproperties.h"#include "logging.h"using namespace std;using namespace Amygdala;Neuron::Neuron(AmIdInt neuronId, const NeuronProperties& props): nId(neuronId), spikeTime(0), outputGroupIdx(0){ //SetDefaults(); neuronProps = props.Copy(); axon = new Axon(); //TODO: Set appropriate variables here (moved from SetDefaults) InitStepSize();}Neuron::Neuron(AmIdInt neuronId): nId(neuronId), spikeTime(0), outputGroupIdx(0){ //SetDefaults(); neuronProps = 0; axon = new Axon(); //TODO: Set appropriate variables here (moved from SetDefaults) InitStepSize();}Neuron::~Neuron(){ LOGGER(6, "Deleting a neuron: " << nId); delete axon; delete neuronProps;}void Neuron::InitStepSize(){ simStepSize = Network::TimeStepSize(); stepSizeInv = 1.0/simStepSize;}// Initialize static variablesAmTimeInt Neuron::simStepSize = 100;float Neuron::stepSizeInv = 0.01;bool Neuron::enforceSign = false;AmGroupInt Neuron::outputMode = 0;void Neuron::AddOutputGroup(unsigned int groupId){ if (groupId >= (sizeof(AmGroupInt)*8)) { throw runtime_error("GroupId is too large"); } unsigned int state=1; state <<= groupId; outputGroupIdx |= state; }void Neuron::CaptureOutput(bool enable, unsigned int groupId){ unsigned int state = 1; state <<= groupId; if (enable) { outputMode |= state; } else { if ((outputMode | state) == outputMode) { // bit was on -- don't do anything if it was already off outputMode ^= state; } }}bool Neuron::CaptureOutput(unsigned int groupId){ unsigned int state=1; state <<= groupId; return (outputMode & state);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -