NdArrays

public final class NdArrays

Utility class for instantiating NdArray objects.

Public Constructors

Public Methods

static BooleanNdArray
ofBooleans(Shape shape)
Creates an N-dimensional array of booleans of the given shape.
static ByteNdArray
ofBytes(Shape shape)
Creates an N-dimensional array of bytes of the given shape.
static DoubleNdArray
ofDoubles(Shape shape)
Creates an N-dimensional array of doubles of the given shape.
static FloatNdArray
ofFloats(Shape shape)
Creates an N-dimensional array of floats of the given shape.
static IntNdArray
ofInts(Shape shape)
Creates an N-dimensional array of ints of the given shape.
static LongNdArray
ofLongs(Shape shape)
Creates an N-dimensional array of longs of the given shape.
static <T> NdArray<T>
ofObjects(Class<T> clazz, Shape shape)
Creates an N-dimensional array of the given shape.
static ShortNdArray
ofShorts(Shape shape)
Creates an N-dimensional array of shorts of the given shape.
static ShortNdArray
scalarOf(short value)
Creates short scalar (rank 0) initialized with the given value.
static IntNdArray
scalarOf(int value)
Creates long scalar (rank 0) initialized with the given value.
static DoubleNdArray
scalarOf(double value)
Creates double scalar (rank 0) initialized with the given value.
static BooleanNdArray
scalarOf(boolean value)
Creates boolean scalar (rank 0) initialized with the given value.
static ByteNdArray
scalarOf(byte value)
Creates byte scalar (rank 0) initialized with the given value.
static LongNdArray
scalarOf(long value)
Creates long scalar (rank 0) initialized with the given value.
static FloatNdArray
scalarOf(float value)
Creates float scalar (rank 0) initialized with the given value.
static <T> NdArray<T>
scalarOfObject(T value)
Creates scalar (rank 0) initialized with the given value.
static LongNdArray
vectorOf(long... values)
Creates a long vector (rank 1) initialized with the given values.
static ShortNdArray
vectorOf(short... values)
Creates a short vector (rank 1) initialized with the given values.
static DoubleNdArray
vectorOf(double... values)
Creates a double vector (rank 1) initialized with the given values.
static BooleanNdArray
vectorOf(boolean... values)
Creates a boolean vector (rank 1) initialized with the given values.
static ByteNdArray
vectorOf(byte... values)
Creates a byte vector (rank 1) initialized with the given values.
static FloatNdArray
vectorOf(float... values)
Creates a float vector (rank 1) initialized with the given values.
static IntNdArray
vectorOf(int... values)
Creates a int vector (rank 1) initialized with the given values.
static <T> NdArray<T>
vectorOfObjects(T... values)
Creates a vector (rank 1) initialized with the given values.
static ByteNdArray
wrap(Shape shape, ByteDataBuffer buffer)
Wraps a buffer in a byte N-dimensional array of a given shape.
static DoubleNdArray
wrap(Shape shape, DoubleDataBuffer buffer)
Wraps a buffer in a double N-dimensional array of a given shape.
static ShortNdArray
wrap(Shape shape, ShortDataBuffer buffer)
Wraps a buffer in a short N-dimensional array of a given shape.
static <T> NdArray<T>
wrap(Shape shape, DataBuffer<T> buffer)
Wraps a buffer in an N-dimensional array of a given shape.
static FloatNdArray
wrap(Shape shape, FloatDataBuffer buffer)
Wraps a buffer in a float N-dimensional array of a given shape.
static LongNdArray
wrap(Shape shape, LongDataBuffer buffer)
Wraps a buffer in a long N-dimensional array of a given shape.
static IntNdArray
wrap(Shape shape, IntDataBuffer buffer)
Wraps a buffer in an int N-dimensional array of a given shape.
static BooleanNdArray
wrap(Shape shape, BooleanDataBuffer buffer)
Wraps a buffer in a boolean N-dimensional array of a given shape.

Inherited Methods

Public Constructors

public NdArrays ()

Public Methods

public static BooleanNdArray ofBooleans (Shape shape)

Creates an N-dimensional array of booleans of the given shape.

All values are initialized to zeros.

Parameters
shape shape of the array
Returns
  • new boolean N-dimensional array
