Package org.nd4j.linalg.api.ndarray
Class BaseNDArray
- java.lang.Object
-
- org.nd4j.linalg.api.ndarray.BaseNDArray
-
- All Implemented Interfaces:
Serializable
,AutoCloseable
,Iterable
,INDArray
public abstract class BaseNDArray extends Object implements INDArray, Iterable
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected long
arrayId
protected boolean
closeable
protected boolean
compressed
protected DataBuffer
data
protected JvmShapeInfo
jvmShapeInfo
protected boolean
released
protected DataBuffer
shapeInformation
-
Constructor Summary
Constructors Constructor Description BaseNDArray()
BaseNDArray(double[][] data)
Initialize the ndarray as a matrix with the given data (indices preserved)BaseNDArray(double[][] data, char ordering)
BaseNDArray(double[] data, int[] shape, char ordering)
BaseNDArray(double[] data, int[] shape, int[] stride, long offset)
BaseNDArray(double[] data, int[] shape, int[] stride, long offset, char ordering)
BaseNDArray(double[] data, long[] shape, char ordering)
BaseNDArray(double[] data, long[] shape, long[] stride, long offset)
BaseNDArray(double[] data, long[] shape, long[] stride, long offset, char ordering)
BaseNDArray(double[] data, long[] shape, long offset, char ordering)
BaseNDArray(float[] data)
BaseNDArray(float[][] data)
Initialize the ndarray with the given dataBaseNDArray(float[][] data, char ordering)
BaseNDArray(float[] data, char order)
BaseNDArray(float[] data, int[] shape)
Create this ndarray with the given data and shape and 0 offsetBaseNDArray(float[] data, int[] shape, char ordering)
Create this ndarray with the given data and shape and 0 offsetBaseNDArray(float[] data, int[] shape, int[] stride)
BaseNDArray(float[] data, int[] shape, int[] stride, char ordering)
BaseNDArray(float[] data, int[] shape, int[] stride, long offset)
BaseNDArray(float[] data, int[] shape, int[] stride, long offset, char ordering)
BaseNDArray(float[] data, int[] shape, long offset)
BaseNDArray(float[] data, int[] shape, long offset, char ordering)
BaseNDArray(float[] data, long[] shape, char ordering)
BaseNDArray(float[] data, long[] shape, long[] stride, long offset)
BaseNDArray(float[] data, long[] shape, long[] stride, long offset, char ordering)
BaseNDArray(float[] data, long[] shape, long offset, char ordering)
BaseNDArray(int[] shape)
Create an ndarray with the given shapeBaseNDArray(int[] shape, char ordering)
BaseNDArray(int[] shape, int[] stride)
Create the ndarray with the specified shape and stride and an offset of 0BaseNDArray(int[] shape, int[] stride, char ordering)
Create the ndarray with the specified shape and stride and an offset of 0BaseNDArray(int[] data, int[] shape, int[] strides)
BaseNDArray(int[] shape, int[] stride, long offset)
Construct an ndarray of the specified shape with an empty data arrayBaseNDArray(int[] shape, int[] stride, long offset, char ordering)
Construct an ndarray of the specified shape with an empty data arrayBaseNDArray(int[] shape, int[] stride, long offset, char ordering, boolean initialize)
Construct an ndarray of the specified shape.BaseNDArray(int[] shape, long offset)
BaseNDArray(int[] shape, long offset, char ordering)
BaseNDArray(int[] shape, DataBuffer buffer)
Create with the specified shape and bufferBaseNDArray(int newRows, int newColumns)
Creates a new n times m DoubleMatrix.BaseNDArray(int newRows, int newColumns, char ordering)
Creates a new n times m DoubleMatrix.BaseNDArray(long[] shape)
BaseNDArray(long[] shape, long[] stride, long offset)
BaseNDArray(long[] shape, long[] stride, long offset, char ordering)
BaseNDArray(long[] shape, long[] stride, long offset, char ordering, boolean initialize)
BaseNDArray(long[] shape, long offset, char ordering)
BaseNDArray(long newRows, long newColumns)
BaseNDArray(long newRows, long newColumns, char ordering)
BaseNDArray(List<INDArray> slices, int[] shape)
Create an ndarray from the specified slices.BaseNDArray(List<INDArray> slices, int[] shape, char ordering)
Create an ndarray from the specified slices.BaseNDArray(List<INDArray> slices, int[] shape, int[] stride)
Create an ndarray from the specified slices.BaseNDArray(List<INDArray> slices, int[] shape, int[] stride, char ordering)
Create an ndarray from the specified slices.BaseNDArray(List<INDArray> slices, long[] shape)
BaseNDArray(List<INDArray> slices, long[] shape, char ordering)
BaseNDArray(List<INDArray> slices, long[] shape, long[] stride)
BaseNDArray(List<INDArray> slices, long[] shape, long[] stride, char ordering)
BaseNDArray(DataBuffer buffer)
BaseNDArray(DataBuffer floatBuffer, char order)
BaseNDArray(DataBuffer data, int[] shape)
BaseNDArray(DataBuffer buffer, int[] shape, char ordering)
BaseNDArray(DataBuffer buffer, int[] shape, int[] strides)
BaseNDArray(DataBuffer data, int[] shape, int[] stride, long offset)
BaseNDArray(DataBuffer buffer, int[] shape, int[] stride, long offset, char ordering)
BaseNDArray(DataBuffer buffer, int[] shape, long offset)
BaseNDArray(DataBuffer buffer, int[] shape, long offset, char ordering)
Constructor for stride and offsetBaseNDArray(DataBuffer data, long[] shape)
BaseNDArray(DataBuffer buffer, long[] shape, char ordering)
BaseNDArray(DataBuffer buffer, long[] shape, long[] stride, char ordering, DataType type)
BaseNDArray(DataBuffer buffer, long[] shape, long[] stride, char ordering, DataType type, MemoryWorkspace workspace)
BaseNDArray(DataBuffer buffer, long[] shape, long[] stride, long offset, char ordering)
BaseNDArray(DataBuffer buffer, long[] shape, long[] stride, long offset, char ordering, DataType dataType)
BaseNDArray(DataBuffer buffer, long[] shape, long[] stride, long offset, long ews, char ordering)
BaseNDArray(DataBuffer buffer, long[] shape, long[] stride, long offset, long ews, char ordering, DataType dataType)
BaseNDArray(DataBuffer buffer, DataType dataType, long[] shape, long[] stride, long offset, char ordering)
BaseNDArray(DataType type, long[] shape, long[] paddings, long[] paddingOffsets, char ordering, MemoryWorkspace workspace)
BaseNDArray(DataType type, long[] shape, long[] stride, long offset, char ordering, boolean initialize)
BaseNDArray(DataType type, long[] shape, long[] stride, long offset, char ordering, boolean initialize, MemoryWorkspace workspace)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description INDArray
add(Number n)
Scalar addition (cloning)INDArray
add(Number n, INDArray result)
Addition of this ndarray.INDArray
add(INDArray other)
Element-wise copy addition of two NDArraysINDArray
add(INDArray other, INDArray result)
Element-wise copy addition of two NDArraysINDArray
addColumnVector(INDArray columnVector)
Addition of a column vector (copy)INDArray
addi(Number n)
In place scalar additionINDArray
addi(Number n, INDArray result)
In place additionINDArray
addi(INDArray other)
in place (element wise) addition of two NDArraysINDArray
addi(INDArray other, INDArray result)
in place (element wise) addition of two NDArraysINDArray
addiColumnVector(INDArray columnVector)
In place addition of a column vectorINDArray
addiRowVector(INDArray rowVector)
In place addition of a row vectorINDArray
addRowVector(INDArray rowVector)
Addition of a row vector (copy)boolean
all()
This method checks if all elements within this array are non-zero (or true, in case of boolean)INDArray
amax(int... dimension)
Returns the absolute overall max of this ndarray along given dimensionsNumber
amaxNumber()
Returns maximum (absolute) value in this INDArrayINDArray
amean(int... dimension)
Returns the absolute overall mean of this ndarrayNumber
ameanNumber()
Returns the absolute overall mean of this ndarrayINDArray
amin(int... dimension)
Returns minimum (absolute) value in this INDArray, along the specified dimensionsNumber
aminNumber()
Returns absolute min value in this INDArrayboolean
any()
This method checks if any of the elements within this array are non-zero (or true, in case of boolean)INDArray
argMax(int... dimension)
This method returns index of highest value along specified dimension(s)protected void
assertSlice(INDArray put, long slice)
INDArray
assign(boolean value)
Set all entries of the ndarray to the specified valueINDArray
assign(Number value)
Set all entries of the ndarray to the specified valueINDArray
assign(INDArray arr)
Assign all of the elements in the given ndarray to this ndarrayINDArray
assignIf(INDArray arr, Condition condition)
Assign all elements from given ndarray that are matching given condition, ndarray to this ndarrayvoid
assignNewId()
protected void
autoProcessScalarCall()
INDArray
broadcast(long... shape)
Broadcasts this ndarray to be the specified shapeINDArray
broadcast(INDArray result)
Broadcasts this ndarray to be the specified shapeINDArray
castTo(DataType dataType)
This method cast elements of this INDArray to new data typeprotected void
checkArrangeArray(int[] arr)
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() methodint
columns()
Returns the number of columns in this matrix (throws exception if not 2d)INDArray
cond(Condition condition)
Returns a binary INDArray with value 'true' if the element matches the specified condition and 'false' otherwiseprotected static DataTypeEx
convertType(DataType type)
protected INDArray
create(int[] shape)
protected INDArray
create(int[] shape, char ordering)
protected INDArray
create(int[] shape, int[] strides, long offset)
protected INDArray
create(int rows, int length)
protected INDArray
create(DataBuffer buffer)
protected INDArray
create(DataBuffer data, int[] shape, int[] strides)
protected INDArray
create(DataBuffer data, int[] newShape, int[] newStrides, long offset)
protected INDArray
create(DataBuffer data, int[] newShape, int[] newStrides, long offset, char ordering)
protected INDArray
create(DataBuffer data, int[] shape, long offset)
protected INDArray
create(DataBuffer data, long[] newShape, long[] newStrides, long offset, char ordering)
protected INDArray
createScalar(double d)
protected INDArray
createScalarForIndex(long i, boolean applyOffset)
INDArray
cumsum(int dimension)
Returns the cumulative sum along a dimension.INDArray
cumsumi(int dimension)
Returns the cumulative sum along a dimension.DataBuffer
data()
Returns a linear double array representation of this ndarrayDataType
dataType()
This method returns dtype for this INDArrayINDArray
detach()
This method detaches INDArray from Workspace, returning copy.INDArray
dimShuffle(Object[] rearrange, int[] newOrder, boolean[] broadCastable)
Deprecated.INDArray
dimShuffle(Object[] rearrange, long[] newOrder, boolean[] broadCastable)
Dimshuffle: an extension of permute that adds the ability to broadcast various dimensions.double
distance1(INDArray other)
Returns the (1-norm) distance.double
distance2(INDArray other)
Returns the (euclidean) distance.INDArray
div(Number n)
Division by a numberINDArray
div(Number n, INDArray result)
Division if ndarray by numberINDArray
div(INDArray other)
Copy (element wise) division of two NDArraysINDArray
div(INDArray other, INDArray result)
copy (element wise) division of two NDArraysINDArray
divColumnVector(INDArray columnVector)
Division of a column vector (copy)INDArray
divi(Number n)
In place scalar divisionINDArray
divi(Number n, INDArray result)
In place division of this ndarrayINDArray
divi(INDArray other)
in place (element wise) division of two NDArraysINDArray
divi(INDArray other, INDArray result)
in place (element wise) division of two NDArraysINDArray
diviColumnVector(INDArray columnVector)
In place division of a column vectorINDArray
diviRowVector(INDArray rowVector)
In place division of a row vectorINDArray
divRowVector(INDArray rowVector)
Division of a row vector (copy)protected INDArray
doColumnWise(INDArray columnVector, char operation)
Do a row wise op (a,s,m,d) a : add s : subtract m : multiply d : divide h : reverse subtraction t : reverse divisionprotected long[]
doPermuteSwap(long[] shape, int[] rearrange)
protected int[]
doPermuteSwap(IntBuffer shape, int[] rearrange)
Deprecated.protected long[]
doPermuteSwap(LongBuffer shape, int[] rearrange)
Deprecated.protected int[]
doPermuteSwap(DataBuffer shape, int[] rearrange)
Deprecated.protected INDArray
doRowWise(INDArray rowVector, char operation)
Do a row wise op (a,s,m,d) a : add s : subtract m : multiply d : divide h : reverse subtraction t : reverse divisionINDArray
dup()
Returns a copy of this ndarrayINDArray
dup(char order)
Returns a copy of this ndarray, where the returned ndarray has the specified orderObject
element()
Returns a scalar (individual element) of a scalar ndarrayint
elementWiseStride()
Element wise strideINDArray
entropy(int... dimension)
Returns entropy value for this INDArray along specified dimension(s)Number
entropyNumber()
Returns entropy value for this INDArrayINDArray
eps(Number other)
Returns the binary ndarray for "Epsilon equals" comparison.INDArray
eps(INDArray other)
Returns the binary ndarray for "Epsilon equals" comparison.INDArray
eq(Number other)
Returns the binary ndarray for "Equals" comparison.INDArray
eq(INDArray other)
Returns the binary ndarray for "Equals" comparison.boolean
equals(Object o)
Compare two matrices.boolean
equalShapes(@NonNull INDArray other)
This method checks 2 INDArrays for equal shapes.
Shapes are considered equal if:
(a) Both arrays have equal rank, and
(b) size(0)...size(rank()-1) are equal for both arraysboolean
equalsWithEps(Object o, double eps)
This method checks 2 INDArrays equality with given epsINDArray
fmod(Number denominator)
remainder of division by scalar.INDArray
fmod(Number denominator, INDArray result)
remainder of division by scalar.INDArray
fmod(INDArray denominator)
remainder of divisionINDArray
fmod(INDArray denominator, INDArray result)
remainder of divisionINDArray
fmodi(Number denominator)
In place fmodINDArray
fmodi(INDArray denominator)
In place fmodINDArray
get(INDArray indices)
Get the elements from this ndarray based on the specified indicesINDArray
get(INDArrayIndex... indexes)
Returns a subset of this array based on the specified indexesINDArray
getColumn(long c)
Returns the specified column.INDArray
getColumn(long c, boolean keepDim)
Returns the specified column.INDArray
getColumns(int... cindices)
Get an INDArray comprised of the specified columns only.double
getDouble(int... indices)
Get a double value at the specified indices.double
getDouble(long i)
Get the double value at the specified linear index in the arraydouble
getDouble(long... indices)
double
getDouble(long i, long j)
Get the double value at the specified indices.double
getDoubleUnsafe(long offset)
Get a double at the given linear offset unsafe, without checks.float
getFloat(int... indices)
Returns the elements at the specified indicesfloat
getFloat(long i)
Return the item at the linear index ifloat
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}long
getId()
A unique ID for the INDArray object instance.int
getInt(int... indices)
Get an integer value at the specified indices.int
getLeadingOnes()
Get the number of leading ones in the array shape.long
getLong(long index)
Get a long value at the specified index.long
getLong(long... indices)
Get a long value at the specified indices.Number
getNumber(long i)
Get the numeric value at the specified index.Number
getNumber(long... idx)
Get a numeric value at the specified indices.protected double
getPercentile(Number quantile, INDArray sorted)
INDArray
getRow(long r)
Returns the specified row as a 1D vector.INDArray
getRow(long r, boolean keepDim)
Returns the specified row.INDArray
getRows(int[] rindices)
Get an INDArray comprised of the specified rows only.INDArray
getScalar(int[] indexes)
Returns the elements at the specified indicesINDArray
getScalar(long i)
Returns the element at the specified indexINDArray
getScalar(long... indexes)
INDArray
getScalar(long row, long column)
Returns the element at the specified row/columnprotected int[]
getStrides(int[] shape, char ordering)
int
getTrailingOnes()
Get the number of trailing ones in the array shape.INDArray
getWhere(Number comp, Condition condition)
Boolean indexing: Return the element if it fulfills the condition in result arrayINDArray
getWhere(INDArray comp, Condition condition)
Boolean indexing: Return the element if it fulfills the condition in result arrayINDArray
gt(Number other)
Returns the binary ndarray for "Greater" comparison.INDArray
gt(INDArray other)
Returns the binary ndarray for "Greater Than" comparison.INDArray
gte(Number other)
Returns binary ndarray for "Greter or equals" comparison.int
hashCode()
protected void
init(int[] shape, int[] stride)
protected void
init(long[] shape, long[] stride)
protected static DataBuffer
internalCreateBuffer(double[] data)
protected static DataBuffer
internalCreateBuffer(double[] data, long offset)
protected static DataBuffer
internalCreateBuffer(float[] data)
protected static DataBuffer
internalCreateBuffer(float[] data, long offset)
protected static DataBuffer
internalCreateBuffer(int[] data)
boolean
isAttached()
This method returns True, if this INDArray instance is attached to some Workspace.boolean
isB()
This method checks if this INDArray instance has boolean typeboolean
isColumnVector()
Returns true if the number of columns is 1boolean
isColumnVectorOrScalar()
Returns true if the number of columns is 1boolean
isCompressed()
Check if this array is compressed.boolean
isEmpty()
This method returns true if this INDArray is special case: no-value INDArrayINDArray
isInfinite()
Returns the binary NDArray with value true where this array's entries are infinite, or false where they are not infiniteboolean
isInScope()
This method checks, if given attached INDArray is still in scope of its parent Workspace PLEASE NOTE: if this INDArray isn't attached to any Workspace, this method will return trueboolean
isMatrix()
Returns true if this ndarray is a matrixINDArray
isNaN()
Returns the binary NDArray with value true where this array's entries are NaN, or false where they are not infiniteboolean
isR()
This method checks if this INDArray instance is one of Real typesboolean
isRowVector()
Returns true if the number of rows is 1boolean
isRowVectorOrScalar()
Returns true if the number of rows is 1boolean
isS()
This method checks if this INDArray instance has String typeboolean
isScalar()
Returns true if this ndarray is a scalarboolean
isSparse()
Check if this array is sparseboolean
isSquare()
Returns whether the matrix has the same rows and columnsboolean
isValid()
Deprecated.boolean
isVector()
Checks whether the matrix is a vector.boolean
isVectorOrScalar()
Returns true if this ndarray is a vector or scalarboolean
isView()
Check if this array is a view or not.boolean
isZ()
This method checks if this INDArray instance is one of integer typesIterator<Object>
iterator()
long
length()
Returns the total number of elements in the ndarrayINDArray
leverage()
This method detaches INDArray from current Workspace, and attaches it to Workspace above, if any.INDArray
leverageOrDetach(String id)
This method detaches INDArray from current Workspace, and attaches it to Workspace with a given Id, if a workspace with the given ID is open and active.INDArray
leverageTo(String id)
This method detaches INDArray from current Workspace, and attaches it to Workspace with a given Id - if a workspace with that ID exists.INDArray
leverageTo(String id, boolean enforceExistence)
This method detaches INDArray from current Workspace, and attaches it to Workspace with a given Id.INDArray
like()
This method returns empty array with the same dtype/order/shape as this onelong
linearIndex(long i)
Deprecated.INDArray
logEntropy(int... dimension)
Returns log entropy value for this INDArray along specified dimension(s)Number
logEntropyNumber()
Returns log entropy value for this INDArrayINDArray
lt(Number other)
Returns the binary ndarray for "Less" comparison.INDArray
lt(INDArray other)
Returns the binary ndarray for "Less" comparison.INDArray
lte(Number other)
Returns the binary ndarray for "Less or equals" comparison.void
markAsCompressed(boolean reallyCompressed)
This method marks INDArray instance as compressed PLEASE NOTE: Do not use this method unless you 100% have toINDArray
match(Number comp, Condition condition)
Returns a maskINDArray
match(INDArray comp, Condition condition)
Return a mask on whether each element matches the given conditionINDArray
max(boolean keepDims, int... dimension)
Returns the overall max of this ndarray along given dimensionsINDArray
max(int... dimension)
Returns the overall max of this ndarray along given dimensionsNumber
maxNumber()
Returns maximum value in this INDArrayINDArray
mean(boolean keepDims, int... dimension)
Returns the overall mean of this ndarrayINDArray
mean(int... dimension)
Returns the overall mean of this ndarrayINDArray
mean(@NonNull INDArray result, boolean keepDims, int... dimension)
Returns the overall mean of this ndarrayINDArray
mean(@NonNull INDArray result, int... dimension)
Returns the overall mean of this ndarrayNumber
meanNumber()
Returns the overall mean of this ndarrayINDArray
median(int... dimension)
This method returns median along given dimension(s)Number
medianNumber()
This method returns median value for this INDArrayINDArray
migrate()
This method pulls this INDArray into current Workspace.INDArray
migrate(boolean detachOnNoWs)
This method pulls this INDArray into current Workspace, or optionally detaches if no workspace is present.
That is:
If current workspace is present/active, INDArray is migrated to it.
If no current workspace is present/active, one of two things occur: 1.INDArray
min(boolean keepDims, int... dimension)
Returns the overall min of this ndarrayINDArray
min(int... dimension)
Returns the overall min of this ndarrayNumber
minNumber()
Returns min value in this INDArrayINDArray
mmul(INDArray other)
Perform a copy matrix multiplicationINDArray
mmul(INDArray other, char resultOrder)
Perform a copy matrix multiplicationINDArray
mmul(INDArray other, MMulTranspose mMulTranspose)
Perform a copy matrix multiplicationINDArray
mmul(INDArray other, INDArray result)
Perform an copy matrix multiplicationINDArray
mmul(INDArray other, INDArray result, MMulTranspose mMulTranspose)
Perform an copy matrix multiplicationINDArray
mmuli(INDArray other)
Perform an inplace matrix multiplicationINDArray
mmuli(INDArray other, MMulTranspose transpose)
Perform an copy matrix multiplicationINDArray
mmuli(INDArray other, INDArray result)
Perform an inplace matrix multiplicationINDArray
mmuli(INDArray other, INDArray result, MMulTranspose transpose)
Perform an in place matrix multiplicationINDArray
mul(Number n)
Scalar multiplication (copy)INDArray
mul(Number n, INDArray result)
Multiplication of ndarray.INDArray
mul(INDArray other)
copy (element wise) multiplication of two NDArraysINDArray
mul(INDArray other, INDArray result)
copy (element wise) multiplication of two NDArraysINDArray
mulColumnVector(INDArray columnVector)
Multiplication of a column vector (copy)INDArray
muli(Number n)
In place scalar multiplicationINDArray
muli(Number n, INDArray result)
In place multiplication of this ndarrayINDArray
muli(INDArray other)
in place (element wise) multiplication of two NDArraysINDArray
muli(INDArray other, INDArray result)
in place (element wise) multiplication of two NDArraysINDArray
muliColumnVector(INDArray columnVector)
In place multiplication of a column vectorINDArray
muliRowVector(INDArray rowVector)
In place multiplication of a row vectorINDArray
mulRowVector(INDArray rowVector)
Multiplication of a row vector (copy)INDArray
neg()
Returns the ndarray negative (cloned)INDArray
negi()
In place setting of the negative version of this ndarrayINDArray
neq(Number other)
Returns the binary ndarray for "Not equals" comparison.INDArray
neq(INDArray other)
Returns the binary ndarray for "Not equals" comparison.protected INDArray
newShape(long[] newShape, char ordering)
boolean
none()
This method checks if any of the elements within this array are non-zero (or true, in case of boolean)INDArray
norm1(boolean keepDims, int... dimension)
Returns the norm1 (L1 norm, i.e., sum of absolute values; also known as Taxicab or Manhattan norm) along the specified dimensionINDArray
norm1(int... dimension)
Returns the norm1 (L1 norm, i.e., sum of absolute values; also known as Taxicab or Manhattan norm) along the specified dimensionNumber
norm1Number()
Calculate and return norm1 (L1 norm, i.e., sum of absolute values; also known as Taxicab or Manhattan norm) for the entire arrayINDArray
norm2(boolean keepDims, int... dimension)
Returns the norm2 (L2 norm, sqrt(sum(x_i^2), also known as Euclidean norm) along the specified dimension(s)INDArray
norm2(int... dimension)
Returns the norm2 (L2 norm, sqrt(sum(x_i^2), also known as Euclidean norm) along the specified dimension(s)Number
norm2Number()
Return the norm2 (L2 norm, sqrt(sum(x_i^2), also known as Euclidean norm) for the entire arrayINDArray
normmax(boolean keepDims, int... dimension)
Returns the max norm (aka infinity norm, equal to the maximum absolute value) along the specified dimension(s)INDArray
normmax(int... dimension)
Returns the max norm (aka infinity norm, equal to the maximum absolute value) along the specified dimension(s)Number
normmaxNumber()
Return the max norm (aka infinity norm, equal to the maximum absolute value) for the entire arraylong
offset()
Returns the start of where the ndarray is for the underlying datachar
ordering()
Return the ordering (fortran or c 'f' and 'c' respectively) of this ndarraylong
originalOffset()
Returns the start of where the ndarray is for the original data bufferINDArray
percentile(Number quantile, int... dimension)
This method returns percentile along given dimension(s)Number
percentileNumber(Number quantile)
This method returns percentile value for this INDArrayINDArray
permute(int... rearrange)
See: http://www.mathworks.com/help/matlab/ref/permute.htmlINDArray
permutei(int... rearrange)
An in-place version of permute.INDArray
prod(boolean keepDims, int... dimension)
Returns the product along a given dimensionINDArray
prod(int... dimension)
Returns the product along a given dimensionNumber
prodNumber()
Calculate the product of all values in the arrayINDArray
put(int[] indices, INDArray element)
Inserts the element at the specified indexINDArray
put(int i, int j, Number element)
Inserts the element at the specified indexINDArray
put(int i, int j, INDArray element)
Inserts the element at the specified indexINDArray
put(int i, INDArray element)
Inserts the element at the specified indexINDArray
put(INDArray indices, INDArray element)
Put element in to the indices denoted by the indices ndarray.INDArray
put(INDArrayIndex[] indices, Number element)
Put the elements of the ndarray in to the specified indicesINDArray
put(INDArrayIndex[] indices, INDArray element)
Put the elements of the ndarray in to the specified indicesINDArray
putColumn(int column, INDArray toPut)
Insert a column in to this array Will throw an exception if this ndarray is not a matrixINDArray
putiColumnVector(INDArray columnVector)
In place assignment of a column vectorINDArray
putiRowVector(INDArray rowVector)
in place assignment of row vector, to each row of this arrayINDArray
putRow(long row, INDArray toPut)
Insert a row in to this array Will throw an exception if this ndarray is not a matrixINDArray
putScalar(int[] indexes, double value)
Insert the item at the specified indicesINDArray
putScalar(int[] indexes, float value)
Put the specified float value at the specified indices in this arrayINDArray
putScalar(int[] indexes, int value)
Put the specified integer value at the specified indices in this arrayINDArray
putScalar(long[] indexes, double value)
INDArray
putScalar(long[] indexes, float value)
INDArray
putScalar(long[] indexes, int value)
INDArray
putScalar(long i, double value)
Insert the number linearly in to the ndarrayINDArray
putScalar(long i, float value)
Insert a scalar float at the specified indexINDArray
putScalar(long i, int value)
Insert a scalar int at the specified indexINDArray
putScalar(long row, long col, double value)
Insert the value at the specified indices, in a 2d (rank 2) NDArray
Equivalent toINDArray.putScalar(int[], double)
but avoids int[] creationINDArray
putScalar(long dim0, long dim1, long dim2, double value)
Insert the value at the specified indices, in a 3d (rank 3) NDArray
Equivalent toINDArray.putScalar(int[], double)
but avoids int[] creationINDArray
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 toINDArray.putScalar(int[], double)
but avoids int[] creationINDArray
putScalarUnsafe(long offset, double value)
Insert a scalar at the given linear offsetINDArray
putSlice(int slice, INDArray put)
Assigns the given matrix (put) to the specified sliceINDArray
putWhere(Number comp, Number put, Condition condition)
Assign the element according to the comparison arrayINDArray
putWhere(Number comp, INDArray put, Condition condition)
Assign the element according to the comparison arrayINDArray
putWhere(INDArray comp, INDArray put, Condition condition)
Assign the element according to the comparison arrayINDArray
putWhereWithMask(INDArray mask, Number put)
Use a pre computed mask for assigning arraysINDArray
putWhereWithMask(INDArray mask, INDArray put)
Use a pre computed mask for assigning arraysint
rank()
Returns the rank of the ndarray (the number of dimensions).INDArray
ravel()
Returns a flattened version (row vector) of this ndarrayINDArray
ravel(char ordering)
Returns a flattened version (row vector) of this ndarrayINDArray
rdiv(Number n)
Reverse division with a scalar - i.e., (n / thisArrayValues)INDArray
rdiv(Number n, INDArray result)
Reverse division (number / ndarray)INDArray
rdiv(INDArray other)
Reverse division, elements wise.INDArray
rdiv(INDArray other, INDArray result)
Reverse divisionINDArray
rdivColumnVector(INDArray columnVector)
Reverse division of a column vector (copy)INDArray
rdivi(Number n)
In place reverse division - i.e., (n / thisArrayValues)INDArray
rdivi(Number n, INDArray result)
Reverse in place divisionINDArray
rdivi(INDArray other)
Reverse divsion (in place).INDArray
rdivi(INDArray other, INDArray result)
Reverse division (in-place)INDArray
rdiviColumnVector(INDArray columnVector)
In place reverse divison of a column vectorINDArray
rdiviRowVector(INDArray rowVector)
In place reverse division of a column vectorINDArray
rdivRowVector(INDArray rowVector)
Reverse division of a column vector (copy)protected void
read(ObjectInputStream s)
INDArray
remainder(Number denominator)
The scalar remainderINDArray
remainder(Number denominator, INDArray result)
The scalar remainderINDArray
remainder(INDArray denominator)
Remainder operatorINDArray
remainder(INDArray denominator, INDArray result)
Remainder operatorINDArray
remainderi(Number denominator)
In place remainderINDArray
remainderi(INDArray denominator)
In place remainderINDArray
repeat(int dimension, long... repeats)
Repeat elements along a specified dimension.INDArray
replaceWhere(INDArray arr, Condition condition)
Replaces all elements in this ndarray that are matching give condition, with corresponding elements from given arrayINDArray
repmat(int[] shape)
Deprecated.INDArray
repmat(long[] shape)
Replicate and tile array to fill out to the given shape See: https://github.com/numpy/numpy/blob/master/numpy/matlib.py#L310-L358INDArray
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)
Deprecated.INDArray
reshape(char order, int rows, int columns)
Reshapes the ndarray (can't change the length of the ndarray).INDArray
reshape(char order, long... newShape)
Reshapes the ndarray (can't change the length of the ndarray).INDArray
reshape(int[] shape)
Reshape the ndarray in to the specified dimensions, possible errors being thrown for invalid shapes Note here that one dimension can be -1.INDArray
reshape(long... shape)
Reshapes the ndarray (can't change the length of the ndarray).INDArray
reshape(long newRows, long newColumns)
Reshapes the ndarray (can't change the length of the ndarray).int
rows()
Returns the number of rows in this matrix (throws exception if not 2d)INDArray
rsub(Number n)
Reverse subtraction with duplicates - i.e., (n - thisArrayValues)INDArray
rsub(Number n, INDArray result)
Reverse subtractionINDArray
rsub(INDArray other)
Element-wise reverse subtraction (copy op).INDArray
rsub(INDArray other, INDArray result)
Reverse subtractionINDArray
rsubColumnVector(INDArray columnVector)
Reverse subtraction of a column vector (copy)INDArray
rsubi(Number n)
Reverse subtraction in place - i.e., (n - thisArrayValues)INDArray
rsubi(Number n, INDArray result)
Reverse in place subtractionINDArray
rsubi(INDArray other)
Element-wise reverse subtraction (in the place op) - i.e., other - thisINDArray
rsubi(INDArray other, INDArray result)
Reverse subtraction (in-place)INDArray
rsubiColumnVector(INDArray columnVector)
In place reverse subtraction of a column vectorINDArray
rsubiRowVector(INDArray rowVector)
In place reverse subtraction of a row vectorINDArray
rsubRowVector(INDArray rowVector)
Reverse subtraction of a row vector (copy)Number
scan(Condition condition)
This method takes boolean condition, and returns number of elements matching this conditionvoid
setData(DataBuffer data)
Set the data for this ndarray.void
setOrder(char order)
Set the orderingvoid
setShapeAndStride(int[] shape, int[] stride)
Shape and stride setterINDArray
shannonEntropy(int... dimension)
Returns Shannon entropy value for this INDArray along specified dimension(s)Number
shannonEntropyNumber()
Returns non-normalized Shannon entropy value for this INDArraylong[]
shape()
Returns the shape of this ndarrayLongBuffer
shapeInfo()
Shape infoDataBuffer
shapeInfoDataBuffer()
Shape infolong[]
shapeInfoJava()
This method returns shapeInformation as jvm long arrayString
shapeInfoToString()
Returns the shape information debugging informationprotected DataBuffer
shapeOf()
long
size(int dimension)
Returns the size along a specified dimensionINDArray
slice(long slice)
Returns the specified slice of this ndarrayINDArray
slice(long slice, int dimension)
Returns the slice of this from the specified dimensionlong
slices()
Returns the number of slices in this ndarrayvoid
sliceVectors(List<INDArray> list)
Flattens the array for linear indexing in list.double
squaredDistance(INDArray other)
Returns the square of the Euclidean distance.INDArray
std(boolean biasCorrected, boolean keepDims, int... dimension)
Standard deviation of an ndarray along a dimensionINDArray
std(boolean biasCorrected, int... dimension)
Standard deviation of an ndarray along a dimensionINDArray
std(int... dimension)
Standard deviation of an INDArray along one or more dimensionsNumber
stdNumber()
Calculate the standard deviation for the entire arrayNumber
stdNumber(boolean biasCorrected)
Calculate the standard deviation for the entire array, specifying whether it is bias corrected or notlong[]
stride()
Returns the stride of this ndarrayint
stride(int dimension)
Calculate the stride along a particular dimensionprotected DataBuffer
strideOf()
protected abstract int
stringBuffer(com.google.flatbuffers.FlatBufferBuilder builder, DataBuffer buffer)
INDArray
sub(Number n)
Scalar subtraction (copied)INDArray
sub(Number n, INDArray result)
Subtraction of this ndarrayINDArray
sub(INDArray other)
copy subtraction of two NDArraysINDArray
sub(INDArray other, INDArray result)
copy subtraction of two NDArraysINDArray
subColumnVector(INDArray columnVector)
Subtraction of a column vector (copy)INDArray
subi(Number n)
In place scalar subtractionINDArray
subi(Number n, INDArray result)
In place subtraction of this ndarrayINDArray
subi(INDArray other)
in place (element wise) subtraction of two NDArraysINDArray
subi(INDArray other, INDArray result)
in place subtraction of two matricesINDArray
subiColumnVector(INDArray columnVector)
In place subtraction of a column vectorINDArray
subiRowVector(INDArray rowVector)
In place subtraction of a row vectorINDArray
subRowVector(INDArray rowVector)
Subtraction of a row vector (copy)INDArray
sum(boolean keepDim, int... dimension)
Returns the sum along the last dimension of this ndarrayINDArray
sum(int... dimension)
Returns the sum along the last dimension of this ndarrayINDArray
sum(@NonNull INDArray result, boolean keepDims, int... dimension)
Returns the sum along the last dimension of this ndarrayINDArray
sum(@NonNull INDArray result, int... dimension)
Returns the sum along the last dimension of this ndarrayNumber
sumNumber()
Sum the entire arrayINDArray
swapAxes(int dimension, int with)
Mainly here for people coming from numpy.INDArray
tensorAlongDimension(long index, int... dimension)
Get the vector along a particular dimensionlong
tensorsAlongDimension(int... dimension)
Returns the number of possible vectors for a given dimensiondouble[][]
toDoubleMatrix()
Convert this ndarray to a 2d double matrix.double[]
toDoubleVector()
Convert this ndarray to a 1d double matrix.int
toFlatArray(com.google.flatbuffers.FlatBufferBuilder builder)
Add anINDArray
to flatbuffers builderfloat[][]
toFloatMatrix()
Convert this ndarray to a 2d float matrix.float[]
toFloatVector()
Convert this ndarray to a 1d float vector.int[][]
toIntMatrix()
Convert this ndarray to a 2d int matrix.int[]
toIntVector()
Convert this ndarray to a 1d int matrix.long[][]
toLongMatrix()
Convert this ndarray to a 2d int matrix.long[]
toLongVector()
Convert this ndarray to a 1d long matrix.String
toString()
Generate string representation of the matrix.String
toString(long maxElements, boolean forceSummarize, int precision)
Get a string representation of the arrayString
toString(@NonNull NDArrayStrings options)
Get a string representation of the array with configurable formattingString
toStringFull()
ToString with unlimited elements and precisionINDArray
transpose()
Flip the rows and columns of a matrixINDArray
transposei()
Return transposed version of this matrix.INDArray
ulike()
This method returns uninitialized array with the same dtype/order/shape as this oneprotected void
validateNumericalArray(String opName, boolean allowEmpty)
Validate that the operation is being applied on a numerical array (not boolean or utf8).INDArray
var(boolean biasCorrected, int... dimension)
Returns the overall variance of this ndarrayINDArray
var(int... dimension)
Returns the overall variance of this ndarrayNumber
varNumber()
Returns the overall variance of all values in this INDArrayINDArray
vectorAlongDimension(int index, int dimension)
Get the vector along a particular dimensionlong
vectorsAlongDimension(int dimension)
Returns the number of possible vectors for a given dimensionboolean
wasClosed()
This method checks if array or its buffer was closed beforeprotected void
write(ObjectOutputStream out)
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.nd4j.linalg.api.ndarray.INDArray
getString, setCloseable, shapeDescriptor, unsafeDuplication, unsafeDuplication
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Field Detail
-
shapeInformation
protected transient volatile DataBuffer shapeInformation
-
data
protected transient volatile DataBuffer data
-
compressed
protected transient boolean compressed
-
closeable
protected transient boolean closeable
-
released
protected transient boolean released
-
jvmShapeInfo
protected transient JvmShapeInfo jvmShapeInfo
-
arrayId
protected transient long arrayId
-
-
Constructor Detail
-
BaseNDArray
public BaseNDArray()
-
BaseNDArray
public BaseNDArray(DataBuffer buffer)
- Parameters:
buffer
-
-
BaseNDArray
public BaseNDArray(DataBuffer buffer, int[] shape, int[] stride, long offset, char ordering)
- Parameters:
buffer
-shape
-stride
-offset
-ordering
-
-
BaseNDArray
public BaseNDArray(DataBuffer buffer, long[] shape, long[] stride, long offset, char ordering)
-
BaseNDArray
public BaseNDArray(DataBuffer buffer, long[] shape, long[] stride, long offset, long ews, char ordering)
-
BaseNDArray
public BaseNDArray(DataBuffer buffer, long[] shape, long[] stride, long offset, char ordering, DataType dataType)
-
BaseNDArray
public BaseNDArray(DataBuffer buffer, long[] shape, long[] stride, long offset, long ews, char ordering, DataType dataType)
-
BaseNDArray
public BaseNDArray(DataBuffer buffer, long[] shape, long[] stride, char ordering, DataType type)
-
BaseNDArray
public BaseNDArray(DataBuffer buffer, long[] shape, long[] stride, char ordering, DataType type, MemoryWorkspace workspace)
-
BaseNDArray
public BaseNDArray(DataBuffer buffer, DataType dataType, long[] shape, long[] stride, long offset, char ordering)
-
BaseNDArray
public BaseNDArray(double[][] data)
Initialize the ndarray as a matrix with the given data (indices preserved)- Parameters:
data
-
-
BaseNDArray
public BaseNDArray(double[][] data, char ordering)
- Parameters:
data
-ordering
-
-
BaseNDArray
public BaseNDArray(int[] shape, DataBuffer buffer)
Create with the specified shape and buffer- Parameters:
shape
- the shapebuffer
- the buffer
-
BaseNDArray
public BaseNDArray(float[] data, int[] shape, char ordering)
Create this ndarray with the given data and shape and 0 offset- Parameters:
data
- the data to useshape
- the shape of the ndarray
-
BaseNDArray
public BaseNDArray(float[] data, int[] shape, long offset, char ordering)
- Parameters:
data
- the data to useshape
- the shape of the ndarrayoffset
- the desired offsetordering
- the ordering of the ndarray
-
BaseNDArray
public BaseNDArray(double[] data, long[] shape, long offset, char ordering)
-
BaseNDArray
public BaseNDArray(float[] data, long[] shape, long offset, char ordering)
-
BaseNDArray
public BaseNDArray(int[] shape, int[] stride, long offset, char ordering)
Construct an ndarray of the specified shape with an empty data array- Parameters:
shape
- the shape of the ndarraystride
- the stride of the ndarrayoffset
- the desired offsetordering
- the ordering of the ndarray
-
BaseNDArray
public BaseNDArray(long[] shape, long[] stride, long offset, char ordering)
-
BaseNDArray
public BaseNDArray(int[] shape, int[] stride, long offset, char ordering, boolean initialize)
Construct an ndarray of the specified shape.- Parameters:
shape
- the shape of the ndarraystride
- the stride of the ndarrayoffset
- the desired offsetordering
- the ordering of the ndarrayinitialize
- Whether to initialize the INDArray. If true: initialize. If false: don't.
-
BaseNDArray
public BaseNDArray(long[] shape, long[] stride, long offset, char ordering, boolean initialize)
-
BaseNDArray
public BaseNDArray(DataType type, long[] shape, long[] stride, long offset, char ordering, boolean initialize)
-
BaseNDArray
public BaseNDArray(DataType type, long[] shape, long[] stride, long offset, char ordering, boolean initialize, MemoryWorkspace workspace)
-
BaseNDArray
public BaseNDArray(DataType type, long[] shape, long[] paddings, long[] paddingOffsets, char ordering, MemoryWorkspace workspace)
-
BaseNDArray
public BaseNDArray(int[] shape, int[] stride, char ordering)
Create the ndarray with the specified shape and stride and an offset of 0- Parameters:
shape
- the shape of the ndarraystride
- the stride of the ndarrayordering
- the ordering of the ndarray
-
BaseNDArray
public BaseNDArray(int[] shape, long offset, char ordering)
- Parameters:
shape
-offset
-ordering
-
-
BaseNDArray
public BaseNDArray(long[] shape, long offset, char ordering)
-
BaseNDArray
public BaseNDArray(int[] shape)
Create an ndarray with the given shape- Parameters:
shape
-
-
BaseNDArray
public BaseNDArray(long[] shape)
-
BaseNDArray
public BaseNDArray(int newRows, int newColumns, char ordering)
Creates a new n times m DoubleMatrix.- Parameters:
newRows
- the number of rows (n) of the new matrix.newColumns
- the number of columns (m) of the new matrix.
-
BaseNDArray
public BaseNDArray(long newRows, long newColumns, char ordering)
-
BaseNDArray
public BaseNDArray(List<INDArray> slices, int[] shape, char ordering)
Create an ndarray from the specified slices. This will go through and merge all of the data from each slice in to one ndarray which will then take the specified shape- Parameters:
slices
- the slices to mergeshape
- the shape of the ndarray
-
BaseNDArray
public BaseNDArray(List<INDArray> slices, int[] shape, int[] stride, char ordering)
Create an ndarray from the specified slices. This will go through and merge all of the data from each slice in to one ndarray which will then take the specified shape- Parameters:
slices
- the slices to mergeshape
- the shape of the ndarray
-
BaseNDArray
public BaseNDArray(float[] data, int[] shape, int[] stride, char ordering)
- Parameters:
data
-shape
-stride
-ordering
-
-
BaseNDArray
public BaseNDArray(float[] data, int[] shape, int[] stride, long offset, char ordering)
- Parameters:
data
-shape
-stride
-offset
-ordering
-
-
BaseNDArray
public BaseNDArray(float[] data, long[] shape, long[] stride, long offset, char ordering)
-
BaseNDArray
public BaseNDArray(double[] data, long[] shape, long[] stride, long offset, char ordering)
-
BaseNDArray
public BaseNDArray(DataBuffer data, int[] shape, int[] stride, long offset)
- Parameters:
data
-shape
-stride
-offset
-
-
BaseNDArray
public BaseNDArray(int[] data, int[] shape, int[] strides)
- Parameters:
data
-shape
-strides
-
-
BaseNDArray
public BaseNDArray(DataBuffer data, int[] shape)
- Parameters:
data
-shape
-
-
BaseNDArray
public BaseNDArray(DataBuffer data, long[] shape)
-
BaseNDArray
public BaseNDArray(DataBuffer buffer, int[] shape, long offset)
- Parameters:
buffer
-shape
-offset
-
-
BaseNDArray
public BaseNDArray(DataBuffer buffer, int[] shape, char ordering)
- Parameters:
buffer
-shape
-ordering
-
-
BaseNDArray
public BaseNDArray(DataBuffer buffer, long[] shape, char ordering)
-
BaseNDArray
public BaseNDArray(double[] data, int[] shape, char ordering)
- Parameters:
data
-shape
-ordering
-
-
BaseNDArray
public BaseNDArray(double[] data, long[] shape, char ordering)
-
BaseNDArray
public BaseNDArray(float[] data, long[] shape, char ordering)
-
BaseNDArray
public BaseNDArray(double[] data, int[] shape, int[] stride, long offset, char ordering)
- Parameters:
data
-shape
-stride
-offset
-ordering
-
-
BaseNDArray
public BaseNDArray(float[] data, char order)
- Parameters:
data
-order
-
-
BaseNDArray
public BaseNDArray(DataBuffer floatBuffer, char order)
- Parameters:
floatBuffer
-order
-
-
BaseNDArray
public BaseNDArray(DataBuffer buffer, int[] shape, int[] strides)
- Parameters:
buffer
-shape
-strides
-
-
BaseNDArray
public BaseNDArray(float[] data, int[] shape)
Create this ndarray with the given data and shape and 0 offset- Parameters:
data
- the data to useshape
- the shape of the ndarray
-
BaseNDArray
public BaseNDArray(float[] data, int[] shape, long offset)
- Parameters:
data
-shape
-offset
-
-
BaseNDArray
public BaseNDArray(int[] shape, int[] stride, long offset)
Construct an ndarray of the specified shape with an empty data array- Parameters:
shape
- the shape of the ndarraystride
- the stride of the ndarrayoffset
- the desired offset
-
BaseNDArray
public BaseNDArray(long[] shape, long[] stride, long offset)
-
BaseNDArray
public BaseNDArray(int[] shape, int[] stride)
Create the ndarray with the specified shape and stride and an offset of 0- Parameters:
shape
- the shape of the ndarraystride
- the stride of the ndarray
-
BaseNDArray
public BaseNDArray(int[] shape, long offset)
- Parameters:
shape
-offset
-
-
BaseNDArray
public BaseNDArray(int[] shape, char ordering)
- Parameters:
shape
-ordering
-
-
BaseNDArray
public BaseNDArray(int newRows, int newColumns)
Creates a new n times m DoubleMatrix.- Parameters:
newRows
- the number of rows (n) of the new matrix.newColumns
- the number of columns (m) of the new matrix.
-
BaseNDArray
public BaseNDArray(long newRows, long newColumns)
-
BaseNDArray
public BaseNDArray(List<INDArray> slices, int[] shape)
Create an ndarray from the specified slices. This will go through and merge all of the data from each slice in to one ndarray which will then take the specified shape- Parameters:
slices
- the slices to mergeshape
- the shape of the ndarray
-
BaseNDArray
public BaseNDArray(List<INDArray> slices, int[] shape, int[] stride)
Create an ndarray from the specified slices. This will go through and merge all of the data from each slice in to one ndarray which will then take the specified shape- Parameters:
slices
- the slices to mergeshape
- the shape of the ndarray
-
BaseNDArray
public BaseNDArray(float[] data, int[] shape, int[] stride)
- Parameters:
data
-shape
-stride
-
-
BaseNDArray
public BaseNDArray(float[] data, int[] shape, int[] stride, long offset)
- Parameters:
data
-shape
-stride
-offset
-
-
BaseNDArray
public BaseNDArray(double[] data, long[] shape, long[] stride, long offset)
-
BaseNDArray
public BaseNDArray(float[] data, long[] shape, long[] stride, long offset)
-
BaseNDArray
public BaseNDArray(float[] data)
- Parameters:
data
-
-
BaseNDArray
public BaseNDArray(float[][] data)
Initialize the ndarray with the given data- Parameters:
data
-
-
BaseNDArray
public BaseNDArray(float[][] data, char ordering)
- Parameters:
data
-ordering
-
-
BaseNDArray
public BaseNDArray(DataBuffer buffer, int[] shape, long offset, char ordering)
Constructor for stride and offset- Parameters:
buffer
-shape
-offset
-ordering
-
-
BaseNDArray
public BaseNDArray(double[] data, int[] shape, int[] stride, long offset)
-
-
Method Detail
-
isCompressed
public boolean isCompressed()
Description copied from interface:INDArray
Check if this array is compressed.- Specified by:
isCompressed
in interfaceINDArray
- Returns:
- true if this array is compressed.
-
markAsCompressed
public void markAsCompressed(boolean reallyCompressed)
Description copied from interface:INDArray
This method marks INDArray instance as compressed PLEASE NOTE: Do not use this method unless you 100% have to- Specified by:
markAsCompressed
in interfaceINDArray
- Parameters:
reallyCompressed
- new value for compressed.
-
internalCreateBuffer
protected static DataBuffer internalCreateBuffer(float[] data)
-
internalCreateBuffer
protected static DataBuffer internalCreateBuffer(double[] data)
-
internalCreateBuffer
protected static DataBuffer internalCreateBuffer(int[] data)
-
internalCreateBuffer
protected static DataBuffer internalCreateBuffer(float[] data, long offset)
-
internalCreateBuffer
protected static DataBuffer internalCreateBuffer(double[] data, long offset)
-
isValid
@Deprecated public boolean isValid()
Deprecated.Returns whether the ndarray is valid or not- Returns:
- true if the ndarray is valid false otherwise
-
create
protected INDArray create(DataBuffer data, int[] shape, long offset)
-
elementWiseStride
public int elementWiseStride()
Description copied from interface:INDArray
Element wise stride- Specified by:
elementWiseStride
in interfaceINDArray
- Returns:
- the element wise stride
-
tensorsAlongDimension
public long tensorsAlongDimension(int... dimension)
Description copied from interface:INDArray
Returns the number of possible vectors for a given dimension- Specified by:
tensorsAlongDimension
in interfaceINDArray
- Parameters:
dimension
- the dimension to calculate the number of vectors for- Returns:
- the number of possible vectors along a dimension
-
tensorAlongDimension
public INDArray tensorAlongDimension(long index, int... dimension)
Description copied from interface:INDArray
Get the vector along a particular dimension- Specified by:
tensorAlongDimension
in interfaceINDArray
- Parameters:
index
- the index of the vector to getScalardimension
- the dimension to getScalar the vector from- Returns:
- the vector along a particular dimension
-
vectorsAlongDimension
public long vectorsAlongDimension(int dimension)
Description copied from interface:INDArray
Returns the number of possible vectors for a given dimension- Specified by:
vectorsAlongDimension
in interfaceINDArray
- Parameters:
dimension
- the dimension to calculate the number of vectors for- Returns:
- the number of possible vectors along a dimension
-
vectorAlongDimension
public INDArray vectorAlongDimension(int index, int dimension)
Description copied from interface:INDArray
Get the vector along a particular dimension- Specified by:
vectorAlongDimension
in interfaceINDArray
- Parameters:
index
- the index of the vector to getScalardimension
- the dimension to getScalar the vector from- Returns:
- the vector along a particular dimension
-
setOrder
public void setOrder(char order)
Description copied from interface:INDArray
Set the ordering
-
setShapeAndStride
public void setShapeAndStride(int[] shape, int[] stride)
Description copied from interface:INDArray
Shape and stride setter- Specified by:
setShapeAndStride
in interfaceINDArray
- Parameters:
shape
- new value for shapestride
- new value for stride
-
cumsumi
public INDArray cumsumi(int dimension)
Description copied from interface:INDArray
Returns the cumulative sum along a dimension. In-place method.
-
normmaxNumber
public Number normmaxNumber()
Description copied from interface:INDArray
Return the max norm (aka infinity norm, equal to the maximum absolute value) for the entire array- Specified by:
normmaxNumber
in interfaceINDArray
- Returns:
- Max norm for the entire array
-
norm2Number
public Number norm2Number()
Description copied from interface:INDArray
Return the norm2 (L2 norm, sqrt(sum(x_i^2), also known as Euclidean norm) for the entire array- Specified by:
norm2Number
in interfaceINDArray
- Returns:
- L2 norm for the array
-
norm1Number
public Number norm1Number()
Description copied from interface:INDArray
Calculate and return norm1 (L1 norm, i.e., sum of absolute values; also known as Taxicab or Manhattan norm) for the entire array- Specified by:
norm1Number
in interfaceINDArray
- Returns:
- Norm 1 for the array
-
stdNumber
public Number stdNumber()
Description copied from interface:INDArray
Calculate the standard deviation for the entire array
-
prodNumber
public Number prodNumber()
Description copied from interface:INDArray
Calculate the product of all values in the array- Specified by:
prodNumber
in interfaceINDArray
- Returns:
- Product of all values in the array
-
meanNumber
public Number meanNumber()
Description copied from interface:INDArray
Returns the overall mean of this ndarray- Specified by:
meanNumber
in interfaceINDArray
- Returns:
- the mean along the specified dimension of this ndarray
-
ameanNumber
public Number ameanNumber()
Description copied from interface:INDArray
Returns the absolute overall mean of this ndarray- Specified by:
ameanNumber
in interfaceINDArray
- Returns:
- the mean along the specified dimension of this ndarray
-
varNumber
public Number varNumber()
Description copied from interface:INDArray
Returns the overall variance of all values in this INDArray
-
maxNumber
public Number maxNumber()
Description copied from interface:INDArray
Returns maximum value in this INDArray
-
amaxNumber
public Number amaxNumber()
Description copied from interface:INDArray
Returns maximum (absolute) value in this INDArray- Specified by:
amaxNumber
in interfaceINDArray
- Returns:
- Max absolute value
-
minNumber
public Number minNumber()
Description copied from interface:INDArray
Returns min value in this INDArray
-
aminNumber
public Number aminNumber()
Description copied from interface:INDArray
Returns absolute min value in this INDArray- Specified by:
aminNumber
in interfaceINDArray
- Returns:
- Absolute min value
-
scan
public Number scan(Condition condition)
Description copied from interface:INDArray
This method takes boolean condition, and returns number of elements matching this condition
-
sumNumber
public Number sumNumber()
Description copied from interface:INDArray
Sum the entire array
-
entropyNumber
public Number entropyNumber()
Description copied from interface:INDArray
Returns entropy value for this INDArray- Specified by:
entropyNumber
in interfaceINDArray
- Returns:
- entropy value
-
shannonEntropyNumber
public Number shannonEntropyNumber()
Description copied from interface:INDArray
Returns non-normalized Shannon entropy value for this INDArray- Specified by:
shannonEntropyNumber
in interfaceINDArray
- Returns:
- non-normalized Shannon entropy
-
logEntropyNumber
public Number logEntropyNumber()
Description copied from interface:INDArray
Returns log entropy value for this INDArray- Specified by:
logEntropyNumber
in interfaceINDArray
- Returns:
- log entropy value
-
cumsum
public INDArray cumsum(int dimension)
Description copied from interface:INDArray
Returns the cumulative sum along a dimension.
-
assign
public INDArray assign(INDArray arr)
Description copied from interface:INDArray
Assign all of the elements in the given ndarray to this ndarray
-
putScalar
public INDArray putScalar(long i, double value)
Description copied from interface:INDArray
Insert the number linearly in to the ndarray
-
putScalar
public INDArray putScalar(long i, float value)
Description copied from interface:INDArray
Insert a scalar float at the specified index
-
putScalar
public INDArray putScalar(long i, int value)
Description copied from interface:INDArray
Insert a scalar int at the specified index
-
putScalar
public INDArray putScalar(int[] indexes, double value)
Description copied from interface:INDArray
Insert the item at the specified indices
-
putScalar
public INDArray putScalar(long[] indexes, double value)
Description copied from interface:INDArray
-
putScalar
public INDArray putScalar(long[] indexes, float value)
Description copied from interface:INDArray
-
putScalar
public INDArray putScalar(long row, long col, double value)
Description copied from interface:INDArray
Insert the value at the specified indices, in a 2d (rank 2) NDArray
Equivalent toINDArray.putScalar(int[], double)
but avoids int[] creation
-
putScalar
public INDArray putScalar(long dim0, long dim1, long dim2, double value)
Description copied from interface:INDArray
Insert the value at the specified indices, in a 3d (rank 3) NDArray
Equivalent toINDArray.putScalar(int[], double)
but avoids int[] creation
-
putScalar
public INDArray putScalar(long dim0, long dim1, long dim2, long dim3, double value)
Description copied from interface:INDArray
Insert the value at the specified indices, in a 4d (rank 4) NDArray
Equivalent toINDArray.putScalar(int[], double)
but avoids int[] creation
-
putScalar
public INDArray putScalar(int[] indexes, float value)
Description copied from interface:INDArray
Put the specified float value at the specified indices in this array
-
putScalar
public INDArray putScalar(int[] indexes, int value)
Description copied from interface:INDArray
Put the specified integer value at the specified indices in this array
-
putScalar
public INDArray putScalar(long[] indexes, int value)
Description copied from interface:INDArray
-
eps
public INDArray eps(Number other)
Description copied from interface:INDArray
Returns the binary ndarray for "Epsilon equals" comparison.
-
eps
public INDArray eps(INDArray other)
Description copied from interface:INDArray
Returns the binary ndarray for "Epsilon equals" comparison.
-
lt
public INDArray lt(Number other)
Description copied from interface:INDArray
Returns the binary ndarray for "Less" comparison.
-
lte
public INDArray lte(Number other)
Description copied from interface:INDArray
Returns the binary ndarray for "Less or equals" comparison.
-
eq
public INDArray eq(Number other)
Description copied from interface:INDArray
Returns the binary ndarray for "Equals" comparison.
-
gt
public INDArray gt(Number other)
Description copied from interface:INDArray
Returns the binary ndarray for "Greater" comparison.
-
gte
public INDArray gte(Number other)
Description copied from interface:INDArray
Returns binary ndarray for "Greter or equals" comparison.
-
lt
public INDArray lt(INDArray other)
Description copied from interface:INDArray
Returns the binary ndarray for "Less" comparison.
-
neq
public INDArray neq(Number other)
Description copied from interface:INDArray
Returns the binary ndarray for "Not equals" comparison.
-
neq
public INDArray neq(INDArray other)
Description copied from interface:INDArray
Returns the binary ndarray for "Not equals" comparison.
-
eq
public INDArray eq(INDArray other)
Description copied from interface:INDArray
Returns the binary ndarray for "Equals" comparison.
-
gt
public INDArray gt(INDArray other)
Description copied from interface:INDArray
Returns the binary ndarray for "Greater Than" comparison.
-
isInfinite
public INDArray isInfinite()
Description copied from interface:INDArray
Returns the binary NDArray with value true where this array's entries are infinite, or false where they are not infinite- Specified by:
isInfinite
in interfaceINDArray
-
isNaN
public INDArray isNaN()
Description copied from interface:INDArray
Returns the binary NDArray with value true where this array's entries are NaN, or false where they are not infinite
-
neg
public INDArray neg()
Description copied from interface:INDArray
Returns the ndarray negative (cloned)
-
negi
public INDArray negi()
Description copied from interface:INDArray
In place setting of the negative version of this ndarray
-
rdiv
public INDArray rdiv(Number n, INDArray result)
Description copied from interface:INDArray
Reverse division (number / ndarray)
-
rdivi
public INDArray rdivi(Number n, INDArray result)
Description copied from interface:INDArray
Reverse in place division
-
rsub
public INDArray rsub(Number n, INDArray result)
Description copied from interface:INDArray
Reverse subtraction
-
rsubi
public INDArray rsubi(Number n, INDArray result)
Description copied from interface:INDArray
Reverse in place subtraction
-
div
public INDArray div(Number n, INDArray result)
Description copied from interface:INDArray
Division if ndarray by number
-
divi
public INDArray divi(Number n, INDArray result)
Description copied from interface:INDArray
In place division of this ndarray
-
mul
public INDArray mul(Number n, INDArray result)
Description copied from interface:INDArray
Multiplication of ndarray.
-
muli
public INDArray muli(Number n, INDArray result)
Description copied from interface:INDArray
In place multiplication of this ndarray
-
sub
public INDArray sub(Number n, INDArray result)
Description copied from interface:INDArray
Subtraction of this ndarray
-
subi
public INDArray subi(Number n, INDArray result)
Description copied from interface:INDArray
In place subtraction of this ndarray
-
add
public INDArray add(Number n, INDArray result)
Description copied from interface:INDArray
Addition of this ndarray.
-
addi
public INDArray addi(Number n, INDArray result)
Description copied from interface:INDArray
In place addition
-
getScalar
public INDArray getScalar(long row, long column)
Description copied from interface:INDArray
Returns the element at the specified row/column
-
dup
public INDArray dup()
Description copied from interface:INDArray
Returns a copy of this ndarray
-
dup
public INDArray dup(char order)
Description copied from interface:INDArray
Returns a copy of this ndarray, where the returned ndarray has the specified order
-
getInt
public int getInt(int... indices)
Description copied from interface:INDArray
Get an integer value at the specified indices. Result will be cast to an integer, precision loss is possible.
-
getLong
public long getLong(long index)
Description copied from interface:INDArray
Get a long value at the specified index.
-
getLong
public long getLong(long... indices)
Description copied from interface:INDArray
Get a long value at the specified indices.
-
getDouble
public double getDouble(int... indices)
Description copied from interface:INDArray
Get a double value at the specified indices.
-
getDouble
public double getDouble(long... indices)
Description copied from interface:INDArray
-
getFloat
public float getFloat(int... indices)
Description copied from interface:INDArray
Returns the elements at the specified indices
-
getFloat
public float getFloat(long... indices)
Description copied from interface:INDArray
-
isScalar
public boolean isScalar()
Description copied from interface:INDArray
Returns true if this ndarray is a scalar
-
put
public INDArray put(int[] indices, INDArray element)
Description copied from interface:INDArray
Inserts the element at the specified index
-
match
public INDArray match(INDArray comp, Condition condition)
Description copied from interface:INDArray
Return a mask on whether each element matches the given condition
-
match
public INDArray match(Number comp, Condition condition)
Description copied from interface:INDArray
Returns a mask
-
getWhere
public INDArray getWhere(INDArray comp, Condition condition)
Description copied from interface:INDArray
Boolean indexing: Return the element if it fulfills the condition in result array
-
getWhere
public INDArray getWhere(Number comp, Condition condition)
Description copied from interface:INDArray
Boolean indexing: Return the element if it fulfills the condition in result array
-
putWhere
public INDArray putWhere(INDArray comp, INDArray put, Condition condition)
Description copied from interface:INDArray
Assign the element according to the comparison array
-
putWhere
public INDArray putWhere(Number comp, INDArray put, Condition condition)
Description copied from interface:INDArray
Assign the element according to the comparison array
-
putWhere
public INDArray putWhere(Number comp, Number put, Condition condition)
Description copied from interface:INDArray
Assign the element according to the comparison array
-
putWhereWithMask
public INDArray putWhereWithMask(INDArray mask, INDArray put)
Description copied from interface:INDArray
Use a pre computed mask for assigning arrays- Specified by:
putWhereWithMask
in interfaceINDArray
- Parameters:
mask
- the mask to useput
- the array to put- Returns:
- a copy of this array with the conditional assignments.
-
putWhereWithMask
public INDArray putWhereWithMask(INDArray mask, Number put)
Description copied from interface:INDArray
Use a pre computed mask for assigning arrays- Specified by:
putWhereWithMask
in interfaceINDArray
- Parameters:
mask
- the mask to useput
- the array to put- Returns:
- a copy of this array with the conditional assignments.
-
put
public INDArray put(int i, int j, INDArray element)
Description copied from interface:INDArray
Inserts the element at the specified index
-
put
public INDArray put(int i, int j, Number element)
Description copied from interface:INDArray
Inserts the element at the specified index
-
putSlice
public INDArray putSlice(int slice, INDArray put)
Description copied from interface:INDArray
Assigns the given matrix (put) to the specified slice
-
assertSlice
protected void assertSlice(INDArray put, long slice)
-
isMatrix
public boolean isMatrix()
Description copied from interface:INDArray
Returns true if this ndarray is a matrix
-
newShape
protected INDArray newShape(long[] newShape, char ordering)
-
create
protected INDArray create(DataBuffer data, int[] newShape, int[] newStrides, long offset, char ordering)
-
create
protected INDArray create(DataBuffer data, long[] newShape, long[] newStrides, long offset, char ordering)
-
create
protected INDArray create(DataBuffer data, int[] newShape, int[] newStrides, long offset)
-
create
protected INDArray create(int[] shape)
-
create
protected INDArray create(int[] shape, int[] strides, long offset)
-
getStrides
protected int[] getStrides(int[] shape, char ordering)
-
squaredDistance
public double squaredDistance(INDArray other)
Description copied from interface:INDArray
Returns the square of the Euclidean distance.- Specified by:
squaredDistance
in interfaceINDArray
-
distance2
public double distance2(INDArray other)
Description copied from interface:INDArray
Returns the (euclidean) distance.
-
distance1
public double distance1(INDArray other)
Description copied from interface:INDArray
Returns the (1-norm) distance.
-
get
public INDArray get(INDArray indices)
Description copied from interface:INDArray
Get the elements from this ndarray based on the specified indices
-
put
public INDArray put(INDArray indices, INDArray element)
Description copied from interface:INDArray
Put element in to the indices denoted by the indices ndarray. In numpy this is equivalent to: a[indices] = element
-
put
public INDArray put(INDArrayIndex[] indices, INDArray element)
Description copied from interface:INDArray
Put the elements of the ndarray in to the specified indices
-
put
public INDArray put(INDArrayIndex[] indices, Number element)
Description copied from interface:INDArray
Put the elements of the ndarray in to the specified indices
-
swapAxes
public INDArray swapAxes(int dimension, int with)
Description copied from interface:INDArray
Mainly here for people coming from numpy. This is equivalent to a call to permute
-
isView
public boolean isView()
Description copied from interface:INDArray
Check if this array is a view or not.
-
isSparse
public boolean isSparse()
Description copied from interface:INDArray
Check if this array is sparse
-
data
public DataBuffer data()
Description copied from interface:INDArray
Returns a linear double array representation of this ndarray
-
setData
public void setData(DataBuffer data)
Description copied from interface:INDArray
Set the data for this ndarray.
-
slices
public long slices()
Description copied from interface:INDArray
Returns the number of slices in this ndarray
-
create
protected INDArray create(DataBuffer buffer)
-
cond
public INDArray cond(Condition condition)
Description copied from interface:INDArray
Returns a binary INDArray with value 'true' if the element matches the specified condition and 'false' otherwise
-
init
protected void init(int[] shape, int[] stride)
-
init
protected void init(long[] shape, long[] stride)
-
getScalar
public INDArray getScalar(long i)
Description copied from interface:INDArray
Returns the element at the specified index
-
doColumnWise
protected INDArray doColumnWise(INDArray columnVector, char operation)
Do a row wise op (a,s,m,d) a : add s : subtract m : multiply d : divide h : reverse subtraction t : reverse division- Parameters:
columnVector
- the column vectoroperation
- the operation- Returns:
-
doRowWise
protected INDArray doRowWise(INDArray rowVector, char operation)
Do a row wise op (a,s,m,d) a : add s : subtract m : multiply d : divide h : reverse subtraction t : reverse division- Parameters:
rowVector
- the row vectoroperation
- the operation- Returns:
-
shapeOf
protected DataBuffer shapeOf()
-
strideOf
protected DataBuffer strideOf()
-
stride
public int stride(int dimension)
Description copied from interface:INDArray
Calculate the stride along a particular dimension
-
rdiviColumnVector
public INDArray rdiviColumnVector(INDArray columnVector)
Description copied from interface:INDArray
In place reverse divison of a column vector- Specified by:
rdiviColumnVector
in interfaceINDArray
- Parameters:
columnVector
- the column vector used for division- Returns:
- the result of the division
-
rdivColumnVector
public INDArray rdivColumnVector(INDArray columnVector)
Description copied from interface:INDArray
Reverse division of a column vector (copy)- Specified by:
rdivColumnVector
in interfaceINDArray
- Parameters:
columnVector
- the column vector used for division- Returns:
- the result of the division
-
rdiviRowVector
public INDArray rdiviRowVector(INDArray rowVector)
Description copied from interface:INDArray
In place reverse division of a column vector- Specified by:
rdiviRowVector
in interfaceINDArray
- Parameters:
rowVector
- the row vector used for division- Returns:
- the result of the division
-
rdivRowVector
public INDArray rdivRowVector(INDArray rowVector)
Description copied from interface:INDArray
Reverse division of a column vector (copy)- Specified by:
rdivRowVector
in interfaceINDArray
- Parameters:
rowVector
- the row vector used for division- Returns:
- the result of the division
-
rsubiColumnVector
public INDArray rsubiColumnVector(INDArray columnVector)
Description copied from interface:INDArray
In place reverse subtraction of a column vector- Specified by:
rsubiColumnVector
in interfaceINDArray
- Parameters:
columnVector
- the column vector to subtract- Returns:
- the result of the subtraction
-
rsubColumnVector
public INDArray rsubColumnVector(INDArray columnVector)
Description copied from interface:INDArray
Reverse subtraction of a column vector (copy)- Specified by:
rsubColumnVector
in interfaceINDArray
- Parameters:
columnVector
- the column vector to subtract- Returns:
- the result of the subtraction
-
rsubiRowVector
public INDArray rsubiRowVector(INDArray rowVector)
Description copied from interface:INDArray
In place reverse subtraction of a row vector- Specified by:
rsubiRowVector
in interfaceINDArray
- Parameters:
rowVector
- the row vector to subtract- Returns:
- the result of the subtraction
-
rsubRowVector
public INDArray rsubRowVector(INDArray rowVector)
Description copied from interface:INDArray
Reverse subtraction of a row vector (copy)- Specified by:
rsubRowVector
in interfaceINDArray
- Parameters:
rowVector
- the row vector to subtract- Returns:
- the result of the subtraction
-
put
public INDArray put(int i, INDArray element)
Description copied from interface:INDArray
Inserts the element at the specified index
-
diviColumnVector
public INDArray diviColumnVector(INDArray columnVector)
Description copied from interface:INDArray
In place division of a column vector- Specified by:
diviColumnVector
in interfaceINDArray
- Parameters:
columnVector
- the column vector used for division- Returns:
- the result of the division
-
divColumnVector
public INDArray divColumnVector(INDArray columnVector)
Description copied from interface:INDArray
Division of a column vector (copy)- Specified by:
divColumnVector
in interfaceINDArray
- Parameters:
columnVector
- the column vector used for division- Returns:
- the result of the division
-
diviRowVector
public INDArray diviRowVector(INDArray rowVector)
Description copied from interface:INDArray
In place division of a row vector- Specified by:
diviRowVector
in interfaceINDArray
- Parameters:
rowVector
- the row vector used for division- Returns:
- the result of the division
-
divRowVector
public INDArray divRowVector(INDArray rowVector)
Description copied from interface:INDArray
Division of a row vector (copy)- Specified by:
divRowVector
in interfaceINDArray
- Parameters:
rowVector
- the row vector used for division- Returns:
- the result of the division
-
muliColumnVector
public INDArray muliColumnVector(INDArray columnVector)
Description copied from interface:INDArray
In place multiplication of a column vector- Specified by:
muliColumnVector
in interfaceINDArray
- Parameters:
columnVector
- the column vector used for multiplication- Returns:
- the result of the multiplication
-
mulColumnVector
public INDArray mulColumnVector(INDArray columnVector)
Description copied from interface:INDArray
Multiplication of a column vector (copy)- Specified by:
mulColumnVector
in interfaceINDArray
- Parameters:
columnVector
- the column vector used for multiplication- Returns:
- the result of the multiplication
-
muliRowVector
public INDArray muliRowVector(INDArray rowVector)
Description copied from interface:INDArray
In place multiplication of a row vector- Specified by:
muliRowVector
in interfaceINDArray
- Parameters:
rowVector
- the row vector used for multiplication- Returns:
- the result of the multiplication
-
mulRowVector
public INDArray mulRowVector(INDArray rowVector)
Description copied from interface:INDArray
Multiplication of a row vector (copy)- Specified by:
mulRowVector
in interfaceINDArray
- Parameters:
rowVector
- the row vector used for multiplication- Returns:
- the result of the multiplication
-
subiColumnVector
public INDArray subiColumnVector(INDArray columnVector)
Description copied from interface:INDArray
In place subtraction of a column vector- Specified by:
subiColumnVector
in interfaceINDArray
- Parameters:
columnVector
- the column vector to subtract- Returns:
- the result of the subtraction
-
subColumnVector
public INDArray subColumnVector(INDArray columnVector)
Description copied from interface:INDArray
Subtraction of a column vector (copy)- Specified by:
subColumnVector
in interfaceINDArray
- Parameters:
columnVector
- the column vector to subtract- Returns:
- the result of the subtraction
-
subiRowVector
public INDArray subiRowVector(INDArray rowVector)
Description copied from interface:INDArray
In place subtraction of a row vector- Specified by:
subiRowVector
in interfaceINDArray
- Parameters:
rowVector
- the row vector to subtract- Returns:
- the result of the subtraction
-
subRowVector
public INDArray subRowVector(INDArray rowVector)
Description copied from interface:INDArray
Subtraction of a row vector (copy)- Specified by:
subRowVector
in interfaceINDArray
- Parameters:
rowVector
- the row vector to subtract- Returns:
- the result of the subtraction
-
addiColumnVector
public INDArray addiColumnVector(INDArray columnVector)
Description copied from interface:INDArray
In place addition of a column vector- Specified by:
addiColumnVector
in interfaceINDArray
- Parameters:
columnVector
- the column vector to add- Returns:
- the result of the addition
-
putiColumnVector
public INDArray putiColumnVector(INDArray columnVector)
Description copied from interface:INDArray
In place assignment of a column vector- Specified by:
putiColumnVector
in interfaceINDArray
- Parameters:
columnVector
- the column vector to add- Returns:
- the result of the addition
-
addColumnVector
public INDArray addColumnVector(INDArray columnVector)
Description copied from interface:INDArray
Addition of a column vector (copy)- Specified by:
addColumnVector
in interfaceINDArray
- Parameters:
columnVector
- the column vector to add- Returns:
- the result of the addition
-
addiRowVector
public INDArray addiRowVector(INDArray rowVector)
Description copied from interface:INDArray
In place addition of a row vector- Specified by:
addiRowVector
in interfaceINDArray
- Parameters:
rowVector
- the row vector to add- Returns:
- the result of the addition
-
putiRowVector
public INDArray putiRowVector(INDArray rowVector)
Description copied from interface:INDArray
in place assignment of row vector, to each row of this array- Specified by:
putiRowVector
in interfaceINDArray
- Parameters:
rowVector
- Row vector to put- Returns:
- This array, after assigning every road to the specified value
-
addRowVector
public INDArray addRowVector(INDArray rowVector)
Description copied from interface:INDArray
Addition of a row vector (copy)- Specified by:
addRowVector
in interfaceINDArray
- Parameters:
rowVector
- the row vector to add- Returns:
- the result of the addition
-
mmul
public INDArray mmul(INDArray other, INDArray result, MMulTranspose mMulTranspose)
Description copied from interface:INDArray
Perform an copy matrix multiplication
-
mmul
public INDArray mmul(INDArray other, MMulTranspose mMulTranspose)
Description copied from interface:INDArray
Perform a copy matrix multiplication
-
mmul
public INDArray mmul(INDArray other, char resultOrder)
Description copied from interface:INDArray
Perform a copy matrix multiplication
-
mmul
public INDArray mmul(INDArray other)
Description copied from interface:INDArray
Perform a copy matrix multiplication
-
create
protected INDArray create(int[] shape, char ordering)
-
toDoubleMatrix
public double[][] toDoubleMatrix()
Description copied from interface:INDArray
Convert this ndarray to a 2d double matrix. Note that THIS SHOULD NOT BE USED FOR SPEED. This is mainly used for integrations with other libraries. Due to nd4j's off heap nature, moving data on heap is very expensive and should not be used if possible.- Specified by:
toDoubleMatrix
in interfaceINDArray
- Returns:
- a copy of this array as a 2d double array
-
toDoubleVector
public double[] toDoubleVector()
Description copied from interface:INDArray
Convert this ndarray to a 1d double matrix. Note that THIS SHOULD NOT BE USED FOR SPEED. This is mainly used for integrations with other libraries. Due to nd4j's off heap nature, moving data on heap is very expensive and should not be used if possible.- Specified by:
toDoubleVector
in interfaceINDArray
- Returns:
- a copy of this array as a 1d double array
-
toFloatVector
public float[] toFloatVector()
Description copied from interface:INDArray
Convert this ndarray to a 1d float vector. Note that THIS SHOULD NOT BE USED FOR SPEED. This is mainly used for integrations with other libraries. Due to nd4j's off heap nature, moving data on heap is very expensive and should not be used if possible.- Specified by:
toFloatVector
in interfaceINDArray
- Returns:
- a copy of this array as a 1d float array
-
toFloatMatrix
public float[][] toFloatMatrix()
Description copied from interface:INDArray
Convert this ndarray to a 2d float matrix. Note that THIS SHOULD NOT BE USED FOR SPEED. This is mainly used for integrations with other libraries. Due to nd4j's off heap nature, moving data on heap is very expensive and should not be used if possible.- Specified by:
toFloatMatrix
in interfaceINDArray
- Returns:
- a copy of this array as a 2d float array
-
toIntVector
public int[] toIntVector()
Description copied from interface:INDArray
Convert this ndarray to a 1d int matrix. Note that THIS SHOULD NOT BE USED FOR SPEED. This is mainly used for integrations with other libraries. Due to nd4j's off heap nature, moving data on heap is very expensive and should not be used if possible.- Specified by:
toIntVector
in interfaceINDArray
- Returns:
- a copy of this array as a 1d int array
-
toLongVector
public long[] toLongVector()
Description copied from interface:INDArray
Convert this ndarray to a 1d long matrix. Note that THIS SHOULD NOT BE USED FOR SPEED. This is mainly used for integrations with other libraries. Due to nd4j's off heap nature, moving data on heap is very expensive and should not be used if possible.- Specified by:
toLongVector
in interfaceINDArray
- Returns:
- a copy of this array as a 1d long array
-
toLongMatrix
public long[][] toLongMatrix()
Description copied from interface:INDArray
Convert this ndarray to a 2d int matrix. Note that THIS SHOULD NOT BE USED FOR SPEED. This is mainly used for integrations with other libraries. Due to nd4j's off heap nature, moving data on heap is very expensive and should not be used if possible.- Specified by:
toLongMatrix
in interfaceINDArray
- Returns:
- a copy of this array as a 2d int array
-
toIntMatrix
public int[][] toIntMatrix()
Description copied from interface:INDArray
Convert this ndarray to a 2d int matrix. Note that THIS SHOULD NOT BE USED FOR SPEED. This is mainly used for integrations with other libraries. Due to nd4j's off heap nature, moving data on heap is very expensive and should not be used if possible.- Specified by:
toIntMatrix
in interfaceINDArray
- Returns:
- a copy of this array as a 2d int array
-
div
public INDArray div(INDArray other)
Description copied from interface:INDArray
Copy (element wise) division of two NDArrays
-
div
public INDArray div(INDArray other, INDArray result)
Description copied from interface:INDArray
copy (element wise) division of two NDArrays
-
mul
public INDArray mul(INDArray other)
Description copied from interface:INDArray
copy (element wise) multiplication of two NDArrays
-
mul
public INDArray mul(INDArray other, INDArray result)
Description copied from interface:INDArray
copy (element wise) multiplication of two NDArrays
-
sub
public INDArray sub(INDArray other)
Description copied from interface:INDArray
copy subtraction of two NDArrays
-
sub
public INDArray sub(INDArray other, INDArray result)
Description copied from interface:INDArray
copy subtraction of two NDArrays
-
add
public INDArray add(INDArray other)
Description copied from interface:INDArray
Element-wise copy addition of two NDArrays
-
add
public INDArray add(INDArray other, INDArray result)
Description copied from interface:INDArray
Element-wise copy addition of two NDArrays
-
mmuli
public INDArray mmuli(INDArray other, MMulTranspose transpose)
Description copied from interface:INDArray
Perform an copy matrix multiplication
-
mmuli
public INDArray mmuli(INDArray other)
Description copied from interface:INDArray
Perform an inplace matrix multiplication
-
mmuli
public INDArray mmuli(INDArray other, INDArray result, MMulTranspose transpose)
Description copied from interface:INDArray
Perform an in place matrix multiplication
-
mmuli
public INDArray mmuli(INDArray other, INDArray result)
Description copied from interface:INDArray
Perform an inplace matrix multiplication
-
divi
public INDArray divi(INDArray other)
Description copied from interface:INDArray
in place (element wise) division of two NDArrays
-
divi
public INDArray divi(INDArray other, INDArray result)
Description copied from interface:INDArray
in place (element wise) division of two NDArrays
-
muli
public INDArray muli(INDArray other)
Description copied from interface:INDArray
in place (element wise) multiplication of two NDArrays
-
muli
public INDArray muli(INDArray other, INDArray result)
Description copied from interface:INDArray
in place (element wise) multiplication of two NDArrays
-
subi
public INDArray subi(INDArray other)
Description copied from interface:INDArray
in place (element wise) subtraction of two NDArrays
-
addi
public INDArray addi(INDArray other)
Description copied from interface:INDArray
in place (element wise) addition of two NDArrays
-
addi
public INDArray addi(INDArray other, INDArray result)
Description copied from interface:INDArray
in place (element wise) addition of two NDArrays
-
normmax
public INDArray normmax(boolean keepDims, int... dimension)
Description copied from interface:INDArray
Returns the max norm (aka infinity norm, equal to the maximum absolute value) along the specified dimension(s)
-
normmax
public INDArray normmax(int... dimension)
Description copied from interface:INDArray
Returns the max norm (aka infinity norm, equal to the maximum absolute value) along the specified dimension(s)
-
rdiv
public INDArray rdiv(INDArray other)
Description copied from interface:INDArray
Reverse division, elements wise. i.e., other / this
-
rdivi
public INDArray rdivi(INDArray other)
Description copied from interface:INDArray
Reverse divsion (in place). i.e., other / this
-
rdiv
public INDArray rdiv(INDArray other, INDArray result)
Description copied from interface:INDArray
Reverse division
-
rdivi
public INDArray rdivi(INDArray other, INDArray result)
Description copied from interface:INDArray
Reverse division (in-place)
-
rsub
public INDArray rsub(INDArray other, INDArray result)
Description copied from interface:INDArray
Reverse subtraction
-
rsub
public INDArray rsub(INDArray other)
Description copied from interface:INDArray
Element-wise reverse subtraction (copy op). i.e., other - this
-
rsubi
public INDArray rsubi(INDArray other)
Description copied from interface:INDArray
Element-wise reverse subtraction (in the place op) - i.e., other - this
-
rsubi
public INDArray rsubi(INDArray other, INDArray result)
Description copied from interface:INDArray
Reverse subtraction (in-place)
-
assign
public INDArray assign(Number value)
Description copied from interface:INDArray
Set all entries of the ndarray to the specified value
-
assign
public INDArray assign(boolean value)
Description copied from interface:INDArray
Set all entries of the ndarray to the specified value
-
assignIf
public INDArray assignIf(INDArray arr, Condition condition)
Description copied from interface:INDArray
Assign all elements from given ndarray that are matching given condition, ndarray to this ndarray
-
replaceWhere
public INDArray replaceWhere(INDArray arr, Condition condition)
Description copied from interface:INDArray
Replaces all elements in this ndarray that are matching give condition, with corresponding elements from given array- Specified by:
replaceWhere
in interfaceINDArray
- Parameters:
arr
- Source arraycondition
- Condition to apply- Returns:
- New array with values conditionally replaced
-
linearIndex
@Deprecated public long linearIndex(long i)
Deprecated.Description copied from interface:INDArray
Get the linear index of the data in to the array- Specified by:
linearIndex
in interfaceINDArray
- Parameters:
i
- the index to getScalar- Returns:
- the linear index in to the data
-
slice
public INDArray slice(long slice)
Description copied from interface:INDArray
Returns the specified slice of this ndarray
-
createScalarForIndex
protected INDArray createScalarForIndex(long i, boolean applyOffset)
-
createScalar
protected INDArray createScalar(double d)
-
getTrailingOnes
public int getTrailingOnes()
Description copied from interface:INDArray
Get the number of trailing ones in the array shape. For example, a rank 3 array with shape [10, 1, 1] would return 2 for this method- Specified by:
getTrailingOnes
in interfaceINDArray
- Returns:
- Number of trailing ones in shape
-
getLeadingOnes
public int getLeadingOnes()
Description copied from interface:INDArray
Get the number of leading ones in the array shape. For example, a rank 3 array with shape [1, 10, 1] would return value 1 for this method- Specified by:
getLeadingOnes
in interfaceINDArray
- Returns:
- Number of leading ones in shape
-
slice
public INDArray slice(long slice, int dimension)
Description copied from interface:INDArray
Returns the slice of this from the specified dimension
-
getScalar
public INDArray getScalar(int[] indexes)
Description copied from interface:INDArray
Returns the elements at the specified indices
-
rdiv
public INDArray rdiv(Number n)
Description copied from interface:INDArray
Reverse division with a scalar - i.e., (n / thisArrayValues)
-
rdivi
public INDArray rdivi(Number n)
Description copied from interface:INDArray
In place reverse division - i.e., (n / thisArrayValues)
-
rsub
public INDArray rsub(Number n)
Description copied from interface:INDArray
Reverse subtraction with duplicates - i.e., (n - thisArrayValues)
-
rsubi
public INDArray rsubi(Number n)
Description copied from interface:INDArray
Reverse subtraction in place - i.e., (n - thisArrayValues)
-
divi
public INDArray divi(Number n)
Description copied from interface:INDArray
In place scalar division
-
mul
public INDArray mul(Number n)
Description copied from interface:INDArray
Scalar multiplication (copy)
-
muli
public INDArray muli(Number n)
Description copied from interface:INDArray
In place scalar multiplication
-
sub
public INDArray sub(Number n)
Description copied from interface:INDArray
Scalar subtraction (copied)
-
subi
public INDArray subi(Number n)
Description copied from interface:INDArray
In place scalar subtraction
-
add
public INDArray add(Number n)
Description copied from interface:INDArray
Scalar addition (cloning)
-
addi
public INDArray addi(Number n)
Description copied from interface:INDArray
In place scalar addition
-
repmat
public INDArray repmat(long[] shape)
Description copied from interface:INDArray
Replicate and tile array to fill out to the given shape See: https://github.com/numpy/numpy/blob/master/numpy/matlib.py#L310-L358
-
repmat
@Deprecated public INDArray repmat(int[] shape)
Deprecated.
-
repeat
public INDArray repeat(int dimension, long... repeats)
Description copied from interface:INDArray
Repeat elements along a specified dimension.
-
putRow
public INDArray putRow(long row, INDArray toPut)
Description copied from interface:INDArray
Insert a row in to this array Will throw an exception if this ndarray is not a matrix
-
putColumn
public INDArray putColumn(int column, INDArray toPut)
Description copied from interface:INDArray
Insert a column in to this array Will throw an exception if this ndarray is not a matrix
-
getNumber
public Number getNumber(long i)
Description copied from interface:INDArray
Get the numeric value at the specified index.
-
getNumber
public Number getNumber(long... idx)
Description copied from interface:INDArray
Get a numeric value at the specified indices.
-
getDouble
public double getDouble(long i)
Description copied from interface:INDArray
Get the double value at the specified linear index in the array
-
getDouble
public double getDouble(long i, long j)
Description copied from interface:INDArray
Get the double value at the specified indices. Can only be used for 2D (rank 2) arrays.
-
getFloat
public float getFloat(long i)
Description copied from interface:INDArray
Return the item at the linear index i
-
getFloat
public float getFloat(long i, long j)
Description copied from interface:INDArray
Return the item at row i column j Note that this is the same as calling getScalar(new int[]{i,j}
-
transpose
public INDArray transpose()
Description copied from interface:INDArray
Flip the rows and columns of a matrix
-
transposei
public INDArray transposei()
Return transposed version of this matrix. PLEASE NOTE: This method is NOT in place, it will return transposed copy instead.- Specified by:
transposei
in interfaceINDArray
- Returns:
- the flipped rows and columns of a matrix
-
create
protected INDArray create(DataBuffer data, int[] shape, int[] strides)
-
reshape
@Deprecated public INDArray reshape(char order, int... newShape)
Deprecated.Description copied from interface:INDArray
Reshapes the ndarray (can't change the length of the ndarray). Typically this will be a view, unless reshaping without copying is impossible.
-
reshape
public INDArray reshape(char order, long... newShape)
Description copied from interface:INDArray
Reshapes the ndarray (can't change the length of the ndarray). Typically this will be a view, unless reshaping without copying is impossible.
-
reshape
public INDArray reshape(char order, boolean enforceView, long... newShape)
Description copied from interface:INDArray
Reshapes the ndarray (note: it's not possible to change the length of the ndarray). Typically this will be a view, unless reshaping without copying (i.e., returning a view) is impossible.
In that case, the behaviour will depend on the enforceView argument: enforceView == true: throw an exception
enforceView == false: return a copy
-
getDoubleUnsafe
public double getDoubleUnsafe(long offset)
Description copied from interface:INDArray
Get a double at the given linear offset unsafe, without checks.- Specified by:
getDoubleUnsafe
in interfaceINDArray
- Parameters:
offset
- the offset to get at- Returns:
- double value at offset
-
putScalarUnsafe
public INDArray putScalarUnsafe(long offset, double value)
Description copied from interface:INDArray
Insert a scalar at the given linear offset- Specified by:
putScalarUnsafe
in interfaceINDArray
- Parameters:
offset
- the offset to insert atvalue
- the value to insert- Returns:
- this
-
reshape
public INDArray reshape(char order, int rows, int columns)
Description copied from interface:INDArray
Reshapes the ndarray (can't change the length of the ndarray). Typically this will be a view, unless reshaping without copying is impossible.
-
reshape
public INDArray reshape(int[] shape)
Reshape the ndarray in to the specified dimensions, possible errors being thrown for invalid shapes Note here that one dimension can be -1. The dimension that is -1 will be inferred from the shape and the length of the ndarray
-
reshape
public INDArray reshape(long... shape)
Description copied from interface:INDArray
Reshapes the ndarray (can't change the length of the ndarray). Typically this will be a view, unless reshaping without copying is impossible.
-
prod
public INDArray prod(boolean keepDims, int... dimension)
Description copied from interface:INDArray
Returns the product along a given dimension
-
prod
public INDArray prod(int... dimension)
Description copied from interface:INDArray
Returns the product along a given dimension
-
mean
public INDArray mean(boolean keepDims, int... dimension)
Description copied from interface:INDArray
Returns the overall mean of this ndarray
-
mean
public INDArray mean(int... dimension)
Description copied from interface:INDArray
Returns the overall mean of this ndarray
-
amean
public INDArray amean(int... dimension)
Description copied from interface:INDArray
Returns the absolute overall mean of this ndarray
-
mean
public INDArray mean(@NonNull @NonNull INDArray result, boolean keepDims, int... dimension)
Description copied from interface:INDArray
Returns the overall mean of this ndarray
-
mean
public INDArray mean(@NonNull @NonNull INDArray result, int... dimension)
Description copied from interface:INDArray
Returns the overall mean of this ndarray
-
var
public INDArray var(int... dimension)
Description copied from interface:INDArray
Returns the overall variance of this ndarray
-
var
public INDArray var(boolean biasCorrected, int... dimension)
Description copied from interface:INDArray
Returns the overall variance of this ndarray
-
max
public INDArray max(boolean keepDims, int... dimension)
Description copied from interface:INDArray
Returns the overall max of this ndarray along given dimensions
-
max
public INDArray max(int... dimension)
Description copied from interface:INDArray
Returns the overall max of this ndarray along given dimensions
-
amax
public INDArray amax(int... dimension)
Description copied from interface:INDArray
Returns the absolute overall max of this ndarray along given dimensions
-
min
public INDArray min(boolean keepDims, int... dimension)
Description copied from interface:INDArray
Returns the overall min of this ndarray
-
min
public INDArray min(int... dimension)
Description copied from interface:INDArray
Returns the overall min of this ndarray
-
amin
public INDArray amin(int... dimension)
Description copied from interface:INDArray
Returns minimum (absolute) value in this INDArray, along the specified dimensions
-
sum
public INDArray sum(int... dimension)
Description copied from interface:INDArray
Returns the sum along the last dimension of this ndarray
-
sum
public INDArray sum(boolean keepDim, int... dimension)
Description copied from interface:INDArray
Returns the sum along the last dimension of this ndarray
-
entropy
public INDArray entropy(int... dimension)
Description copied from interface:INDArray
Returns entropy value for this INDArray along specified dimension(s)
-
shannonEntropy
public INDArray shannonEntropy(int... dimension)
Description copied from interface:INDArray
Returns Shannon entropy value for this INDArray along specified dimension(s)- Specified by:
shannonEntropy
in interfaceINDArray
- Parameters:
dimension
- specified dimension(s)- Returns:
- Shannon entropy
-
logEntropy
public INDArray logEntropy(int... dimension)
Description copied from interface:INDArray
Returns log entropy value for this INDArray along specified dimension(s)- Specified by:
logEntropy
in interfaceINDArray
- Parameters:
dimension
- specified dimension(s)- Returns:
- log entropy value
-
sum
public INDArray sum(@NonNull @NonNull INDArray result, boolean keepDims, int... dimension)
Description copied from interface:INDArray
Returns the sum along the last dimension of this ndarray
-
sum
public INDArray sum(@NonNull @NonNull INDArray result, int... dimension)
Description copied from interface:INDArray
Returns the sum along the last dimension of this ndarray
-
norm1
public INDArray norm1(int... dimension)
Description copied from interface:INDArray
Returns the norm1 (L1 norm, i.e., sum of absolute values; also known as Taxicab or Manhattan norm) along the specified dimension
-
norm1
public INDArray norm1(boolean keepDims, int... dimension)
Description copied from interface:INDArray
Returns the norm1 (L1 norm, i.e., sum of absolute values; also known as Taxicab or Manhattan norm) along the specified dimension
-
std
public INDArray std(int... dimension)
Description copied from interface:INDArray
Standard deviation of an INDArray along one or more dimensions
-
std
public INDArray std(boolean biasCorrected, int... dimension)
Description copied from interface:INDArray
Standard deviation of an ndarray along a dimension
-
std
public INDArray std(boolean biasCorrected, boolean keepDims, int... dimension)
Description copied from interface:INDArray
Standard deviation of an ndarray along a dimension
-
stdNumber
public Number stdNumber(boolean biasCorrected)
Description copied from interface:INDArray
Calculate the standard deviation for the entire array, specifying whether it is bias corrected or not
-
norm2
public INDArray norm2(boolean keepDims, int... dimension)
Description copied from interface:INDArray
Returns the norm2 (L2 norm, sqrt(sum(x_i^2), also known as Euclidean norm) along the specified dimension(s)
-
norm2
public INDArray norm2(int... dimension)
Description copied from interface:INDArray
Returns the norm2 (L2 norm, sqrt(sum(x_i^2), also known as Euclidean norm) along the specified dimension(s)
-
columns
public int columns()
Description copied from interface:INDArray
Returns the number of columns in this matrix (throws exception if not 2d)
-
rows
public int rows()
Description copied from interface:INDArray
Returns the number of rows in this matrix (throws exception if not 2d)
-
ravel
public INDArray ravel(char ordering)
Description copied from interface:INDArray
Returns a flattened version (row vector) of this ndarray
-
ravel
public INDArray ravel()
Description copied from interface:INDArray
Returns a flattened version (row vector) of this ndarray
-
sliceVectors
public void sliceVectors(List<INDArray> list)
Description copied from interface:INDArray
Flattens the array for linear indexing in list.- Specified by:
sliceVectors
in interfaceINDArray
-
reshape
public INDArray reshape(long newRows, long newColumns)
Description copied from interface:INDArray
Reshapes the ndarray (can't change the length of the ndarray). Typically this will be a view, unless reshaping without copying is impossible.
-
getColumn
public INDArray getColumn(long c)
Description copied from interface:INDArray
Returns the specified column. Throws an exception if its not a matrix
-
getColumn
public INDArray getColumn(long c, boolean keepDim)
Description copied from interface:INDArray
Returns the specified column. Throws an exception if its not a matrix (rank 2). Returned array will either be 1D (keepDim = false) or 2D (keepDim = true) with shape [length, 1]
-
getRows
public INDArray getRows(int[] rindices)
Description copied from interface:INDArray
Get an INDArray comprised of the specified rows only. Copy operation
-
get
public INDArray get(INDArrayIndex... indexes)
Description copied from interface:INDArray
Returns a subset of this array based on the specified indexes
-
getColumns
public INDArray getColumns(int... cindices)
Description copied from interface:INDArray
Get an INDArray comprised of the specified columns only. Copy operation.- Specified by:
getColumns
in interfaceINDArray
- Parameters:
cindices
- Columns to extract out of the current array- Returns:
- Array with only the specified columns
-
create
protected INDArray create(int rows, int length)
-
getRow
public INDArray getRow(long r)
Description copied from interface:INDArray
Returns the specified row as a 1D vector. Throws an exception if its not a matrix
-
getRow
public INDArray getRow(long r, boolean keepDim)
Description copied from interface:INDArray
Returns the specified row. Throws an exception if its not a matrix. Returned array will either be 1D (keepDim = false) or 2D (keepDim = true) with shape [1, length]
-
equalsWithEps
public boolean equalsWithEps(Object o, double eps)
Description copied from interface:INDArray
This method checks 2 INDArrays equality with given eps- Specified by:
equalsWithEps
in interfaceINDArray
- Parameters:
o
- INDArray to compare against.eps
- Epsilon value to use for the quality operation- Returns:
- True if ndarrays are equal within eps.
-
equalShapes
public boolean equalShapes(@NonNull @NonNull INDArray other)
Description copied from interface:INDArray
This method checks 2 INDArrays for equal shapes.
Shapes are considered equal if:
(a) Both arrays have equal rank, and
(b) size(0)...size(rank()-1) are equal for both arrays- Specified by:
equalShapes
in interfaceINDArray
- Parameters:
other
- Other- Returns:
- True if shap
-
equals
public boolean equals(Object o)
Compare two matrices. Returns true if and only if other is also a DoubleMatrix which has the same size and the maximal absolute difference in matrix elements is smaller than 1e-5.
-
shapeInfoDataBuffer
public DataBuffer shapeInfoDataBuffer()
Description copied from interface:INDArray
Shape info- Specified by:
shapeInfoDataBuffer
in interfaceINDArray
- Returns:
- Shape info
-
shapeInfo
public LongBuffer shapeInfo()
Description copied from interface:INDArray
Shape info
-
shape
public long[] shape()
Description copied from interface:INDArray
Returns the shape of this ndarray
-
shapeInfoToString
public String shapeInfoToString()
Description copied from interface:INDArray
Returns the shape information debugging information- Specified by:
shapeInfoToString
in interfaceINDArray
- Returns:
- the shape information.
-
stride
public long[] stride()
Description copied from interface:INDArray
Returns the stride of this ndarray
-
offset
public long offset()
Description copied from interface:INDArray
Returns the start of where the ndarray is for the underlying data
-
ordering
public char ordering()
Description copied from interface:INDArray
Return the ordering (fortran or c 'f' and 'c' respectively) of this ndarray
-
size
public long size(int dimension)
Description copied from interface:INDArray
Returns the size along a specified dimension
-
rank
public int rank()
Description copied from interface:INDArray
Returns the rank of the ndarray (the number of dimensions).
-
length
public long length()
Description copied from interface:INDArray
Returns the total number of elements in the ndarray
-
broadcast
public INDArray broadcast(INDArray result)
Description copied from interface:INDArray
Broadcasts this ndarray to be the specified shape
-
broadcast
public INDArray broadcast(long... shape)
Description copied from interface:INDArray
Broadcasts this ndarray to be the specified shape
-
dimShuffle
@Deprecated public INDArray dimShuffle(Object[] rearrange, int[] newOrder, boolean[] broadCastable)
Deprecated.Description copied from interface:INDArray
Dimshuffle: an extension of permute that adds the ability to broadcast various dimensions. This will only accept integers and xs. An x indicates a dimension should be broadcasted rather than permuted. Examples originally from the theano docs: http://deeplearning.net/software/theano/library/tensor/basic.html Returns a view of this tensor with permuted dimensions. Typically the pattern will include the integers 0, 1, ... ndim-1, and any number of 'x' characters in dimensions where this tensor should be broadcasted. A few examples of patterns and their effect: ('x') -> make a 0d (scalar) into a 1d vector (0, 1) -> identity for 2d vectors (1, 0) -> inverts the first and second dimensions ('x', 0) -> make a row out of a 1d vector (N to 1xN) (0, 'x') -> make a column out of a 1d vector (N to Nx1) (2, 0, 1) -> AxBxC to CxAxB (0, 'x', 1) -> AxB to Ax1xB (1, 'x', 0) -> AxB to Bx1xA (1,) -> This remove dimensions 0. It must be a broadcastable dimension (1xA to A)- Specified by:
dimShuffle
in interfaceINDArray
- Parameters:
rearrange
- the dimensions to swap tonewOrder
- the new order (think permute)broadCastable
- (whether the dimension is broadcastable) (must be same length as new order)- Returns:
- the newly permuted array
-
dimShuffle
public INDArray dimShuffle(Object[] rearrange, long[] newOrder, boolean[] broadCastable)
Dimshuffle: an extension of permute that adds the ability to broadcast various dimensions. See theano for more examples. This will only accept integers and xs. An x indicates a dimension should be broadcasted rather than permuted.- Specified by:
dimShuffle
in interfaceINDArray
- Parameters:
rearrange
- the dimensions to swap to- Returns:
- the newly permuted array
-
permute
public INDArray permute(int... rearrange)
Description copied from interface:INDArray
See: http://www.mathworks.com/help/matlab/ref/permute.html
-
permutei
public INDArray permutei(int... rearrange)
Description copied from interface:INDArray
An in-place version of permute. The array shape information (shape, strides) is modified by this operation (but not the data itself) See: http://www.mathworks.com/help/matlab/ref/permute.html
-
doPermuteSwap
@Deprecated protected long[] doPermuteSwap(LongBuffer shape, int[] rearrange)
Deprecated.
-
doPermuteSwap
@Deprecated protected int[] doPermuteSwap(IntBuffer shape, int[] rearrange)
Deprecated.
-
doPermuteSwap
@Deprecated protected int[] doPermuteSwap(DataBuffer shape, int[] rearrange)
Deprecated.
-
doPermuteSwap
protected long[] doPermuteSwap(long[] shape, int[] rearrange)
-
checkArrangeArray
protected void checkArrangeArray(int[] arr)
-
autoProcessScalarCall
protected void autoProcessScalarCall()
-
isVector
public boolean isVector()
Checks whether the matrix is a vector.
-
isVectorOrScalar
public boolean isVectorOrScalar()
Description copied from interface:INDArray
Returns true if this ndarray is a vector or scalar- Specified by:
isVectorOrScalar
in interfaceINDArray
- Returns:
- whether this ndarray is a vector or scalar
-
isSquare
public boolean isSquare()
Description copied from interface:INDArray
Returns whether the matrix has the same rows and columns
-
isRowVector
public boolean isRowVector()
Description copied from interface:INDArray
Returns true if the number of rows is 1- Specified by:
isRowVector
in interfaceINDArray
- Returns:
- true if the number of rows is 1
-
isColumnVector
public boolean isColumnVector()
Description copied from interface:INDArray
Returns true if the number of columns is 1- Specified by:
isColumnVector
in interfaceINDArray
- Returns:
- true if the number of columns is 1
-
isColumnVectorOrScalar
public boolean isColumnVectorOrScalar()
Description copied from interface:INDArray
Returns true if the number of columns is 1- Specified by:
isColumnVectorOrScalar
in interfaceINDArray
- Returns:
- true if the number of columns is 1
-
isRowVectorOrScalar
public boolean isRowVectorOrScalar()
Description copied from interface:INDArray
Returns true if the number of rows is 1- Specified by:
isRowVectorOrScalar
in interfaceINDArray
- Returns:
- true if the number of rows is 1
-
toString
public String toString()
Generate string representation of the matrix. Printing will switch to scientific notation on a per element basis - when abs value is greater than or equal to 10000 - when abs value is less than or equal to 0.0001 and not zero If the number of elements in the array is greater than 1000 (by default) only the first and last three elements in a dimension are included. This can be changed globally usingNDArrayStrings#setMaxPrintElements(long)
-
toString
public String toString(@NonNull @NonNull NDArrayStrings options)
Description copied from interface:INDArray
Get a string representation of the array with configurable formatting
-
toString
public String toString(long maxElements, boolean forceSummarize, int precision)
Description copied from interface:INDArray
Get a string representation of the array- Specified by:
toString
in interfaceINDArray
- Parameters:
maxElements
- Summarize if more than maxElements in the arrayforceSummarize
- Force a summary instead of a full printprecision
- The number of decimals to print. Doesn't print trailing 0s if negative- Returns:
- string representation of the array
-
toStringFull
public String toStringFull()
Description copied from interface:INDArray
ToString with unlimited elements and precision- Specified by:
toStringFull
in interfaceINDArray
- See Also:
toString(long, boolean, int)
-
element
public Object element()
Description copied from interface:INDArray
Returns a scalar (individual element) of a scalar ndarray
-
remainder
public INDArray remainder(INDArray denominator)
Description copied from interface:INDArray
Remainder operator
-
remainder
public INDArray remainder(INDArray denominator, INDArray result)
Description copied from interface:INDArray
Remainder operator
-
remainder
public INDArray remainder(Number denominator)
Description copied from interface:INDArray
The scalar remainder
-
remainder
public INDArray remainder(Number denominator, INDArray result)
Description copied from interface:INDArray
The scalar remainder
-
remainderi
public INDArray remainderi(INDArray denominator)
Description copied from interface:INDArray
In place remainder- Specified by:
remainderi
in interfaceINDArray
- Parameters:
denominator
- the denominator- Returns:
- Remainder
-
remainderi
public INDArray remainderi(Number denominator)
Description copied from interface:INDArray
In place remainder- Specified by:
remainderi
in interfaceINDArray
- Parameters:
denominator
- the denominator- Returns:
- Remainder
-
fmod
public INDArray fmod(INDArray denominator)
Description copied from interface:INDArray
remainder of division
-
fmod
public INDArray fmod(INDArray denominator, INDArray result)
Description copied from interface:INDArray
remainder of division
-
fmod
public INDArray fmod(Number denominator)
Description copied from interface:INDArray
remainder of division by scalar.
-
fmod
public INDArray fmod(Number denominator, INDArray result)
Description copied from interface:INDArray
remainder of division by scalar.
-
fmodi
public INDArray fmodi(INDArray denominator)
Description copied from interface:INDArray
In place fmod
-
fmodi
public INDArray fmodi(Number denominator)
Description copied from interface:INDArray
In place fmod
-
originalOffset
public long originalOffset()
Description copied from interface:INDArray
Returns the start of where the ndarray is for the original data buffer- Specified by:
originalOffset
in interfaceINDArray
- Returns:
- original offset.
-
write
protected void write(ObjectOutputStream out) throws IOException
- Throws:
IOException
-
read
protected void read(ObjectInputStream s)
-
argMax
public INDArray argMax(int... dimension)
Description copied from interface:INDArray
This method returns index of highest value along specified dimension(s)
-
isAttached
public boolean isAttached()
Description copied from interface:INDArray
This method returns True, if this INDArray instance is attached to some Workspace. False otherwise.- Specified by:
isAttached
in interfaceINDArray
- Returns:
- True if attached to workspace, false otherwise
-
isInScope
public boolean isInScope()
Description copied from interface:INDArray
This method checks, if given attached INDArray is still in scope of its parent Workspace PLEASE NOTE: if this INDArray isn't attached to any Workspace, this method will return true
-
detach
public INDArray detach()
Description copied from interface:INDArray
This method detaches INDArray from Workspace, returning copy. Basically it's dup() into new memory chunk. PLEASE NOTE: If this INDArray instance is NOT attached - it will be returned unmodified.
-
leverage
public INDArray leverage()
Description copied from interface:INDArray
This method detaches INDArray from current Workspace, and attaches it to Workspace above, if any. PLEASE NOTE: If this INDArray instance is NOT attached - it will be returned unmodified. PLEASE NOTE: If current Workspace is the top-tier one, effect will be equal to detach() call - detached copy will be returned
-
leverageTo
public INDArray leverageTo(String id)
Description copied from interface:INDArray
This method detaches INDArray from current Workspace, and attaches it to Workspace with a given Id - if a workspace with that ID exists. If no workspace with the specified ID exists, the current INDArray is returned unmodified.- Specified by:
leverageTo
in interfaceINDArray
- See Also:
INDArray.leverageTo(String, boolean)
-
leverageTo
public INDArray leverageTo(String id, boolean enforceExistence) throws Nd4jNoSuchWorkspaceException
Description copied from interface:INDArray
This method detaches INDArray from current Workspace, and attaches it to Workspace with a given Id. If enforceExistence == true, and no workspace with the specified ID exists, then anNd4jNoSuchWorkspaceException
is thrown. Otherwise, if enforceExistance == false and no workspace with the specified ID exists, then the current INDArray is returned unmodified (same asINDArray.leverage()
- Specified by:
leverageTo
in interfaceINDArray
- Parameters:
id
- ID of the workspace to leverage toenforceExistence
- If true, and the specified workspace does not exist: anNd4jNoSuchWorkspaceException
will be thrown.- Returns:
- The INDArray, leveraged to the specified workspace
- Throws:
Nd4jNoSuchWorkspaceException
- See Also:
INDArray.leverageTo(String)
-
leverageOrDetach
public INDArray leverageOrDetach(String id)
Description copied from interface:INDArray
This method detaches INDArray from current Workspace, and attaches it to Workspace with a given Id, if a workspace with the given ID is open and active. If the workspace does not exist, or is not active, the array is detached from any workspaces.- Specified by:
leverageOrDetach
in interfaceINDArray
- Parameters:
id
- ID of the workspace to leverage to- Returns:
- The INDArray, leveraged to the specified workspace (if it exists and is active) otherwise the detached array
- See Also:
INDArray.leverageTo(String)
-
migrate
public INDArray migrate()
Description copied from interface:INDArray
This method pulls this INDArray into current Workspace. PLEASE NOTE: If there's no current Workspace - INDArray returned as is- Specified by:
migrate
in interfaceINDArray
- Returns:
- Migrated INDArray or this if no current workspace
- See Also:
INDArray.migrate(boolean)
-
migrate
public INDArray migrate(boolean detachOnNoWs)
Description copied from interface:INDArray
This method pulls this INDArray into current Workspace, or optionally detaches if no workspace is present.
That is:
If current workspace is present/active, INDArray is migrated to it.
If no current workspace is present/active, one of two things occur: 1. If detachOnNoWs arg is true: if there is no current workspace, INDArray is detached 2. If detachOnNoWs arg is false: this INDArray is returned as-is (no-op) - equivalent toINDArray.migrate()
-
percentileNumber
public Number percentileNumber(Number quantile)
Description copied from interface:INDArray
This method returns percentile value for this INDArray- Specified by:
percentileNumber
in interfaceINDArray
- Parameters:
quantile
- target percentile in range of 0..100- Returns:
- percentile value
-
medianNumber
public Number medianNumber()
Description copied from interface:INDArray
This method returns median value for this INDArray- Specified by:
medianNumber
in interfaceINDArray
- Returns:
- Median value for array
-
median
public INDArray median(int... dimension)
Description copied from interface:INDArray
This method returns median along given dimension(s)
-
percentile
public INDArray percentile(Number quantile, int... dimension)
Description copied from interface:INDArray
This method returns percentile along given dimension(s)- Specified by:
percentile
in interfaceINDArray
- Parameters:
quantile
- target percentile in range of 0..100dimension
- Dimension to calculate percentile for- Returns:
- array with percentiles
-
stringBuffer
protected abstract int stringBuffer(com.google.flatbuffers.FlatBufferBuilder builder, DataBuffer buffer)
-
toFlatArray
public int toFlatArray(com.google.flatbuffers.FlatBufferBuilder builder)
Description copied from interface:INDArray
Add anINDArray
to flatbuffers builder- Specified by:
toFlatArray
in interfaceINDArray
- Parameters:
builder
- the builder to use- Returns:
- the offset to add
-
convertType
protected static DataTypeEx convertType(DataType type)
-
isEmpty
public boolean isEmpty()
Description copied from interface:INDArray
This method returns true if this INDArray is special case: no-value INDArray
-
shapeInfoJava
public long[] shapeInfoJava()
Description copied from interface:INDArray
This method returns shapeInformation as jvm long array- Specified by:
shapeInfoJava
in interfaceINDArray
- Returns:
- shapeInformation
-
dataType
public DataType dataType()
Description copied from interface:INDArray
This method returns dtype for this INDArray
-
isR
public boolean isR()
Description copied from interface:INDArray
This method checks if this INDArray instance is one of Real types
-
isZ
public boolean isZ()
Description copied from interface:INDArray
This method checks if this INDArray instance is one of integer types
-
isB
public boolean isB()
Description copied from interface:INDArray
This method checks if this INDArray instance has boolean type
-
isS
public boolean isS()
Description copied from interface:INDArray
This method checks if this INDArray instance has String type
-
castTo
public INDArray castTo(DataType dataType)
Description copied from interface:INDArray
This method cast elements of this INDArray to new data type
-
all
public boolean all()
Description copied from interface:INDArray
This method checks if all elements within this array are non-zero (or true, in case of boolean)
-
any
public boolean any()
Description copied from interface:INDArray
This method checks if any of the elements within this array are non-zero (or true, in case of boolean)
-
none
public boolean none()
Description copied from interface:INDArray
This method checks if any of the elements within this array are non-zero (or true, in case of boolean)
-
validateNumericalArray
protected void validateNumericalArray(String opName, boolean allowEmpty)
Validate that the operation is being applied on a numerical array (not boolean or utf8). Some operations (such as sum, norm2, add(Number) etc don't make sense when applied to boolean/utf8 arrays- Parameters:
opName
- Operation name to print in the exception
-
closeable
public boolean closeable()
Description copied from interface:INDArray
This method checks, if this INDArray instalce can use close() method
-
close
public void close()
Description copied from interface:INDArray
This method releases exclusive off-heap resources uses by this INDArray instance. If INDArray relies on shared resources, exception will be thrown instead PLEASE NOTE: This method is NOT safe by any means- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceINDArray
-
like
public INDArray like()
Description copied from interface:INDArray
This method returns empty array with the same dtype/order/shape as this one
-
ulike
public INDArray ulike()
Description copied from interface:INDArray
This method returns uninitialized array with the same dtype/order/shape as this one
-
wasClosed
public boolean wasClosed()
Description copied from interface:INDArray
This method checks if array or its buffer was closed before
-
getId
public long getId()
Description copied from interface:INDArray
A unique ID for the INDArray object instance. Does not account for views.
-
assignNewId
public void assignNewId()
-
-