Changeset 791 for cpp/frams/neuro/impl/neuroimpl-simple.h
- Timestamp:
- 05/29/18 16:24:39 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/neuro/impl/neuroimpl-simple.h
r726 r791 11 11 extern ParamEntry NI_StdNeuron_tab[]; 12 12 13 class NI_StdNeuron : public NeuroImpl13 class NI_StdNeuron : public NeuroImpl 14 14 { 15 protected: 16 double istate, velocity; 17 void calcInternalState(); 18 virtual void calcOutput(); 19 public: 20 double inertia,force,sigmo; 21 NI_StdNeuron():velocity(0),inertia(0),force(0),sigmo(0) 22 {paramentries=NI_StdNeuron_tab;} 23 NeuroImpl* makeNew(){return new NI_StdNeuron();} // for NeuroFactory 24 int lateinit(); 25 void go(); 15 protected: 16 double istate, velocity; 17 void calcInternalState(); 18 virtual void calcOutput(); 19 public: 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(); 26 28 }; 27 29 28 30 extern ParamEntry NI_StdUNeuron_tab[]; 29 31 30 class NI_StdUNeuron : public NI_StdNeuron32 class NI_StdUNeuron : public NI_StdNeuron 31 33 { 32 public: 33 NI_StdUNeuron() 34 {paramentries=NI_StdUNeuron_tab;} 35 NeuroImpl* makeNew(){return new NI_StdUNeuron();} // for NeuroFactory 36 void calcOutput(); 34 public: 35 NI_StdUNeuron() 36 { 37 paramentries = NI_StdUNeuron_tab; 38 } 39 NeuroImpl* makeNew(){ return new NI_StdUNeuron(); } // for NeuroFactory 40 void calcOutput(); 37 41 }; 38 42 39 class NI_Const : public NeuroImpl43 class NI_Const : public NeuroImpl 40 44 { 41 45 public: 42 NeuroImpl* makeNew(){return new NI_Const();} // for NeuroFactory43 int lateinit()46 NeuroImpl* makeNew(){ return new NI_Const(); } // for NeuroFactory 47 int lateinit() 44 48 { 45 neuro->state=newstate=1.0;46 simorder=0;47 return 1;49 neuro->state = newstate = 1.0; 50 simorder = 0; 51 return 1; 48 52 } 49 53 }; … … 51 55 class NI_Diff : public NeuroImpl 52 56 { 53 double previous; 54 55 NeuroImpl* makeNew() { return new NI_Diff(); };57 double previous; 58 public: 59 NeuroImpl* makeNew() { return new NI_Diff(); }; 56 60 57 void go()61 void go() 58 62 { 59 double s=getWeightedInputSum();60 setState(s-previous);61 previous=s;63 double s = getWeightedInputSum(); 64 setState(s - previous); 65 previous = s; 62 66 } 63 int lateinit()67 int lateinit() 64 68 { 65 NeuroImpl::lateinit();66 previous=neuro->state;67 return 1;69 NeuroImpl::lateinit(); 70 previous = neuro->state; 71 return 1; 68 72 } 69 73 }; … … 71 75 class NI_Random : public NeuroImpl 72 76 { 73 74 NeuroImpl* makeNew() { return new NI_Random(); };75 void go() {setState(rnd01*2.0-1.0);}77 public: 78 NeuroImpl* makeNew() { return new NI_Random(); }; 79 void go() { setState(rnd01*2.0 - 1.0); } 76 80 }; 77 81 … … 80 84 class NI_Sinus : public NeuroImpl 81 85 { 82 public: 83 double f0,t; 84 NeuroImpl* makeNew() { return new NI_Sinus(); }; 85 NI_Sinus():f0(0),t(0) 86 {paramentries=NI_Sinus_tab;} 87 void go() 86 public: 87 double f0, t; 88 NeuroImpl* makeNew() { return new NI_Sinus(); }; 89 NI_Sinus() :f0(0), t(0) 88 90 { 89 t+=f0+getWeightedInputSum(); 90 setState(sin(t)); 91 paramentries = NI_Sinus_tab; 92 } 93 void go() 94 { 95 t += f0 + getWeightedInputSum(); 96 setState(sin(t)); 91 97 } 92 98 }; 93 99 94 100 #endif 95
Note: See TracChangeset
for help on using the changeset viewer.