SignalArray |
SignalArray wraps a native array along with an offset into that array. The resulting SignalArray provides offset indexed access to the underlying native array. SignalArray minimizes the amount of value copying required when setting input signal values to, and reading output values from an IBlackBox. E.g. FastCyclicNetwork requires all input, output and hidden node activation values to be stored in a single array. This class allows us to handle direct access to the input and output values through their own SignalArray, thus we can set individual values in the underlying native array directly without having knowledge of that array's structure. An alternative would be to pass arrays to SetInputs() and SetOutput() methods, requiring us to copy the complete contents of the arrays into the IBlackBox's working array on each call. This class is effectively a substitute for array pointer manipulation as is possible in C++, e.g. in C++ you might do something like: double[] allSignals = new double[100]; double[] inputSignals = &allSignals + 1; // Skip bias neuron. double[] outputSignals = &allSignals + 10; // Skip bias and input neurons. In the above example access to the real items outside of the bounds of the sub-ranges is possible (e.g. inputSignals[10] yields the first output signal). SignalArray also does not check for such out-of-bounds accesses, accept when running with a debugger attached in which case assertions will make these tests. |