The Encog Project

org.encog.neural.data.basic
Class BasicNeuralData

java.lang.Object
  extended by org.encog.neural.data.basic.BasicNeuralData
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, NeuralData
Direct Known Subclasses:
ImageNeuralData

public class BasicNeuralData
extends java.lang.Object
implements NeuralData, java.io.Serializable, java.lang.Cloneable

Basic implementation of the NeuralData interface that stores the data in an array.

Author:
jheaton
See Also:
Serialized Form

Constructor Summary
BasicNeuralData(double[] d)
          Construct this object with the specified data.
BasicNeuralData(int size)
          Construct this object with blank data and a specified size.
BasicNeuralData(NeuralData d)
          Construct a new BasicNeuralData object from an existing one.
 
Method Summary
 void add(int index, double value)
          Add a value to the specified index.
 void clear()
          Set all data to zero.
 NeuralData clone()
          Clone this object.
 double[] getData()
          Get the data as an array.
 double getData(int index)
          Get a data value at the specified index.
 void setData(double[] data)
          Set the entire data array.
 void setData(int index, double d)
          Set the data element specified by the index.
 int size()
          Get the number of data elements present.
 java.lang.String toString()
          Return a string representation of this object.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BasicNeuralData

public BasicNeuralData(double[] d)
Construct this object with the specified data.

Parameters:
d - The data to construct this object with.

BasicNeuralData

public BasicNeuralData(int size)
Construct this object with blank data and a specified size.

Parameters:
size - The amount of data to store.

BasicNeuralData

public BasicNeuralData(NeuralData d)
Construct a new BasicNeuralData object from an existing one. This makes a copy of an array.

Parameters:
d - The object to be copied.
Method Detail

add

public void add(int index,
                double value)
Add a value to the specified index.

Specified by:
add in interface NeuralData
Parameters:
index - The index to add to.
value - The value to add.

clear

public void clear()
Set all data to zero.

Specified by:
clear in interface NeuralData

clone

public NeuralData clone()
Description copied from interface: NeuralData
Clone this object.

Specified by:
clone in interface NeuralData
Overrides:
clone in class java.lang.Object
Returns:
A clone of this object.

getData

public double[] getData()
Get the data as an array.

Specified by:
getData in interface NeuralData
Returns:
The data held by this object.

getData

public double getData(int index)
Get a data value at the specified index.

Specified by:
getData in interface NeuralData
Parameters:
index - The index to read.
Returns:
The data at the specified index.

setData

public void setData(double[] data)
Set the entire data array.

Specified by:
setData in interface NeuralData
Parameters:
data - The data to store.

setData

public void setData(int index,
                    double d)
Set the data element specified by the index.

Specified by:
setData in interface NeuralData
Parameters:
index - The data element to set.
d - The new value for the specified data element.

size

public int size()
Get the number of data elements present.

Specified by:
size in interface NeuralData
Returns:
The number of data elements present.

toString

public java.lang.String toString()
Return a string representation of this object.

Overrides:
toString in class java.lang.Object
Returns:
The string form of this object.

The Encog Project