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

Last change on this file since 875 was 791, checked in by Maciej Komosinski, 7 years ago

Code formatting

  • Property svn:eol-style set to native
File size: 1.8 KB
RevLine 
[286]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.
[109]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
[791]13class NI_StdNeuron : public NeuroImpl
[109]14{
[791]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();
[109]28};
29
30extern ParamEntry NI_StdUNeuron_tab[];
31
[791]32class NI_StdUNeuron : public NI_StdNeuron
[109]33{
[791]34public:
35        NI_StdUNeuron()
36        {
37                paramentries = NI_StdUNeuron_tab;
38        }
39        NeuroImpl* makeNew(){ return new NI_StdUNeuron(); } // for NeuroFactory
40        void calcOutput();
[109]41};
42
[791]43class NI_Const : public NeuroImpl
[109]44{
45public:
[791]46        NeuroImpl* makeNew(){ return new NI_Const(); } // for NeuroFactory
47        int lateinit()
[109]48        {
[791]49                neuro->state = newstate = 1.0;
50                simorder = 0;
51                return 1;
[109]52        }
53};
54
55class NI_Diff : public NeuroImpl
56{
[791]57        double previous;
58public:
59        NeuroImpl* makeNew() { return new NI_Diff(); };
[109]60
[791]61        void go()
[109]62        {
[791]63                double s = getWeightedInputSum();
64                setState(s - previous);
65                previous = s;
[109]66        }
[791]67        int lateinit()
[109]68        {
[791]69                NeuroImpl::lateinit();
70                previous = neuro->state;
71                return 1;
[109]72        }
73};
74
75class NI_Random : public NeuroImpl
76{
[791]77public:
78        NeuroImpl* makeNew() { return new NI_Random(); };
79        void go() { setState(rnd01*2.0 - 1.0); }
[109]80};
81
82extern ParamEntry NI_Sinus_tab[];
83
84class NI_Sinus : public NeuroImpl
85{
[791]86public:
87        double f0, t;
88        NeuroImpl* makeNew() { return new NI_Sinus(); };
89        NI_Sinus() :f0(0), t(0)
[109]90        {
[791]91                paramentries = NI_Sinus_tab;
[109]92        }
[791]93        void go()
94        {
95                t += f0 + getWeightedInputSum();
96                setState(sin(t));
97        }
[109]98};
99
100#endif
Note: See TracBrowser for help on using the repository browser.