summaryrefslogtreecommitdiff
path: root/src/row.h
blob: 0ec5ddea9acee13fe2032e0dccbf48f3392a1bd1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#ifndef NEURAL_ROW_H
#define NEURAL_ROW_H

#include "neural/container.h"

namespace Neural
{
	template<typename sigtype>
	class Row : public Container<sigtype>
	{
	public:
		//typedef Bu::List<Neural::Node<sigtype> *> NodeList;
		Row() :
			iInputs( 0 ),
			iOutputs( 0 ),
			iWeights( 0 ),
			iBiases( 0 )
		{
		}

		virtual ~Row()
		{
		}

		virtual void finalize( int iNumInputs )
		{
			iInputs = iNumInputs;
			iOutputs = 0;
			iWeights = 0;
			iBiases = 0;

			for( typename Container<sigtype>::NodeList::iterator i =
				Container<sigtype>::getNodeList().begin(); i; i++ )
			{
				(*i)->finalize( iInputs );
				iOutputs += (*i)->getNumOutputs();
				iWeights += (*i)->getNumWeights();
				iBiases += (*i)->getNumBiases();
			}
		}

		virtual void process( sigtype *aInput, sigtype *aOutput )
		{
			int iOutputOffset = 0;
			for( typename Container<sigtype>::NodeList::iterator i =
				Container<sigtype>::getNodeList().begin(); i; i++ )
			{
				(*i)->process( aInput, aOutput+iOutputOffset );
				iOutputOffset += (*i)->getNumOutputs();
			}
		}

		virtual int getNumInputs() const
		{
			return iInputs;
		}

		virtual int getNumOutputs() const
		{
			return iOutputs;
		}

		virtual int getNumWeights() const
		{
			return iWeights;
		}

		virtual int getNumBiases() const
		{
			return iBiases;
		}

	private:
		int iInputs;
		int iOutputs;
		int iWeights;
		int iBiases;
	};
};

#endif