Data¶
-
public class
Data
¶ Wrapper around data. It enables us to live with just one copy of most methods and pass data around independently of its dimension and numerical type. It can be constructed using: 1) one of the 6x3 constructors with explicit array types 2) a general constructor using Object and dimensionality data specified by you.
Author: pipek
Fields¶
Constructors¶
Data¶
-
public
Data
(Object data, int type, long[] dimensions)¶ Generic constructor.
Parameters: - data – The correct array object (or null)
- type – Type of data in terms of this class constants.
- dimensions – Length along all dimensions. Gets copied. This is useful if we obtain data from external source, we know its properties but we don’t want to cast them unnecessarily (like read from HDF5). Data needn’t be specified (in such case a new array is created.)
Methods¶
asDoubleArray1D¶
-
public double[]
asDoubleArray1D
()¶ Get a 1-D double array representation of data. Works for 1-D data. For doubles, it simply returns, for others, it converts them using ArrayUtils.asDoubleArray() (see).
Throws: - WrongDimensionsException – if data are not 1-D.
- UnknownDataTypeException – if conversion to double is not supported by underlying procedure.
createRawObject¶
flatten¶
-
public boolean
flatten
()¶ Remove dimensions that have length 1. Preserves 1D arrays. Makes changes only if there is a trivial dimension.
Returns: true if there was a change, false otherwise. Motivation: Our HDF5 file sometimes have Nx1 arrays instead of N arrays.
from1DArray¶
getRank¶
-
public int
getRank
()¶ Get the number of dimensions. i.e. double[] => 1, short[][] => 2 etc.