source: cpp/gdk/neuroimpl-simple.h @ 64

Last change on this file since 64 was 64, checked in by Maciej Komosinski, 13 years ago

a lot of minor fixes

File size: 1.9 KB
Line 
1// This file is a part of the Framsticks GDK library.
2// Copyright (C) 2002-2011  Szymon Ulatowski.  See LICENSE.txt for details.
3// Refer to http://www.framsticks.com/ for further information.
4
5#ifndef _NEUROIMPLSIMPLE_H_
6#define _NEUROIMPLSIMPLE_H_
7
8#include "neuroimpl.h"
9
10extern ParamEntry NI_StdNeuron_tab[];
11
12class NI_StdNeuron: public NeuroImpl
13{
14  protected:
15double istate, velocity;
16void calcInternalState();
17virtual void calcOutput();
18  public:
19double inertia,force,sigmo;
20NI_StdNeuron():velocity(0)
21#ifdef MODEL_V1_COMPATIBLE
22        ,inertia(-1),force(-1),sigmo(1e10)// illegal values, will be adjusted in lateinit()
23#else
24        ,inertia(0),force(0),sigmo(0)
25#endif
26        {paramentries=NI_StdNeuron_tab;}
27NeuroImpl* makeNew(){return new NI_StdNeuron();} // for NeuroFactory
28int lateinit();
29void go();
30};
31
32extern ParamEntry NI_StdUNeuron_tab[];
33
34class NI_StdUNeuron: public NI_StdNeuron
35{
36  public:
37NI_StdUNeuron()
38        {paramentries=NI_StdUNeuron_tab;}
39NeuroImpl* makeNew(){return new NI_StdUNeuron();} // for NeuroFactory
40void calcOutput();
41};
42
43class NI_Const: public NeuroImpl
44{
45public:
46NeuroImpl* makeNew(){return new NI_Const();} // for NeuroFactory
47int lateinit()
48        {
49        neuro->state=newstate=1.0;
50        simorder=0;
51        return 1;
52        }
53};
54
55class NI_Diff : public NeuroImpl
56{
57double previous;     
58  public:
59NeuroImpl* makeNew() { return new NI_Diff(); };
60
61void go()
62        {
63        double s=getWeightedInputSum();
64        setState(s-previous);
65        previous=s;
66        }
67int lateinit()
68        {
69        NeuroImpl::lateinit();
70        previous=neuro->state;
71        return 1;
72        }
73};
74
75class NI_Random : public NeuroImpl
76{
77  public:
78NeuroImpl* makeNew() { return new NI_Random(); };
79void go() {setState(rnd01*2.0-1.0);}
80};
81
82extern ParamEntry NI_Sinus_tab[];
83
84class NI_Sinus : public NeuroImpl
85{
86  public:
87double f0,t;
88NeuroImpl* makeNew() { return new NI_Sinus(); };
89NI_Sinus():f0(0),t(0)
90        {paramentries=NI_Sinus_tab;}
91void go()
92        {
93        t+=f0+getWeightedInputSum();
94        setState(sin(t));
95        }
96};
97
98#endif
99
Note: See TracBrowser for help on using the repository browser.