public class BaseSparseNDArrayCOO extends BaseSparseNDArray
Modifier and Type | Field and Description |
---|---|
protected static SparseFormat |
format |
protected DataBuffer |
indices |
protected boolean |
isSorted |
protected DataBuffer |
values |
columns, isMatrix, isScalar, isSparse, isVector, javaShapeInformation, length, rank, rows, shape, shapeInformation, sparseInformation, stride, THRESHOLD_MEMORY_ALLOCATION
Constructor and Description |
---|
BaseSparseNDArrayCOO(DataBuffer values,
DataBuffer indices,
DataBuffer sparseInformation,
long[] shape) |
BaseSparseNDArrayCOO(DataBuffer values,
DataBuffer indices,
long[] shape) |
BaseSparseNDArrayCOO(DataBuffer values,
DataBuffer indices,
long[] sparseOffsets,
int[] flags,
int[] hiddenDimensions,
int underlyingRank,
long[] shape) |
BaseSparseNDArrayCOO(double[] values,
int[][] indices,
long[] shape) |
BaseSparseNDArrayCOO(double[] values,
long[][] indices,
long[] shape) |
BaseSparseNDArrayCOO(float[] values,
int[][] indices,
long[] shape) |
BaseSparseNDArrayCOO(float[] values,
long[][] indices,
long[] shape) |
Modifier and Type | Method and Description |
---|---|
void |
addOrUpdate(long[] indexes,
double value)
Add a new element in the ndarray or update the value if there is already a non-null element at this position
|
boolean |
all()
This method checks if all elements within this array are non-zero (or true, in case of boolean)
|
boolean |
any()
This method checks if any of the elements within this array are non-zero (or true, in case of boolean)
|
INDArray |
assign(INDArray arr)
Assign all of the elements in the given
ndarray to this ndarray
|
boolean |
canInsert(DataBuffer buffer,
int length)
Return if there is enough allocated memory space to add data of a given length in the databuffer
|
INDArray |
castTo(DataType dataType)
This method cast elements of this INDArray to new data type
|
protected void |
checkBufferCoherence()
Check that the length of indices and values are coherent and matches the rank of the matrix.
|
void |
close()
This method releases exclusive off-heap resources uses by this INDArray instance.
|
boolean |
closeable()
This method checks, if this INDArray instalce can use close() method
|
long |
countNNZ()
Count the number of value that are included in the ndarray (view) according to the sparse offsets and the shape
|
protected static DataBuffer |
createIndiceBuffer(int[][] indices,
long[] shape)
Create a DataBuffer for indices of given arrays of indices.
|
protected static DataBuffer |
createIndiceBuffer(long[][] indices,
long[] shape)
Create a DataBuffer for indices of given arrays of indices.
|
protected static DataBuffer |
createSparseInformationBuffer(int rank)
Create a SparseInfo databuffer given rank if of the sparse matrix.
|
protected static DataBuffer |
createValueBuffer(double[] values)
Create a DataBuffer for values of given array of values.
|
protected static DataBuffer |
createValueBuffer(float[] values)
Create a DataBuffer for values of given array of values.
|
DataBuffer |
data()
Returns a linear double array representation of this ndarray
|
int[] |
filterOutFixedDimensions(int[] flags,
List<Integer> idx) |
INDArray |
get(INDArrayIndex... indexes)
Returns a subset of this array based on the specified
indexes
|
double |
getDouble(int... indices)
Get a double value at the specified indices.
|
double |
getDouble(long... indices) |
double |
getDouble(long i)
Get the double value at the specified linear index in the array
|
double |
getDouble(long i,
long j)
Get the double value at the specified indices.
|
float |
getFloat(int[] indices)
Returns the elements at the specified indices
|
float |
getFloat(long i)
Return the item at the linear index i
|
float |
getFloat(long[] indices) |
float |
getFloat(long i,
long j)
Return the item at row i column j
Note that this is the same as calling getScalar(new int[]{i,j}
|
SparseFormat |
getFormat()
Return the sparse format (i.e COO, CSR, ...)
|
DataBuffer |
getIncludedIndices()
Return a copy of the indices included in the view.
|
DataBuffer |
getIncludedValues()
Return a copy of the values included in the array.
|
DataBuffer |
getIndices() |
DataBuffer |
getIndicesOf(int i)
Returns the indices of the element of the given index in the array context
|
int |
getInt(int... indices)
Get an integer value at the specified indices.
|
long |
getLong(long index) |
int |
getNumHiddenDimension() |
INDArray |
getScalar(int... indices)
Returns the elements at the specified indices
|
INDArray |
getScalar(long... indices) |
String |
getString(long index) |
DataBuffer |
getUnderlyingIndices()
Return the indices buffer
|
DataBuffer |
getUnderlyingIndicesOf(int i)
Returns the underlying indices of the element of the given index
such as there really are in the original ndarray
|
DataBuffer |
getUnderlyingValues()
Return the values buffer
|
DataBuffer |
getValues() |
DataBuffer |
getVectorCoordinates()
Returns the indices of non-zero element of the vector
|
int |
indexesBinarySearch(int lowerBound,
int upperBound,
int[] idx)
Return the position of the idx array into the indexes buffer between the lower and upper bound.
|
boolean |
isB()
This method checks if this INDArray instance has boolean type
|
boolean |
isDimensionFixed(int i)
Return if the dimension in argument is a fixed dimension.
|
boolean |
isEmpty()
This method returns true if this INDArray is special case: no-value INDArray
|
boolean |
isR()
This method checks if this INDArray instance is one of Real types
|
boolean |
isS()
This method checks if this INDArray instance has String type
|
boolean |
isSorted() |
boolean |
isView()
Returns true if this array is a view or not
|
boolean |
isZ()
This method checks if this INDArray instance is one of integer types
|
boolean |
isZero(int... indexes) |
INDArray |
mmul(INDArray other,
INDArray result,
MMulTranspose mMulTranspose)
Perform an copy matrix multiplication
|
INDArray |
mmul(INDArray other,
MMulTranspose mMulTranspose) |
INDArray |
mmuli(INDArray other,
INDArray result,
MMulTranspose transpose) |
INDArray |
mmuli(INDArray other,
MMulTranspose transpose) |
boolean |
none()
This method checks if any of the elements within this array are non-zero (or true, in case of boolean)
|
INDArray |
put(INDArrayIndex[] indices,
INDArray element)
Put the elements of the ndarray
in to the specified indices
|
INDArray |
put(INDArrayIndex[] indices,
Number element)
Put the elements of the ndarray
in to the specified indices
|
INDArray |
put(int[] indexes,
INDArray element)
Inserts the element at the specified index
|
INDArray |
put(int i,
INDArray element)
Inserts the element at the specified index
|
INDArray |
put(int i,
int j,
INDArray element)
Inserts the element at the specified index
|
INDArray |
put(int i,
int j,
Number element)
Inserts the element at the specified index
|
INDArray |
putColumn(int column,
INDArray toPut)
Insert a column in to this array
Will throw an exception if this
ndarray is not a matrix
|
INDArray |
putiColumnVector(INDArray columnVector)
In place assignment of a column vector
|
INDArray |
putiRowVector(INDArray rowVector)
in place assignment of row vector, to each row of this array
|
INDArray |
putRow(long row,
INDArray toPut)
Insert a row in to this array
Will throw an exception if this
ndarray is not a matrix
|
INDArray |
putScalar(int[] indexes,
double value)
Insert the item at the specified indices
|
INDArray |
putScalar(long[] indexes,
double value) |
INDArray |
putScalar(long[] i,
float value) |
INDArray |
putScalar(long[] i,
int value) |
INDArray |
putScalar(long i,
double value)
Insert the number linearly in to the ndarray
|
INDArray |
putScalar(long i,
float value)
Insert a scalar float at the specified index
|
INDArray |
putScalar(long i,
int value)
Insert a scalar int at the specified index
|
INDArray |
putScalar(long row,
long col,
double value)
Insert the value at the specified indices, in a 2d (rank 2) NDArray
Equivalent to INDArray.putScalar(int[], double) but avoids int[] creation |
INDArray |
putScalar(long dim0,
long dim1,
long dim2,
double value)
Insert the value at the specified indices, in a 3d (rank 3) NDArray
Equivalent to INDArray.putScalar(int[], double) but avoids int[] creation |
INDArray |
putScalar(long dim0,
long dim1,
long dim2,
long dim3,
double value)
Insert the value at the specified indices, in a 4d (rank 4) NDArray
Equivalent to INDArray.putScalar(int[], double) but avoids int[] creation |
INDArray |
removeEntry(int idx)
Remove an element of the ndarray
|
INDArray |
repeat(int dimension,
long... repeats)
Repeat elements along a specified dimension.
|
INDArray |
reshape(char order,
boolean enforceView,
long... newShape)
Reshapes the ndarray (note: it's not possible to change the length of the ndarray).
|
INDArray |
reshape(char order,
int... newShape)
Reshapes the ndarray (can't change the length of the ndarray).
|
INDArray |
reshape(int[] shape) |
int |
reverseIndexes(int... indexes)
Return the index of the value corresponding to the indexes
|
void |
setShape(long... shape)
Shape setter
|
void |
setStride(long... stride)
stride setter
|
LongShapeDescriptor |
shapeDescriptor()
Returns shape descriptor of this ndarray
|
DataBuffer |
shapeInfoDataBuffer()
Shape info
|
DataBuffer |
shiftLeft(DataBuffer buffer,
int from,
int offset,
long datalength) |
void |
sort()
Sort the indexes and the values buffers
|
INDArray |
subArray(long[] offsets,
int[] shape,
int[] stride) |
INDArray |
toDense()
Converts the sparse ndarray into a dense one
|
int |
toFlatArray(com.google.flatbuffers.FlatBufferBuilder builder)
Add an
INDArray
to flatbuffers builder |
int[] |
translateToPhysical(int[] virtualIndexes) |
long[] |
translateToPhysical(long[] virtualIndexes)
Translate the view index to the corresponding index of the original ndarray
|
int |
underlyingRank() |
add, add, add, add, addColumnVector, addi, addi, addi, addi, addiColumnVector, addiRowVector, addRowVector, amax, amaxNumber, amean, ameanNumber, amin, aminNumber, argMax, assign, assignIf, broadcast, broadcast, clone, columns, cond, cumsum, cumsumi, dataType, detach, dimShuffle, dimShuffle, distance1, distance2, div, div, div, div, divColumnVector, divi, divi, divi, divi, diviColumnVector, diviRowVector, divRowVector, dup, dup, element, elementWiseStride, entropy, entropyNumber, eps, eps, eq, eq, equals, equalShapes, equalsWithEps, flags, fmod, fmod, fmod, fmod, fmodi, fmodi, get, get, getColumn, getColumn, getColumns, getDoubleUnsafe, getLeadingOnes, getLong, getNumber, getNumber, getPercentile, getRow, getRow, getRows, getScalar, getScalar, getTrailingOnes, getWhere, getWhere, gt, gt, gte, hiddenDimensions, init, isAttached, isColumnVector, isColumnVectorOrScalar, isCompressed, isInfinite, isInScope, isMatrix, isNaN, isRowVector, isRowVectorOrScalar, isScalar, isSparse, isSquare, isVector, isVectorOrScalar, javaTensorAlongDimension, length, lengthLong, leverage, leverageOrDetach, leverageTo, leverageTo, like, linearIndex, logEntropy, logEntropyNumber, lt, lt, lte, markAsCompressed, match, match, max, maxNumber, mean, mean, meanNumber, median, medianNumber, migrate, migrate, min, minNumber, mmul, mmul, mmuli, mmuli, mul, mul, mul, mul, mulColumnVector, muli, muli, muli, muli, muliColumnVector, muliRowVector, mulRowVector, neg, negi, neq, neq, nnz, norm1, norm1Number, norm2, norm2Number, normmax, normmaxNumber, offset, ordering, originalOffset, percentile, percentileNumber, permute, permutei, prod, prodNumber, put, putScalar, putScalar, putScalarUnsafe, putSlice, putWhere, putWhere, putWhere, putWhereWithMask, putWhereWithMask, rank, ravel, ravel, rdiv, rdiv, rdiv, rdiv, rdivColumnVector, rdivi, rdivi, rdivi, rdivi, rdiviColumnVector, rdiviRowVector, rdivRowVector, reallocate, remainder, remainder, remainder, remainder, remainderi, remainderi, replaceWhere, repmat, reshape, reshape, reshape, reshape, rows, rsub, rsub, rsub, rsub, rsubColumnVector, rsubi, rsubi, rsubi, rsubi, rsubiColumnVector, rsubiRowVector, rsubRowVector, scan, setData, setOrder, setShapeAndStride, setShapeInformation, shannonEntropy, shannonEntropyNumber, shape, shapeInfo, shapeInfoJava, shapeInfoToString, shapeOf, size, slice, slice, slices, sliceVectors, sparseInfoDataBuffer, sparseOffsets, squaredDistance, std, std, stdNumber, stdNumber, stride, stride, strideOf, sub, sub, sub, sub, subColumnVector, subi, subi, subi, subi, subiColumnVector, subiRowVector, subRowVector, sum, sum, sum, sumNumber, swapAxes, tensorAlongDimension, tensorsAlongDimension, toDoubleMatrix, toDoubleVector, toFloatMatrix, toFloatVector, toIntMatrix, toIntVector, toLongMatrix, toLongVector, transpose, transposei, ulike, unsafeDuplication, unsafeDuplication, var, var, varNumber, vectorAlongDimension, vectorsAlongDimension
protected static final SparseFormat format
protected transient volatile DataBuffer values
protected transient volatile DataBuffer indices
protected transient volatile boolean isSorted
public BaseSparseNDArrayCOO(DataBuffer values, DataBuffer indices, long[] shape)
public BaseSparseNDArrayCOO(double[] values, long[][] indices, long[] shape)
public BaseSparseNDArrayCOO(float[] values, long[][] indices, long[] shape)
public BaseSparseNDArrayCOO(double[] values, int[][] indices, long[] shape)
public BaseSparseNDArrayCOO(float[] values, int[][] indices, long[] shape)
public BaseSparseNDArrayCOO(DataBuffer values, DataBuffer indices, DataBuffer sparseInformation, long[] shape)
public BaseSparseNDArrayCOO(DataBuffer values, DataBuffer indices, long[] sparseOffsets, int[] flags, int[] hiddenDimensions, int underlyingRank, long[] shape)
protected void checkBufferCoherence()
protected static DataBuffer createSparseInformationBuffer(int rank)
rank
- protected static DataBuffer createValueBuffer(float[] values)
values
- protected static DataBuffer createValueBuffer(double[] values)
values
- protected static DataBuffer createIndiceBuffer(long[][] indices, long[] shape)
indices
- shape
- protected static DataBuffer createIndiceBuffer(int[][] indices, long[] shape)
indices
- shape
- public int toFlatArray(com.google.flatbuffers.FlatBufferBuilder builder)
INDArray
INDArray
to flatbuffers builderbuilder
- the builder to usepublic long countNNZ()
public INDArray assign(INDArray arr)
INDArray
assign
in interface INDArray
assign
in class BaseSparseNDArray
arr
- the elements to assignpublic void sort()
public long[] translateToPhysical(long[] virtualIndexes)
virtualIndexes
- the view indexespublic int[] translateToPhysical(int[] virtualIndexes)
public boolean isDimensionFixed(int i)
public INDArray putScalar(long i, double value)
INDArray
putScalar
in interface INDArray
putScalar
in class BaseSparseNDArray
i
- the index to insert intovalue
- the value to insertpublic INDArray putScalar(long i, float value)
INDArray
putScalar
in interface INDArray
putScalar
in class BaseSparseNDArray
i
- The index to insert intovalue
- Value to insertpublic INDArray putScalar(long i, int value)
INDArray
putScalar
in interface INDArray
putScalar
in class BaseSparseNDArray
i
- The index to insert intovalue
- Value to insertpublic INDArray putScalar(int[] indexes, double value)
INDArray
putScalar
in interface INDArray
putScalar
in class BaseSparseNDArray
indexes
- the indices to insert atvalue
- the number to insertpublic INDArray putScalar(long[] indexes, double value)
putScalar
in interface INDArray
putScalar
in class BaseSparseNDArray
public INDArray putScalar(long[] i, float value)
putScalar
in interface INDArray
putScalar
in class BaseSparseNDArray
public INDArray putScalar(long[] i, int value)
putScalar
in interface INDArray
putScalar
in class BaseSparseNDArray
public INDArray putScalar(long row, long col, double value)
INDArray
INDArray.putScalar(int[], double)
but avoids int[] creationputScalar
in interface INDArray
putScalar
in class BaseSparseNDArray
row
- Row (dimension 0) indexcol
- Column (dimension 1) indexvalue
- Value to putpublic INDArray putScalar(long dim0, long dim1, long dim2, double value)
INDArray
INDArray.putScalar(int[], double)
but avoids int[] creationputScalar
in interface INDArray
putScalar
in class BaseSparseNDArray
dim0
- Dimension 0 indexdim1
- Dimension 1 indexdim2
- Dimension 2 indexvalue
- Value to putpublic INDArray putScalar(long dim0, long dim1, long dim2, long dim3, double value)
INDArray
INDArray.putScalar(int[], double)
but avoids int[] creationputScalar
in interface INDArray
putScalar
in class BaseSparseNDArray
dim0
- Dimension 0 indexdim1
- Dimension 1 indexdim2
- Dimension 2 indexdim3
- Dimension 3 indexvalue
- Value to putpublic INDArray putRow(long row, INDArray toPut)
INDArray
putRow
in interface INDArray
putRow
in class BaseSparseNDArray
row
- the row insert intotoPut
- the row to insertpublic INDArray putColumn(int column, INDArray toPut)
INDArray
putColumn
in interface INDArray
putColumn
in class BaseSparseNDArray
column
- the column to inserttoPut
- the array to putpublic INDArray put(INDArrayIndex[] indices, INDArray element)
INDArray
put
in interface INDArray
put
in class BaseSparseNDArray
indices
- the indices to put the ndarray in toelement
- the ndarray to putpublic INDArray put(INDArrayIndex[] indices, Number element)
INDArray
put
in interface INDArray
put
in class BaseSparseNDArray
indices
- the indices to put the ndarray in toelement
- the ndarray to putpublic INDArray put(int[] indexes, INDArray element)
INDArray
put
in interface INDArray
put
in class BaseSparseNDArray
indexes
- the indices to insert intoelement
- a scalar ndarraypublic INDArray put(int i, int j, INDArray element)
INDArray
put
in interface INDArray
put
in class BaseSparseNDArray
i
- the row insert intoj
- the column to insert intoelement
- a scalar ndarraypublic INDArray put(int i, int j, Number element)
INDArray
put
in interface INDArray
put
in class BaseSparseNDArray
i
- the row insert intoj
- the column to insert intoelement
- a scalar ndarraypublic INDArray put(int i, INDArray element)
INDArray
put
in interface INDArray
put
in class BaseSparseNDArray
i
- the index insert intoelement
- a scalar ndarraypublic void addOrUpdate(long[] indexes, double value)
indexes
- the indexes of the element to be addedvalue
- the value of the element to be addedpublic boolean canInsert(DataBuffer buffer, int length)
buffer
- a databuffer in which we want to add datalength
- the length of the datapublic DataBuffer shiftLeft(DataBuffer buffer, int from, int offset, long datalength)
public INDArray removeEntry(int idx)
idx
- the index of the element to be removedpublic INDArray get(INDArrayIndex... indexes)
get
in interface INDArray
get
in class BaseSparseNDArray
indexes
- the indexes in to the arraypublic INDArray repeat(int dimension, long... repeats)
INDArray
dimension
- the dimension to repeatrepeats
- the number of elements to repeat on each elementpublic int reverseIndexes(int... indexes)
indexes
- public int indexesBinarySearch(int lowerBound, int upperBound, int[] idx)
idx
- a set of coordinateslowerBound
- the lower bound of the positionupperBound
- the upper bound of the positionpublic INDArray getScalar(int... indices)
INDArray
getScalar
in interface INDArray
getScalar
in class BaseSparseNDArray
indices
- the indices to getScalarpublic INDArray getScalar(long... indices)
getScalar
in interface INDArray
getScalar
in class BaseSparseNDArray
public int getInt(int... indices)
INDArray
getInt
in interface INDArray
getInt
in class BaseSparseNDArray
indices
- Indices to get the integer at. Number of indices must match the array rank.public long getLong(long index)
public double getDouble(int... indices)
INDArray
getDouble
in interface INDArray
getDouble
in class BaseSparseNDArray
indices
- Indices to get the double at. Number of indices must match the array rank.public double getDouble(long... indices)
getDouble
in interface INDArray
getDouble
in class BaseSparseNDArray
public float getFloat(int[] indices)
INDArray
getFloat
in interface INDArray
getFloat
in class BaseSparseNDArray
indices
- the indices to getScalarpublic float getFloat(long[] indices)
getFloat
in interface INDArray
getFloat
in class BaseSparseNDArray
public double getDouble(long i)
INDArray
getDouble
in interface INDArray
getDouble
in class BaseSparseNDArray
i
- Indexpublic double getDouble(long i, long j)
INDArray
getDouble
in interface INDArray
getDouble
in class BaseSparseNDArray
i
- Dimension 0 (row) indexj
- Dimension 1 (column) indexpublic float getFloat(long i)
INDArray
getFloat
in interface INDArray
getFloat
in class BaseSparseNDArray
i
- the index of the item to getScalarpublic float getFloat(long i, long j)
INDArray
getFloat
in interface INDArray
getFloat
in class BaseSparseNDArray
i
- the row to getScalarj
- the column to getScalarpublic INDArray reshape(char order, int... newShape)
INDArray
newShape
- the new shape of the ndarraypublic INDArray reshape(char order, boolean enforceView, long... newShape)
INDArray
newShape
- the new shape of the ndarraypublic INDArray reshape(int[] shape)
public LongShapeDescriptor shapeDescriptor()
INDArray
public SparseFormat getFormat()
ISparseNDArray
SparseFormat
public int underlyingRank()
public DataBuffer data()
INDArray
public DataBuffer getUnderlyingIndices()
public DataBuffer getIncludedIndices()
public DataBuffer getUnderlyingValues()
public DataBuffer getIncludedValues()
public DataBuffer getVectorCoordinates()
public INDArray toDense()
toDense
in interface INDArray
toDense
in interface ISparseNDArray
toDense
in class BaseSparseNDArray
public DataBuffer shapeInfoDataBuffer()
INDArray
shapeInfoDataBuffer
in interface INDArray
shapeInfoDataBuffer
in class BaseSparseNDArray
public INDArray subArray(long[] offsets, int[] shape, int[] stride)
subArray
in interface INDArray
subArray
in class BaseSparseNDArray
public DataBuffer getUnderlyingIndicesOf(int i)
i
- the index of the element+public DataBuffer getIndicesOf(int i)
i
- the index of the elementpublic boolean isZero(int... indexes)
public boolean isView()
INDArray
public String getString(long index)
public int getNumHiddenDimension()
public boolean isSorted()
public DataBuffer getValues()
public DataBuffer getIndices()
public INDArray putiColumnVector(INDArray columnVector)
INDArray
columnVector
- the column vector to addpublic INDArray putiRowVector(INDArray rowVector)
INDArray
rowVector
- Row vector to putpublic INDArray mmul(INDArray other, MMulTranspose mMulTranspose)
public INDArray mmul(INDArray other, INDArray result, MMulTranspose mMulTranspose)
other
- the other matrix to perform matrix multiply withresult
- the result ndarraymMulTranspose
- the transpose status of each arraypublic INDArray mmuli(INDArray other, MMulTranspose transpose)
public INDArray mmuli(INDArray other, INDArray result, MMulTranspose transpose)
public void setStride(long... stride)
INDArray
setStride
in interface INDArray
setStride
in class BaseSparseNDArray
public void setShape(long... shape)
INDArray
setShape
in interface INDArray
setShape
in class BaseSparseNDArray
public boolean isEmpty()
public boolean isR()
INDArray
public boolean isZ()
INDArray
public boolean isB()
INDArray
public INDArray castTo(DataType dataType)
INDArray
public boolean all()
INDArray
all
in interface INDArray
all
in class BaseSparseNDArray
public boolean any()
INDArray
any
in interface INDArray
any
in class BaseSparseNDArray
public boolean none()
INDArray
none
in interface INDArray
none
in class BaseSparseNDArray
public boolean closeable()
INDArray
public void close()
INDArray
public boolean isS()
INDArray
Copyright © 2019. All rights reserved.