public class DoubleArrayBackedDataSource extends Object implements DataSource<double[]>
DataSource backed by a 2D array of doubles.| Modifier and Type | Field and Description |
|---|---|
protected double[][] |
data |
protected Random |
rng |
| Constructor and Description |
|---|
DoubleArrayBackedDataSource(double[][] data)
Construct with data
|
DoubleArrayBackedDataSource(double[][] data,
Random rng)
Construct with data and a random generator for random sampling
|
| Modifier and Type | Method and Description |
|---|---|
double[][] |
createTemporaryArray(int size)
Create a temporary array suitable for use with the
DataSource.getRandomRows(Object[]) and DataSource.getData(int, int, Object[])
methods. |
double[] |
getData(int row)
Get the data for a given row
|
void |
getData(int startRow,
int stopRow,
double[][] output)
Get data between given rows.
|
void |
getRandomRows(double[][] output) |
Iterator<double[]> |
iterator() |
int |
numDimensions() |
int |
size() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEach, spliteratorpublic DoubleArrayBackedDataSource(double[][] data)
data - the datapublic DoubleArrayBackedDataSource(double[][] data, Random rng)
data - the datarng - the random generatorpublic final void getData(int startRow, int stopRow, double[][] output)
DataSourceDataSource.size().
data is guaranteed to have (stopRow - startRow) valid entriesgetData in interface DataSource<double[]>startRow - where to start (inclusive)stopRow - where to stop (exclusive)output - the array to fillpublic final void getRandomRows(double[][] output)
getRandomRows in interface DataSource<double[]>output - a random set of data. This array is guaranteed to be filled.public int numDimensions()
numDimensions in interface DataSource<double[]>public int size()
size in interface DataSource<double[]>public double[] getData(int row)
DataSourcegetData in interface DataSource<double[]>row - the row numberpublic double[][] createTemporaryArray(int size)
DataSourceDataSource.getRandomRows(Object[]) and DataSource.getData(int, int, Object[])
methods.createTemporaryArray in interface DataSource<double[]>size - the size of the array