C# Class SharpNeat.Phenomes.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.
Inheritance: ISignalArray
Mostrar archivo Open project: colgreen/sharpneat Class Usage Examples

Public Methods

Method Description
CopyFrom ( double sourceArray, int targetIndex ) : void

Copies all elements from the source array writing them into the current SignalArray starting at the specified targetIndex.

CopyFrom ( double sourceArray, int targetIndex, int length ) : void

Copies length elements from the source array writing them to the current SignalArray starting at the specified targetIndex.

CopyFrom ( double sourceArray, int sourceIndex, int targetIndex, int length ) : void

Copies length elements starting from sourceIndex on sourceArray to the current SignalArray starting at the specified targetIndex.

CopyTo ( double targetArray, int targetIndex ) : void

Copies all elements from the current SignalArray to the specified target array starting at the specified target Array index.

CopyTo ( double targetArray, int targetIndex, int length ) : void

Copies length elements from the current SignalArray to the specified target array starting at the specified target Array index.

CopyTo ( double targetArray, int targetIndex, int sourceIndex, int length ) : void

Copies length elements from the current SignalArray to the specified target starting from targetIndex on the target array and sourceIndex on the current source SignalArray.

Reset ( ) : void

Reset all array elements to zero.

SignalArray ( double wrappedArray, int offset, int length ) : System

Construct a SignalArray that wraps the provided wrappedArray.

this ( int index ) : double

Gets or sets the single value at the specified index. We assert that the index is within the defined range of the signal array. Throwing an exception would be more correct but the check would affect performance of problem domains with large I/O throughput.

Method Details

CopyFrom() public method

Copies all elements from the source array writing them into the current SignalArray starting at the specified targetIndex.
public CopyFrom ( double sourceArray, int targetIndex ) : void
sourceArray double The array to copy elements from.
targetIndex int The index into the current SignalArray at which copying begins.
return void

CopyFrom() public method

Copies length elements from the source array writing them to the current SignalArray starting at the specified targetIndex.
public CopyFrom ( double sourceArray, int targetIndex, int length ) : void
sourceArray double The array to copy elements from.
targetIndex int The index into the current SignalArray at which copying begins.
length int The number of elements to copy.
return void

CopyFrom() public method

Copies length elements starting from sourceIndex on sourceArray to the current SignalArray starting at the specified targetIndex.
public CopyFrom ( double sourceArray, int sourceIndex, int targetIndex, int length ) : void
sourceArray double The array to copy elements from.
sourceIndex int The sourceArray index at which copying begins.
targetIndex int The index into the current SignalArray at which copying begins.
length int The number of elements to copy.
return void

CopyTo() public method

Copies all elements from the current SignalArray to the specified target array starting at the specified target Array index.
public CopyTo ( double targetArray, int targetIndex ) : void
targetArray double The array to copy elements to.
targetIndex int The targetArray index at which copying to begins.
return void

CopyTo() public method

Copies length elements from the current SignalArray to the specified target array starting at the specified target Array index.
public CopyTo ( double targetArray, int targetIndex, int length ) : void
targetArray double The array to copy elements to.
targetIndex int The targetArray index at which storing begins.
length int The number of elements to copy.
return void

CopyTo() public method

Copies length elements from the current SignalArray to the specified target starting from targetIndex on the target array and sourceIndex on the current source SignalArray.
public CopyTo ( double targetArray, int targetIndex, int sourceIndex, int length ) : void
targetArray double The array to copy elements to.
targetIndex int The targetArray index at which copying begins.
sourceIndex int The index into the current SignalArray at which copying begins.
length int The number of elements to copy.
return void

Reset() public method

Reset all array elements to zero.
public Reset ( ) : void
return void

SignalArray() public method

Construct a SignalArray that wraps the provided wrappedArray.
public SignalArray ( double wrappedArray, int offset, int length ) : System
wrappedArray double
offset int
length int
return System

this() public method

Gets or sets the single value at the specified index. We assert that the index is within the defined range of the signal array. Throwing an exception would be more correct but the check would affect performance of problem domains with large I/O throughput.
public this ( int index ) : double
index int
return double