Throws
IllegalArgumentException if shape is null or has unknown dimensions

public static ByteNdArray ofBytes (Shape shape)

Creates an N-dimensional array of bytes of the given shape.

All values are initialized to zeros.

Parameters
shape shape of the array
Returns
  • new byte N-dimensional array
Throws
IllegalArgumentException if shape is null or has unknown dimensions

public static DoubleNdArray ofDoubles (Shape shape)

Creates an N-dimensional array of doubles of the given shape.

All values are initialized to zeros.

Parameters
shape shape of the array
Returns
  • new double N-dimensional array
Throws
IllegalArgumentException if shape is null or has unknown dimensions

public static FloatNdArray ofFloats (Shape shape)

Creates an N-dimensional array of floats of the given shape.

All values are initialized to zeros.

Parameters
shape shape of the array
Returns
  • new float N-dimensional array
Throws
IllegalArgumentException if shape is null or has unknown dimensions

public static IntNdArray ofInts (Shape shape)

Creates an N-dimensional array of ints of the given shape.

All values are initialized to zeros.

Parameters
shape shape of the array
Returns
  • new int N-dimensional array
Throws
IllegalArgumentException if shape is null or has unknown dimensions

public static LongNdArray ofLongs (Shape shape)

Creates an N-dimensional array of longs of the given shape.

All values are initialized to zeros.

Parameters
shape shape of the array
Returns
  • new long N-dimensional array
Throws
IllegalArgumentException if shape is null or has unknown dimensions

public static NdArray<T> ofObjects (Class<T> clazz, Shape shape)

Creates an N-dimensional array of the given shape.

All values are initialized to zeros.

Parameters
clazz class of the data to be stored in this array
shape shape of the array
Returns
  • new N-dimensional array
Throws
IllegalArgumentException if shape is null or has unknown dimensions

public static ShortNdArray ofShorts (Shape shape)

Creates an N-dimensional array of shorts of the given shape.

All values are initialized to zeros.

Parameters
shape shape of the array
Returns
  • new short N-dimensional array
Throws
IllegalArgumentException if shape is null or has unknown dimensions

public static ShortNdArray scalarOf (short value)

Creates short scalar (rank 0) initialized with the given value.

Parameters
value scalar value
Returns
  • new short scalar

public static IntNdArray scalarOf (int value)

Creates long scalar (rank 0) initialized with the given value.

Parameters
value scalar value
Returns
  • new long scalar

public static DoubleNdArray scalarOf (double value)

Creates double scalar (rank 0) initialized with the given value.

Parameters
value scalar value
Returns
  • new double scalar

public static BooleanNdArray scalarOf (boolean value)

Creates boolean scalar (rank 0) initialized with the given value.

Parameters
value scalar value
Returns
  • new boolean scalar

public static ByteNdArray scalarOf (byte value)

Creates byte scalar (rank 0) initialized with the given value.

Parameters
value scalar value
Returns
  • new byte scalar

public static LongNdArray scalarOf (long value)

Creates long scalar (rank 0) initialized with the given value.

Parameters
value scalar value
Returns
  • new long scalar

public static FloatNdArray scalarOf (float value)

Creates float scalar (rank 0) initialized with the given value.

Parameters
value scalar value
Returns
  • new float scalar

public static NdArray<T> scalarOfObject (T value)

Creates scalar (rank 0) initialized with the given value.

Parameters
value scalar value
Returns
  • new scalar

public static LongNdArray vectorOf (long... values)

Creates a long vector (rank 1) initialized with the given values.

Modifying the data of the returned vector will also impact the values in the array passed in parameter.

Parameters
values vector values
Returns
  • new long vector
Throws
IllegalArgumentException if values is null

public static ShortNdArray vectorOf (short... values)

Creates a short vector (rank 1) initialized with the given values.

Modifying the data of the returned vector will also impact the values in the array passed in parameter.

Parameters
values vector values
Returns
  • new short vector
Throws
IllegalArgumentException if values is null

public static DoubleNdArray vectorOf (double... values)

Creates a double vector (rank 1) initialized with the given values.

Modifying the data of the returned vector will also impact the values in the array passed in parameter.

Parameters
values vector values
Returns
  • new double vector
