source: cpp/frams/neuro/impl/neuroimpl-simple.h @ 138

Last change on this file since 138 was 121, checked in by sz, 11 years ago

updated file headers and makefiles

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