source: cpp/gdk/neuroimpl-channels.cpp @ 5

Last change on this file since 5 was 5, checked in by sz, 15 years ago

added the GDK (Genotype Development Kit)

File size: 848 bytes
Line 
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
7void NI_Channelize::go()
8{
9setChannelCount(getInputCount());
10for(int i=0;i<getInputCount();i++)
11        setState(getWeightedInputState(i),i);
12}
13
14void NI_ChMux::go()
15{
16int c=getInputChannelCount(1);
17if (c<2) {setState(getWeightedInputState(1)); return;}
18double s=getWeightedInputState(0);
19s=(max(-1.0,min(1.0,s))+1.0)/2.0; // 0..1
20int i1;
21i1=s*(c-1); i1=max(0,min(i1,c-2));
22double sw=1.0/(c-1);
23double s1=sw*i1;
24double w1=fabs((s-s1)/sw);
25double w2=1.0-w1;
26double is1=getWeightedInputState(1,i1);
27double is2=getWeightedInputState(1,i1+1);
28setState(is1*w2 + is2*w1);
29}
30
31void NI_ChSel::go()
32{
33setState(getWeightedInputState(0,ch));
34}
Note: See TracBrowser for help on using the repository browser.