Throws
IllegalArgumentException if values is null

public static BooleanNdArray vectorOf (boolean... values)

Creates a boolean vector (rank 1) initialized with the given values.

Modifying the data of the returned vector will also impact the values in the array passed in parameter.

Parameters
values vector values
Returns
  • new boolean vector
Throws
IllegalArgumentException if values is null

public static ByteNdArray vectorOf (byte... values)

Creates a byte vector (rank 1) initialized with the given values.

Modifying the data of the returned vector will also impact the values in the array passed in parameter.

Parameters
values vector values
Returns
  • new byte vector
Throws
IllegalArgumentException if values is null

public static FloatNdArray vectorOf (float... values)

Creates a float vector (rank 1) initialized with the given values.

Modifying the data of the returned vector will also impact the values in the array passed in parameter.

Parameters
values vector values
Returns
  • new float vector
Throws
IllegalArgumentException if values is null

public static IntNdArray vectorOf (int... values)

Creates a int vector (rank 1) initialized with the given values.

Modifying the data of the returned vector will also impact the values in the array passed in parameter.

Parameters
values vector values
Returns
  • new int vector
Throws
IllegalArgumentException if values is null

public static NdArray<T> vectorOfObjects (T... values)

Creates a vector (rank 1) initialized with the given values.

Modifying the data of the returned vector will also impact the values in the array passed in parameter.

Parameters
values vector values
Returns
  • new vector
Throws
IllegalArgumentException if values is null

public static ByteNdArray wrap (Shape shape, ByteDataBuffer buffer)

Wraps a buffer in a byte N-dimensional array of a given shape.

Parameters
shape shape of the array
buffer buffer to wrap
Returns
  • new byte N-dimensional array
Throws
IllegalArgumentException if shape is null, has unknown dimensions or has size bigger in the buffer size

public static DoubleNdArray wrap (Shape shape, DoubleDataBuffer buffer)

Wraps a buffer in a double N-dimensional array of a given shape.

Parameters
shape shape of the array
buffer buffer to wrap
Returns
  • new double N-dimensional array
Throws
IllegalArgumentException if shape is null, has unknown dimensions or has size bigger in the buffer size

public static ShortNdArray wrap (Shape shape, ShortDataBuffer buffer)

Wraps a buffer in a short N-dimensional array of a given shape.

Parameters
shape shape of the array
buffer buffer to wrap
Returns
  • new short N-dimensional array
Throws
IllegalArgumentException if shape is null, has unknown dimensions or has size bigger in the buffer size

public static NdArray<T> wrap (Shape shape, DataBuffer<T> buffer)

Wraps a buffer in an N-dimensional array of a given shape.

Parameters
shape shape of the array
buffer buffer to wrap
Returns
  • new N-dimensional array
Throws
IllegalArgumentException if shape is null, has unknown dimensions or has size bigger in the buffer size

public static FloatNdArray wrap (Shape shape, FloatDataBuffer buffer)

Wraps a buffer in a float N-dimensional array of a given shape.

Parameters
shape shape of the array
buffer buffer to wrap
Returns
  • new float N-dimensional array
Throws
IllegalArgumentException if shape is null, has unknown dimensions or has size bigger in the buffer size

public static LongNdArray wrap (Shape shape, LongDataBuffer buffer)

Wraps a buffer in a long N-dimensional array of a given shape.

Parameters
shape shape of the array
buffer buffer to wrap
Returns
  • new long N-dimensional array
Throws
IllegalArgumentException if shape is null, has unknown dimensions or has size bigger in the buffer size

public static IntNdArray wrap (Shape shape, IntDataBuffer buffer)

Wraps a buffer in an int N-dimensional array of a given shape.

Parameters
shape shape of the array
buffer buffer to wrap
Returns
  • new int N-dimensional array
Throws
IllegalArgumentException if shape is null, has unknown dimensions or has size bigger in the buffer size

public static BooleanNdArray wrap (Shape shape, BooleanDataBuffer buffer)

Wraps a buffer in a boolean N-dimensional array of a given shape.

Parameters
shape shape of the array
buffer buffer to wrap
Returns
  • new boolean N-dimensional array
Throws
IllegalArgumentException if shape is null, has unknown dimensions or has size bigger in the buffer size