Class NdArrays
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic BooleanNdArrayofBooleans(Shape shape) Creates an N-dimensional array of booleans of the given shape.static ByteNdArrayCreates an N-dimensional array of bytes of the given shape.static DoubleNdArrayCreates an N-dimensional array of doubles of the given shape.static FloatNdArrayCreates an N-dimensional array of floats of the given shape.static IntNdArrayCreates an N-dimensional array of ints of the given shape.static LongNdArrayCreates an N-dimensional array of longs of the given shape.static <T> NdArray<T> Creates an N-dimensional array of the given shape.static ShortNdArrayCreates an N-dimensional array of shorts of the given shape.static BooleanNdArrayscalarOf(boolean value) Creates boolean scalar (rank 0) initialized with the given value.static ByteNdArrayscalarOf(byte value) Creates byte scalar (rank 0) initialized with the given value.static DoubleNdArrayscalarOf(double value) Creates double scalar (rank 0) initialized with the given value.static FloatNdArrayscalarOf(float value) Creates float scalar (rank 0) initialized with the given value.static IntNdArrayscalarOf(int value) Creates long scalar (rank 0) initialized with the given value.static LongNdArrayscalarOf(long value) Creates long scalar (rank 0) initialized with the given value.static ShortNdArrayscalarOf(short value) Creates short 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 BooleanSparseNdArraysparseOf(LongNdArray indices, BooleanNdArray values, boolean defaultValue, Shape shape) Creates a Sparse array of boolean valuesstatic BooleanSparseNdArraysparseOf(LongNdArray indices, BooleanNdArray values, Shape shape) Creates a Sparse array of boolean values with a default value of 'false'static ByteSparseNdArraysparseOf(LongNdArray indices, ByteNdArray values, byte defaultValue, Shape shape) Creates a Sparse array of byte valuesstatic ByteSparseNdArraysparseOf(LongNdArray indices, ByteNdArray values, Shape shape) Creates a Sparse array of byte values with a default value of zerostatic DoubleSparseNdArraysparseOf(LongNdArray indices, DoubleNdArray values, double defaultValue, Shape shape) Creates a Sparse array of double valuesstatic DoubleSparseNdArraysparseOf(LongNdArray indices, DoubleNdArray values, Shape shape) Creates a Sparse array of double values with a default value of zerostatic FloatSparseNdArraysparseOf(LongNdArray indices, FloatNdArray values, float defaultValue, Shape shape) Creates a Sparse array of float valuesstatic FloatSparseNdArraysparseOf(LongNdArray indices, FloatNdArray values, Shape shape) Creates a Sparse array of float values with a default value of zerostatic IntSparseNdArraysparseOf(LongNdArray indices, IntNdArray values, int defaultValue, Shape shape) Creates a Sparse array of int valuesstatic IntSparseNdArraysparseOf(LongNdArray indices, IntNdArray values, Shape shape) Creates a Sparse array of int values with a default value of zero.static LongSparseNdArraysparseOf(LongNdArray indices, LongNdArray values, long defaultValue, Shape shape) Creates a Sparse array of long values with a default value of zerostatic LongSparseNdArraysparseOf(LongNdArray indices, LongNdArray values, Shape shape) Creates a Sparse array of long values with a default value of zerostatic ShortSparseNdArraysparseOf(LongNdArray indices, ShortNdArray values, short defaultValue, Shape shape) Creates a Sparse array of short valuesstatic ShortSparseNdArraysparseOf(LongNdArray indices, ShortNdArray values, Shape shape) Creates a Sparse array of short values with a default value of zerostatic <T> NdArray<T> sparseOfObjects(Class<T> type, LongNdArray indices, NdArray<T> values, Shape shape) Creates a Sparse array of values with a null default valuestatic <T> NdArray<T> sparseOfObjects(Class<T> type, LongNdArray indices, NdArray<T> values, T defaultValue, Shape shape) Creates a Sparse array of valuesstatic BooleanNdArrayvectorOf(boolean... values) Creates a boolean vector (rank 1) initialized with the given values.static ByteNdArrayvectorOf(byte... values) Creates a byte vector (rank 1) initialized with the given values.static DoubleNdArrayvectorOf(double... values) Creates a double vector (rank 1) initialized with the given values.static FloatNdArrayvectorOf(float... values) Creates a float vector (rank 1) initialized with the given values.static IntNdArrayvectorOf(int... values) Creates a int vector (rank 1) initialized with the given values.static LongNdArrayvectorOf(long... values) Creates a long vector (rank 1) initialized with the given values.static ShortNdArrayvectorOf(short... values) Creates a short 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 BooleanNdArraywrap(Shape shape, BooleanDataBuffer buffer) Wraps a buffer in a boolean N-dimensional array of a given shape.static ByteNdArraywrap(Shape shape, ByteDataBuffer buffer) Wraps a buffer in a byte 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 DoubleNdArraywrap(Shape shape, DoubleDataBuffer buffer) Wraps a buffer in a double N-dimensional array of a given shape.static FloatNdArraywrap(Shape shape, FloatDataBuffer buffer) Wraps a buffer in a float N-dimensional array of a given shape.static IntNdArraywrap(Shape shape, IntDataBuffer buffer) Wraps a buffer in an int N-dimensional array of a given shape.static LongNdArraywrap(Shape shape, LongDataBuffer buffer) Wraps a buffer in a long N-dimensional array of a given shape.static ShortNdArraywrap(Shape shape, ShortDataBuffer buffer) Wraps a buffer in a short N-dimensional array of a given shape.
-
Constructor Details
-
NdArrays
public NdArrays()
-
-
Method Details
-
scalarOf
Creates byte scalar (rank 0) initialized with the given value.- Parameters:
value- scalar value- Returns:
- new byte scalar
-
vectorOf
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
-
ofBytes
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
-
wrap
Wraps a buffer in a byte N-dimensional array of a given shape.- Parameters:
shape- shape of the arraybuffer- 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
-
sparseOf
Creates a Sparse array of byte values with a default value of zero- Parameters:
indices- A 2-D LongNdArray of shape[N, ndims], that specifies the indices of the elements in the sparse array that contain non-default values (elements are zero-indexed). For example,indices=[[1,3,1], [2,4,0]]specifies that the elements with indexes of[1,3,1]and[2,4,0]have non-default values.values- A 1-D ByteNdArray of shape[N], which supplies the values for each element in indices. For example, givenindices=[[1,3,1], [2,4,0]], the parametervalues=[18, 3]specifies that element[1,3,1]of the sparse NdArray has a value of18, and element[2,4,0]of the NdArray has a value of3.shape- the shape of the dense array represented by this sparse array.- Returns:
- the byte sparse array.
-
sparseOf
public static ByteSparseNdArray sparseOf(LongNdArray indices, ByteNdArray values, byte defaultValue, Shape shape) Creates a Sparse array of byte values- Parameters:
indices- A 2-D LongNdArray of shape[N, ndims], that specifies the indices of the elements in the sparse array that contain non-default values (elements are zero-indexed). For example,indices=[[1,3,1], [2,4,0]]specifies that the elements with indexes of[1,3,1]and[2,4,0]have non default values.values- A 1-D ByteNdArray of shape[N], which supplies the values for each element in indices. For example, givenindices=[[1,3,1], [2,4,0]], the parametervalues=[18, 3]specifies that element[1,3,1]of the sparse NdArray has a value of18, and element[2,4,0]of the NdArray has a value of3.defaultValue- Scalar value to set for indices not specified in 'indices'shape- the shape of the dense array represented by this sparse array.- Returns:
- the byte sparse array.
-
scalarOf
Creates long scalar (rank 0) initialized with the given value.- Parameters:
value- scalar value- Returns:
- new long scalar
-
vectorOf
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
-
ofLongs
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
-
wrap
Wraps a buffer in a long N-dimensional array of a given shape.- Parameters:
shape- shape of the arraybuffer- 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
-
sparseOf
Creates a Sparse array of long values with a default value of zero- Parameters:
indices- A 2-D LongNdArray of shape[N, ndims], that specifies the indices of the elements in the sparse array that contain non-default values (elements are zero-indexed). For example,indices=[[1,3,1], [2,4,0]]specifies that the elements with indexes of[1,3,1]and[2,4,0]have non-default values.values- A 1-D LongNdArray of shape[N], which supplies the values for each element in indices. For example, givenindices=[[1,3,1], [2,4,0]], the parametervalues=[18L, 3L]specifies that element[1,3,1]of the sparse NdArray has a value of18L, and element[2,4,0]of the NdArray has a value of3L.shape- the shape of the dense array represented by this sparse array.- Returns:
- the long sparse array.
-
sparseOf
public static LongSparseNdArray sparseOf(LongNdArray indices, LongNdArray values, long defaultValue, Shape shape) Creates a Sparse array of long values with a default value of zero- Parameters:
indices- A 2-D LongNdArray of shape[N, ndims], that specifies the indices of the elements in the sparse array that contain non-default values (elements are zero-indexed). For example,indices=[[1,3,1], [2,4,0]]specifies that the elements with indexes of[1,3,1]and[2,4,0]have non-default values.values- A 1-D LongNdArray of shape[N], which supplies the values for each element in indices. For example, givenindices=[[1,3,1], [2,4,0]], the parametervalues=[18L, 3L]specifies that element[1,3,1]of the sparse NdArray has a value of18L, and element[2,4,0]of the NdArray has a value of3L.defaultValue- Scalar value to set for indices not specified in 'indices'shape- the shape of the dense array represented by this sparse array.- Returns:
- the long sparse array.
-
scalarOf
Creates long scalar (rank 0) initialized with the given value.- Parameters:
value- scalar value- Returns:
- new long scalar
-
vectorOf
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
-
ofInts
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
-
wrap
Wraps a buffer in an int N-dimensional array of a given shape.- Parameters:
shape- shape of the arraybuffer- 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
-
sparseOf
Creates a Sparse array of int values with a default value of zero.- Parameters:
indices- A 2-D LongNdArray of shape[N, ndims], that specifies the indices of the elements in the sparse array that contain non-default values (elements are zero-indexed). For example,indices=[[1,3,1], [2,4,0]]specifies that the elements with indexes of[1,3,1]and[2,4,0]have non-default values.values- A 1-D IntNdArray of shape[N], which supplies the values for each element in indices. For example, givenindices=[[1,3,1], [2,4,0]], the parametervalues=[18, 3]specifies that element[1,3,1]of the sparse NdArray has a value of18, and element[2,4,0]of the NdArray has a value of3.shape- the shape of the dense array represented by this sparse array.- Returns:
- the int sparse array.
-
sparseOf
public static IntSparseNdArray sparseOf(LongNdArray indices, IntNdArray values, int defaultValue, Shape shape) Creates a Sparse array of int values- Parameters:
indices- A 2-D LongNdArray of shape[N, ndims], that specifies the indices of the elements in the sparse array that contain non-default values (elements are zero-indexed). For example,indices=[[1,3,1], [2,4,0]]specifies that the elements with indexes of[1,3,1]and[2,4,0]have non-default values.values- A 1-D IntNdArray of shape[N], which supplies the values for each element in indices. For example, givenindices=[[1,3,1], [2,4,0]], the parametervalues=[18, 3]specifies that element[1,3,1]of the sparse NdArray has a value of18, and element[2,4,0]of the NdArray has a value of3.defaultValue- Scalar value to set for indices not specified in 'indices'shape- the shape of the dense array represented by this sparse array.- Returns:
- the int sparse array.
-
scalarOf
Creates short scalar (rank 0) initialized with the given value.- Parameters:
value- scalar value- Returns:
- new short scalar
-
vectorOf
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
-
ofShorts
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
-
wrap
Wraps a buffer in a short N-dimensional array of a given shape.- Parameters:
shape- shape of the arraybuffer- 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
-
sparseOf
Creates a Sparse array of short values with a default value of zero- Parameters:
indices- A 2-D LongNdArray of shape[N, ndims], that specifies the indices of the elements in the sparse array that contain non-default values (elements are zero-indexed). For example,indices=[[1,3,1], [2,4,0]]specifies that the elements with indexes of[1,3,1]and[2,4,0]have non-default values.values- A 1-D ShortNdArray of shape[N], which supplies the values for each element in indices. For example, givenindices=[[1,3,1], [2,4,0]], the parametervalues=[18, 3]specifies that element[1,3,1]of the sparse NdArray has a value of18, and element[2,4,0]of the NdArray has a value of3.shape- the shape of the dense array represented by this sparse array.- Returns:
- the short sparse array.
-
sparseOf
public static ShortSparseNdArray sparseOf(LongNdArray indices, ShortNdArray values, short defaultValue, Shape shape) Creates a Sparse array of short values- Parameters:
indices- A 2-D LongNdArray of shape[N, ndims], that specifies the indices of the elements in the sparse array that contain non-default values (elements are zero-indexed). For example,indices=[[1,3,1], [2,4,0]]specifies that the elements with indexes of[1,3,1]and[2,4,0]have non-default values.values- A 1-D ShortNdArray of shape[N], which supplies the values for each element in indices. For example, givenindices=[[1,3,1], [2,4,0]], the parametervalues=[18, 3]specifies that element[1,3,1]of the sparse NdArray has a value of18, and element[2,4,0]of the NdArray has a value of3.defaultValue- Scalar value to set for indices not specified in 'indices'shape- the shape of the dense array represented by this sparse array.- Returns:
- the short sparse array.
-
scalarOf
Creates float scalar (rank 0) initialized with the given value.- Parameters:
value- scalar value- Returns:
- new float scalar
-
vectorOf
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
-
ofFloats
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
-
wrap
Wraps a buffer in a float N-dimensional array of a given shape.- Parameters:
shape- shape of the arraybuffer- 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
-
sparseOf
Creates a Sparse array of float values with a default value of zero- Parameters:
indices- A 2-D LongNdArray of shape[N, ndims], that specifies the indices of the elements in the sparse array that contain non-default values (elements are zero-indexed). For example,indices=[[1,3,1], [2,4,0]]specifies that the elements with indexes of[1,3,1]and[2,4,0]have non-default values.values- A 1-D FloatNdArray of shape[N], which supplies the values for each element in indices. For example, givenindices=[[1,3,1], [2,4,0]], the parametervalues=[18f, 3.8f]specifies that element[1,3,1]of the sparse NdArray has a value of18f, and element[2,4,0]of the NdArray has a value of3.8f.shape- the shape of the dense array represented by this sparse array.- Returns:
- the float sparse array.
-
sparseOf
public static FloatSparseNdArray sparseOf(LongNdArray indices, FloatNdArray values, float defaultValue, Shape shape) Creates a Sparse array of float values- Parameters:
indices- A 2-D LongNdArray of shape[N, ndims], that specifies the indices of the elements in the sparse array that contain non-default values (elements are zero-indexed). For example,indices=[[1,3,1], [2,4,0]]specifies that the elements with indexes of[1,3,1]and[2,4,0]have non-default values.values- A 1-D FloatNdArray of shape[N], which supplies the values for each element in indices. For example, givenindices=[[1,3,1], [2,4,0]], the parametervalues=[18f, 3.8f]specifies that element[1,3,1]of the sparse NdArray has a value of18f, and element[2,4,0]of the NdArray has a value of3.8f.defaultValue- Scalar value to set for indices not specified in 'indices'shape- the shape of the dense array represented by this sparse array.- Returns:
- the float sparse array.
-
scalarOf
Creates double scalar (rank 0) initialized with the given value.- Parameters:
value- scalar value- Returns:
- new double scalar
-
vectorOf
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
-
ofDoubles
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
-
wrap
Wraps a buffer in a double N-dimensional array of a given shape.- Parameters:
shape- shape of the arraybuffer- 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
-
sparseOf
Creates a Sparse array of double values with a default value of zero- Parameters:
indices- A 2-D LongNdArray of shape[N, ndims], that specifies the indices of the elements in the sparse array that contain non-default values (elements are zero-indexed). For example,indices=[[1,3,1], [2,4,0]]specifies that the elements with indexes of[1,3,1]and[2,4,0]have non-default values.values- A 1-D DoubleNdArray of shape[N], which supplies the values for each element in indices. For example, givenindices=[[1,3,1], [2,4,0]], the parametervalues=[18, 3.8]specifies that element[1,3,1]of the sparse NdArray has a value of18, and element[2,4,0]of the NdArray has a value of3.8.shape- the shape of the dense array represented by this sparse array.- Returns:
- the float sparse array.
-
sparseOf
public static DoubleSparseNdArray sparseOf(LongNdArray indices, DoubleNdArray values, double defaultValue, Shape shape) Creates a Sparse array of double values- Parameters:
indices- A 2-D LongNdArray of shape[N, ndims], that specifies the indices of the elements in the sparse array that contain non-default values (elements are zero-indexed). For example,indices=[[1,3,1], [2,4,0]]specifies that the elements with indexes of[1,3,1]and[2,4,0]have non-default values.values- A 1-D DoubleNdArray of shape[N], which supplies the values for each element in indices. For example, givenindices=[[1,3,1], [2,4,0]], the parametervalues=[18, 3.8]specifies that element[1,3,1]of the sparse NdArray has a value of18, and element[2,4,0]of the NdArray has a value of3.8.defaultValue- Scalar value to set for indices not specified in 'indices'shape- the shape of the dense array represented by this sparse array.- Returns:
- the float sparse array.
-
scalarOf
Creates boolean scalar (rank 0) initialized with the given value.- Parameters:
value- scalar value- Returns:
- new boolean scalar
-
vectorOf
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
-
ofBooleans
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
-
wrap
Wraps a buffer in a boolean N-dimensional array of a given shape.- Parameters:
shape- shape of the arraybuffer- 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
-
sparseOf
public static BooleanSparseNdArray sparseOf(LongNdArray indices, BooleanNdArray values, Shape shape) Creates a Sparse array of boolean values with a default value of 'false'- Parameters:
indices- A 2-D LongNdArray of shape[N, ndims], that specifies the indices of the elements in the sparse array that contain non-default values (elements are zero-indexed). For example,indices=[[1,3,1], [2,4,0]]specifies that the elements with indexes of[1,3,1]and[2,4,0]have non-default values.values- A 1-D BooleanNdArray of shape[N], which supplies the values for each element in indices. For example, givenindices=[[1,3,1], [2,4,0]], the parametervalues=[true, true]specifies that element[1,3,1]of the sparse NdArray has a value of true, and element[2,4,0]of the NdArray has a value of true. All other values are false.shape- the shape of the dense array represented by this sparse array.- Returns:
- the float sparse array.
-
sparseOf
public static BooleanSparseNdArray sparseOf(LongNdArray indices, BooleanNdArray values, boolean defaultValue, Shape shape) Creates a Sparse array of boolean values- Parameters:
indices- A 2-D LongNdArray of shape[N, ndims], that specifies the indices of the elements in the sparse array that contain non-default values (elements are zero-indexed). For example,indices=[[1,3,1], [2,4,0]]specifies that the elements with indexes of[1,3,1]and[2,4,0]have non-default values.values- A 1-D BooleanNdArray of shape[N], which supplies the values for each element in indices. For example, givenindices=[[1,3,1], [2,4,0]], the parametervalues=[true, true]specifies that element[1,3,1]of the sparse NdArray has a value of true, and element[2,4,0]of the NdArray has a value of true. All other values are false.defaultValue- Scalar value to set for indices not specified in 'indices'shape- the shape of the dense array represented by this sparse array.- Returns:
- the float sparse array.
-
scalarOfObject
Creates scalar (rank 0) initialized with the given value.- Type Parameters:
T- the data type- Parameters:
value- scalar value- Returns:
- new scalar
-
vectorOfObjects
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.
- Type Parameters:
T- the data type- Parameters:
values- vector values- Returns:
- new vector
- Throws:
IllegalArgumentException- if values is null
-
ofObjects
Creates an N-dimensional array of the given shape.All values are initialized to zeros.
- Type Parameters:
T- the data type- Parameters:
clazz- class of the data to be stored in this arrayshape- shape of the array- Returns:
- new N-dimensional array
- Throws:
IllegalArgumentException- if shape is null or has unknown dimensions
-
wrap
Wraps a buffer in an N-dimensional array of a given shape.- Type Parameters:
T- the data type- Parameters:
shape- shape of the arraybuffer- 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
-
sparseOfObjects
public static <T> NdArray<T> sparseOfObjects(Class<T> type, LongNdArray indices, NdArray<T> values, Shape shape) Creates a Sparse array of values with a null default value- Parameters:
type- the class type represented by this sparse array.indices- A 2-D LongNdArray of shape[N, ndims], that specifies the indices of the elements in the sparse array that contain non-default values (elements are zero-indexed). For example,indices=[[1,3,1], [2,4,0]]specifies that the elements with indexes of[1,3,1]and[2,4,0]have non-default values.values- A 1-D NdArray of shape[N], which supplies the values for each element in indices. For example, givenindices=[[1,3,1], [2,4,0]], the parametervalues=["one", "two"]specifies that element[1,3,1]of the sparse NdArray has a value of "one", and element[2,4,0]of the NdArray has a value of "two"". All other values are null.shape- the shape of the dense array represented by this sparse array.- Returns:
- the float sparse array.
-
sparseOfObjects
public static <T> NdArray<T> sparseOfObjects(Class<T> type, LongNdArray indices, NdArray<T> values, T defaultValue, Shape shape) Creates a Sparse array of values- Parameters:
type- the class type represented by this sparse array.indices- A 2-D LongNdArray of shape[N, ndims], that specifies the indices of the elements in the sparse array that contain non-default values (elements are zero-indexed). For example,indices=[[1,3,1], [2,4,0]]specifies that the elements with indexes of[1,3,1]and[2,4,0]have non-default values.values- A 1-D NdArray of shape[N], which supplies the values for each element in indices. For example, givenindices=[[1,3,1], [2,4,0]], the parametervalues=["one", "two"]specifies that element[1,3,1]of the sparse NdArray has a value of "one", and element[2,4,0]of the NdArray has a value of "two"". All other values are null.defaultValue- Scalar value to set for indices not specified in 'indices'shape- the shape of the dense array represented by this sparse array.- Returns:
- the float sparse array.
-