예제 #1
0
파일: A2.cpp 프로젝트: nMerlin/CP
//Regula Falsi
schranke Intervallhalbierung(schranke s, double epsilon, int n) {
	//Variablen
	double z;
	
	//Iteration
	while ((s.max-s.min)>epsilon) {
		z = (s.min+s.max)/2;
		if ((Gn(n,z)*Gn(n,s.min)) < 0) {
			s.max = z;
		} else {
			s.min = z;	
		}
	}
	return s;
}
bool Neuron::SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError)
{
	std::string strType = Std_CheckString(strDataType);
	
	if(Node::SetData(strDataType, strValue, false))
		return true;

	if(strType == "CM")
	{
		Cn(atof(strValue.c_str()));
		return true;
	}

	if(strType == "GM")
	{
		Gn(atof(strValue.c_str()));
		return true;
	}

	if(strType == "VTH")
	{
		Vth(atof(strValue.c_str()));
		return true;
	}

	if(strType == "VREST")
	{
		Vrest(atof(strValue.c_str()));
		return true;
	}

	if(strType == "RELATIVEACCOMMODATION")
	{
		RelativeAccommodation(atof(strValue.c_str()));
		return true;
	}

	if(strType == "ACCOMMODATIONTIMECONSTANT")
	{
		AccommodationTimeConstant(atof(strValue.c_str()));
		return true;
	}

	if(strType == "VNOISEMAX")
	{
		VNoiseMax(atof(strValue.c_str()));
		return true;
	}

	if(strType == "FMIN")
	{
		Fmin(atof(strValue.c_str()));
		return true;
	}

	if(strType == "GAIN")
	{
		Gain(atof(strValue.c_str()));
		return true;
	}

	if(strType == "GAINTYPE")
	{
		GainType(Std_ToBool(strValue));
		return true;
	}

	if(strType == "ADDEXTERNALCURRENT")
	{
		AddExternalI(atof(strValue.c_str()));
		return true;
	}

	if(strType == "IINIT")
	{
		Iinit(atof(strValue.c_str()));
		return true;
	}

	if(strType == "INITTIME")
	{
		InitTime(atof(strValue.c_str()));
		return true;
	}

	//If it was not one of those above then we have a problem.
	if(bThrowError)
		THROW_PARAM_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType, "Data Type", strDataType);

	return false;
}
void Neuron::Load(CStdXml &oXml)
{
	int iCount, iIndex;

	Node::Load(oXml);

	oXml.IntoElem();  //Into Neuron Element

	m_arySynapses.RemoveAll();

	Enabled(oXml.GetChildBool("Enabled", true));

	Cn(oXml.GetChildFloat("Cn"));
	Gn(oXml.GetChildFloat("Gn"));
	Vrest(oXml.GetChildFloat("Vrest", 0));
	Vth(oXml.GetChildFloat("Vth"));
	Fmin(oXml.GetChildFloat("Fmin"));
	Gain(oXml.GetChildFloat("Gain"));
	ExternalI(oXml.GetChildFloat("ExternalI"));
	VNoiseMax(fabs(oXml.GetChildFloat("VNoiseMax", m_fltVNoiseMax)));
	Iinit(oXml.GetChildFloat("Iinit", m_fltIinit));
	InitTime(oXml.GetChildFloat("InitTime", m_fltInitTime));

	m_fltVndisp = m_fltVrest;
	m_fltVthdisp = m_fltVrest + m_fltVth;

	GainType(oXml.GetChildBool("GainType", true));

	m_aryVth[0] = m_aryVth[1] = m_fltVth;

	if(m_fltVNoiseMax != 0)
		UseNoise(true);
	else
		UseNoise(false);

	RelativeAccommodation(fabs(oXml.GetChildFloat("RelativeAccom", m_fltRelativeAccom)));
	AccommodationTimeConstant(fabs(oXml.GetChildFloat("AccomTimeConst", m_fltAccomTimeConst)));

	if(m_fltRelativeAccom != 0)
		UseAccom(true);
	else
		UseAccom(false);

	//*** Begin Loading Synapses. *****
	if(oXml.FindChildElement("Synapses", false))
	{
		oXml.IntoElem();  //Into Synapses Element

		iCount = oXml.NumberOfChildren();
		for(iIndex=0; iIndex<iCount; iIndex++)
		{
			oXml.FindChildByIndex(iIndex);
			LoadSynapse(oXml);
		}

		oXml.OutOfElem();
	}
	//*** End Loading Synapses. *****


	oXml.OutOfElem(); //OutOf Neuron Element
}