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
|
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
|
protected void |
checkBufferCoherence()
Check that the length of indices and values are coherent and matches the rank of the matrix.
|
INDArray |
convertToDoubles() |
INDArray |
convertToFloats() |
INDArray |
convertToHalfs() |
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 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.
|
int |
getNumHiddenDimension() |
INDArray |
getScalar(int... indices)
Returns the elements at the the specified indices
|
INDArray |
getScalar(long... indices) |
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 |
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 |
isSorted() |
boolean |
isView()
Returns true if this array is a view or not
|
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) |
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) |
INDArray |
reshape(char order,
int... newShape) |
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
|
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 |
subArray(ShapeOffsetResolution resolution)
Sub array based on the
pre calculated shape,strides, offsets
|
INDArray |
subArray(ShapeOffsetResolution resolution,
ShapeOffsetResolution resolutionWithoutNewAxis) |
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, checkDimensions, cleanup, clone, columns, cond, condi, cumsum, cumsumi, dataType, detach, dimShuffle, dimShuffle, distance1, distance2, div, div, div, div, divColumnVector, divi, divi, divi, divi, diviColumnVector, diviRowVector, divRowVector, dup, dup, element, elementStride, elementWiseStride, entropy, entropyNumber, eps, eps, epsi, epsi, eq, eq, eqi, eqi, equals, equalShapes, equalsWithEps, flags, fmod, fmod, fmod, fmod, fmodi, fmodi, get, get, getColumn, getColumns, getDoubleUnsafe, getLeadingOnes, getPercentile, getRow, getRows, getScalar, getScalar, getTrailingOnes, getWhere, getWhere, gt, gt, gte, gtei, gti, gti, hiddenDimensions, index, init, innerMostStride, isAttached, isCleanedUp, isColumnVector, isColumnVectorOrScalar, isCompressed, isInScope, isMatrix, isRowVector, isRowVectorOrScalar, isScalar, isSparse, isSquare, isVector, isVectorOrScalar, isWrapAround, javaTensorAlongDimension, length, lengthLong, leverage, leverageOrDetach, leverageTo, leverageTo, linearIndex, linearView, linearViewColumnOrder, logEntropy, logEntropyNumber, lt, lt, lte, ltei, lti, lti, majorStride, 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, neqi, neqi, nnz, norm1, norm1Number, norm2, norm2Number, normmax, normmaxNumber, offset, ordering, originalOffset, percentile, percentileNumber, permute, permutei, prod, prodNumber, put, 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, repeat, replaceWhere, repmat, resetLinearView, reshape, reshape, reshape, reshape, rows, rsub, rsub, rsub, rsub, rsubColumnVector, rsubi, rsubi, rsubi, rsubi, rsubiColumnVector, rsubiRowVector, rsubRowVector, scan, secondaryStride, setData, setOrder, setShapeAndStride, setShapeInformation, setWrapAround, 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, sumNumber, swapAxes, tensorAlongDimension, tensorssAlongDimension, toDoubleMatrix, toDoubleVector, toFloatMatrix, toFloatVector, toIntMatrix, toIntVector, toLongMatrix, toLongVector, transpose, transposei, 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 INDArray convertToHalfs()
public 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)
public 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 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)
public INDArray reshape(int[] shape)
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(ShapeOffsetResolution resolution)
INDArray
subArray
in interface INDArray
subArray
in class BaseSparseNDArray
resolution
- the resolution to usepublic INDArray subArray(ShapeOffsetResolution resolution, ShapeOffsetResolution resolutionWithoutNewAxis)
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 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 INDArray convertToFloats()
public INDArray convertToDoubles()
public boolean isEmpty()
Copyright © 2018. All rights reserved.