/**************************************************************************

	StdForms.h													JJS 9/08/95
	
		part of CONICAL, the Computational Neuroscience Class Library
	
	This file does not define a class; rather, it defines some standard
	formulas which are frequently used to describe channel gating, etc.
	It also defines some constants and a front-end function for accessing
	compatible functions through a single call (StdFormula) if the format
	is only known at runtime.
	
	Requires:
		math			-- ANSI math functions (defined in <math.h>)
		
**************************************************************************/

#ifndef STDFORMS_H
#define STDFORMS_H

#ifndef real
#define real double
#endif

#include <math.h>

enum StdForm {
	kExpForm,
	kSigForm,
	kLinForm,
kQtyForms };

inline real ExpForm(real v, real A, real B, real V0)
{
	return A * exp((v-V0)/B);
}

inline real SigForm(real v, real A, real B, real V0)
{
	return A / (exp((v-V0)/B) + 1);
}

inline real LinForm(real v, real A, real B, real V0)
{
	return (v==V0 ? A : A * (v-V0) / (exp((v-V0)/B)  - 1));
}

inline real StdFormula( StdForm pForm, real V, real A, real B, real V0 )
{
	switch (pForm) {
		case kExpForm: return ExpForm( V, A, B, V0 );
		case kSigForm: return SigForm( V, A, B, V0 );
		case kLinForm: return LinForm( V, A, B, V0 );
	}
	return 0;
}

#endif