Last change
on this file since 56 was
5,
checked in by sz, 16 years ago
|
added the GDK (Genotype Development Kit)
|
File size:
848 bytes
|
Rev | Line | |
---|
[5] | 1 | // This file is a part of Framsticks GDK library. |
---|
| 2 | // Copyright (C) 2002-2006 Szymon Ulatowski. See LICENSE.txt for details. |
---|
| 3 | // Refer to http://www.frams.alife.pl/ for further information. |
---|
| 4 | |
---|
| 5 | #include "neuroimpl-channels.h" |
---|
| 6 | |
---|
| 7 | void NI_Channelize::go() |
---|
| 8 | { |
---|
| 9 | setChannelCount(getInputCount()); |
---|
| 10 | for(int i=0;i<getInputCount();i++) |
---|
| 11 | setState(getWeightedInputState(i),i); |
---|
| 12 | } |
---|
| 13 | |
---|
| 14 | void NI_ChMux::go() |
---|
| 15 | { |
---|
| 16 | int c=getInputChannelCount(1); |
---|
| 17 | if (c<2) {setState(getWeightedInputState(1)); return;} |
---|
| 18 | double s=getWeightedInputState(0); |
---|
| 19 | s=(max(-1.0,min(1.0,s))+1.0)/2.0; // 0..1 |
---|
| 20 | int i1; |
---|
| 21 | i1=s*(c-1); i1=max(0,min(i1,c-2)); |
---|
| 22 | double sw=1.0/(c-1); |
---|
| 23 | double s1=sw*i1; |
---|
| 24 | double w1=fabs((s-s1)/sw); |
---|
| 25 | double w2=1.0-w1; |
---|
| 26 | double is1=getWeightedInputState(1,i1); |
---|
| 27 | double is2=getWeightedInputState(1,i1+1); |
---|
| 28 | setState(is1*w2 + is2*w1); |
---|
| 29 | } |
---|
| 30 | |
---|
| 31 | void NI_ChSel::go() |
---|
| 32 | { |
---|
| 33 | setState(getWeightedInputState(0,ch)); |
---|
| 34 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.