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

Last change on this file was 907, checked in by Maciej Komosinski, 4 years ago

Code formatting

  • Property svn:eol-style set to native
File size: 1.8 KB
Line 
1// This file is a part of Framsticks SDK.  http://www.framsticks.com/
2// Copyright (C) 1999-2015  Maciej Komosinski and Szymon Ulatowski.
3// See LICENSE.txt for details.
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{
15protected:
16        double istate, velocity;
17        void calcInternalState();
18        virtual void calcOutput();
19public:
20        double inertia, force, sigmo;
21        NI_StdNeuron() :velocity(0), inertia(0), force(0), sigmo(0)
22        {
23                paramentries = NI_StdNeuron_tab;
24        }
25        NeuroImpl* makeNew() { return new NI_StdNeuron(); } // for NeuroFactory
26        int lateinit();
27        void go();
28};
29
30extern ParamEntry NI_StdUNeuron_tab[];
31
32class NI_StdUNeuron : public NI_StdNeuron
33{
34public:
35        NI_StdUNeuron()
36        {
37                paramentries = NI_StdUNeuron_tab;
38        }
39        NeuroImpl* makeNew() { return new NI_StdUNeuron(); } // for NeuroFactory
40        void calcOutput();
41};
42
43class NI_Const : public NeuroImpl
44{
45public:
46        NeuroImpl* makeNew() { return new NI_Const(); } // for NeuroFactory
47        int lateinit()
48        {
49                neuro->state = newstate = 1.0;
50                simorder = 0;
51                return 1;
52        }
53};
54
55class NI_Diff : public NeuroImpl
56{
57        double previous;
58public:
59        NeuroImpl* makeNew() { return new NI_Diff(); };
60
61        void go()
62        {
63                double s = getWeightedInputSum();
64                setState(s - previous);
65                previous = s;
66        }
67        int lateinit()
68        {
69                NeuroImpl::lateinit();
70                previous = neuro->state;
71                return 1;
72        }
73};
74
75class NI_Random : public NeuroImpl
76{
77public:
78        NeuroImpl* makeNew() { return new NI_Random(); };
79        void go() { setState(rndDouble(2) - 1.0); }
80};
81
82extern ParamEntry NI_Sinus_tab[];
83
84class NI_Sinus : public NeuroImpl
85{
86public:
87        double f0, t;
88        NeuroImpl* makeNew() { return new NI_Sinus(); };
89        NI_Sinus() :f0(0), t(0)
90        {
91                paramentries = NI_Sinus_tab;
92        }
93        void go()
94        {
95                t += f0 + getWeightedInputSum();
96                setState(sin(t));
97        }
98};
99
100#endif
Note: See TracBrowser for help on using the repository browser.