org.encog.ml.data.basic

## Class BasicMLData

- java.lang.Object
- - org.encog.ml.data.basic.BasicMLData

- All Implemented Interfaces:
    Serializable, Cloneable, MLData, CentroidFactory<MLData>
  Direct Known Subclasses:
    BasicNeuralData, ImageMLData

      public class BasicMLData
      extends Object
      implements MLData, Serializable, Cloneable

  Basic implementation of the MLData interface that stores the data in an array.
  Author:
    jheaton
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `BasicMLData(double[] d)` Construct this object with the specified data.
    `BasicMLData(int size)` Construct this object with blank data and a specified size.
    `BasicMLData(MLData d)` Construct a new BasicMLData object from an existing one.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `add(int index, double value)` Add a value to the specified index.
    `void` | `clear()` Clear any data to zero.
    `MLData` | `clone()` Clone this object.
    `Centroid<MLData>` | `createCentroid()`
    `double[]` | `getData()`
    `double` | `getData(int index)` Get the element specified index value.
    `MLData` | `minus(MLData o)` Subtract one data element from another.
    `MLData` | `plus(MLData o)` Add one data element to another.
    `void` | `setData(double[] theData)` Set all of the data as an array of doubles.
    `void` | `setData(int index, double d)` Set the specified element.
    `int` | `size()`
    `MLData` | `times(double d)` Multiply one data element with another.
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### BasicMLData

          public BasicMLData(double[] d)

      Construct this object with the specified data.
      Parameters:
        `d` - The data to construct this object with.

    - #### BasicMLData

          public BasicMLData(int size)

      Construct this object with blank data and a specified size.
      Parameters:
        `size` - The amount of data to store.

    - #### BasicMLData

          public BasicMLData(MLData d)

      Construct a new BasicMLData 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 `MLData`
      Parameters:
        `index` - The index to add to.
        `value` - The value to add.

    - #### clear

          public void clear()

      Clear any data to zero.
      Specified by:
        `clear` in interface `MLData`

    - #### clone

          public MLData clone()

      Clone this object.
      Specified by:
        `clone` in interface `MLData`
      Overrides:
        `clone` in class `Object`
      Returns:
        A cloned version of this object.

    - #### getData

          public double[] getData()

      Specified by:
        `getData` in interface `MLData`
      Returns:
        All of the elements as an array.

    - #### getData

          public double getData(int index)

      Get the element specified index value.
      Specified by:
        `getData` in interface `MLData`
      Parameters:
        `index` - The index to read.
      Returns:
        The value at the specified inedx.

    - #### setData

          public void setData(double[] theData)

      Set all of the data as an array of doubles.
      Specified by:
        `setData` in interface `MLData`
      Parameters:
        `theData` - An array of doubles.

    - #### setData

          public void setData(int index,
                     double d)

      Set the specified element.
      Specified by:
        `setData` in interface `MLData`
      Parameters:
        `index` - The index to set.
        `d` - The data for the specified element.

    - #### size

          public int size()

      Specified by:
        `size` in interface `MLData`
      Returns:
        How many elements are stored in this object.

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### createCentroid

          public Centroid<MLData> createCentroid()

      Specified by:
        `createCentroid` in interface `CentroidFactory<MLData>`
      Returns:
        The centroid.

    - #### plus

          public MLData plus(MLData o)

      Add one data element to another. This does not modify the object.
      Parameters:
        `o` - The other data element
      Returns:
        The result.

    - #### times

          public MLData times(double d)

      Multiply one data element with another. This does not modify the object.
      Parameters:
        `d` - The other data element
      Returns:
        The result.

    - #### minus

          public MLData minus(MLData o)

      Subtract one data element from another. This does not modify the object.
      Parameters:
        `o` - The other data element
      Returns:
        The result.

Copyright © 2014. All Rights Reserved.