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

DOUBLE

public static final int DOUBLE

FLOAT

public static final int FLOAT

INT16

public static final int INT16

INT32

public static final int INT32

INT64

public static final int INT64

INT8

public static final int INT8

MAX_RANK

public static final int MAX_RANK

Constructors

Data

public Data(byte[] data)

Data

public Data(byte[][] data)

Data

public Data(byte[][][] data)

Data

public Data(short[] data)

Data

public Data(short[][] data)

Data

public Data(short[][][] data)

Data

public Data(int[] data)

Data

public Data(int[][] data)

Data

public Data(int[][][] data)

Data

public Data(long[] data)

Data

public Data(long[][] data)

Data

public Data(long[][][] data)

Data

public Data(double[] data)

Data

public Data(double[][] data)

Data

public Data(double[][][] data)

Data

public Data(float[] data)

Data

public Data(float[][] data)

Data

public Data(float[][][] data)

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:

createRawObject

public static Object createRawObject(int type, long[] dimensions)

Create a multidimensional array object of a selected type and dimensions.

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

public static Data from1DArray(Object array, int type, long[] dimensions)

Reshapes 1-D array to a multidimensional array of correct dimensions. Motivation: HDF5 library returns only 1-D arrays. In C order.

getDimensions

public long[] getDimensions()

Get length of the data along all dimensions.

getRank

public int getRank()

Get the number of dimensions. i.e. double[] => 1, short[][] => 2 etc.

getRawData

public Object getRawData()

Get the original array used for the initialization of this object. No type information, you have to cast it yourself.

getType

public int getType()

Get the type of stored array (in terms of constants defined in this class). Our data types differ from HDF5 so that this class is not dependent on HDF5 library. Hdf5Utils class contains conversion routines.

linearTransform

public Data linearTransform(double mul, double add)