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 longarrayIdprotected booleancloseableprotected booleancompressedprotected DataBufferdataprotected JvmShapeInfojvmShapeInfoprotected booleanreleasedprotected DataBuffershapeInformation
-
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 INDArrayadd(Number n)Scalar addition (cloning)INDArrayadd(Number n, INDArray result)Addition of this ndarray.INDArrayadd(INDArray other)Element-wise copy addition of two NDArraysINDArrayadd(INDArray other, INDArray result)Element-wise copy addition of two NDArraysINDArrayaddColumnVector(INDArray columnVector)Addition of a column vector (copy)INDArrayaddi(Number n)In place scalar additionINDArrayaddi(Number n, INDArray result)In place additionINDArrayaddi(INDArray other)in place (element wise) addition of two NDArraysINDArrayaddi(INDArray other, INDArray result)in place (element wise) addition of two NDArraysINDArrayaddiColumnVector(INDArray columnVector)In place addition of a column vectorINDArrayaddiRowVector(INDArray rowVector)In place addition of a row vectorINDArrayaddRowVector(INDArray rowVector)Addition of a row vector (copy)booleanall()This method checks if all elements within this array are non-zero (or true, in case of boolean)INDArrayamax(int... dimension)Returns the absolute overall max of this ndarray along given dimensionsNumberamaxNumber()Returns maximum (absolute) value in this INDArrayINDArrayamean(int... dimension)Returns the absolute overall mean of this ndarrayNumberameanNumber()Returns the absolute overall mean of this ndarrayINDArrayamin(int... dimension)Returns minimum (absolute) value in this INDArray, along the specified dimensionsNumberaminNumber()Returns absolute min value in this INDArraybooleanany()This method checks if any of the elements within this array are non-zero (or true, in case of boolean)INDArrayargMax(int... dimension)This method returns index of highest value along specified dimension(s)protected voidassertSlice(INDArray put, long slice)INDArrayassign(boolean value)Set all entries of the ndarray to the specified valueINDArrayassign(Number value)Set all entries of the ndarray to the specified valueINDArrayassign(INDArray arr)Assign all of the elements in the given ndarray to this ndarrayINDArrayassignIf(INDArray arr, Condition condition)Assign all elements from given ndarray that are matching given condition, ndarray to this ndarrayvoidassignNewId()protected voidautoProcessScalarCall()INDArraybroadcast(long... shape)Broadcasts this ndarray to be the specified shapeINDArraybroadcast(INDArray result)Broadcasts this ndarray to be the specified shapeINDArraycastTo(DataType dataType)This method cast elements of this INDArray to new data typeprotected voidcheckArrangeArray(int[] arr)voidclose()This method releases exclusive off-heap resources uses by this INDArray instance.booleancloseable()This method checks, if this INDArray instalce can use close() methodintcolumns()Returns the number of columns in this matrix (throws exception if not 2d)INDArraycond(Condition condition)Returns a binary INDArray with value 'true' if the element matches the specified condition and 'false' otherwiseprotected static DataTypeExconvertType(DataType type)protected INDArraycreate(int[] shape)protected INDArraycreate(int[] shape, char ordering)protected INDArraycreate(int[] shape, int[] strides, long offset)protected INDArraycreate(int rows, int length)protected INDArraycreate(DataBuffer buffer)protected INDArraycreate(DataBuffer data, int[] shape, int[] strides)protected INDArraycreate(DataBuffer data, int[] newShape, int[] newStrides, long offset)protected INDArraycreate(DataBuffer data, int[] newShape, int[] newStrides, long offset, char ordering)protected INDArraycreate(DataBuffer data, int[] shape, long offset)protected INDArraycreate(DataBuffer data, long[] newShape, long[] newStrides, long offset, char ordering)protected INDArraycreateScalar(double d)protected INDArraycreateScalarForIndex(long i, boolean applyOffset)INDArraycumsum(int dimension)Returns the cumulative sum along a dimension.INDArraycumsumi(int dimension)Returns the cumulative sum along a dimension.DataBufferdata()Returns a linear double array representation of this ndarrayDataTypedataType()This method returns dtype for this INDArrayINDArraydetach()This method detaches INDArray from Workspace, returning copy.INDArraydimShuffle(Object[] rearrange, int[] newOrder, boolean[] broadCastable)Deprecated.INDArraydimShuffle(Object[] rearrange, long[] newOrder, boolean[] broadCastable)Dimshuffle: an extension of permute that adds the ability to broadcast various dimensions.doubledistance1(INDArray other)Returns the (1-norm) distance.doubledistance2(INDArray other)Returns the (euclidean) distance.INDArraydiv(Number n)Division by a numberINDArraydiv(Number n, INDArray result)Division if ndarray by numberINDArraydiv(INDArray other)Copy (element wise) division of two NDArraysINDArraydiv(INDArray other, INDArray result)copy (element wise) division of two NDArraysINDArraydivColumnVector(INDArray columnVector)Division of a column vector (copy)INDArraydivi(Number n)In place scalar divisionINDArraydivi(Number n, INDArray result)In place division of this ndarrayINDArraydivi(INDArray other)in place (element wise) division of two NDArraysINDArraydivi(INDArray other, INDArray result)in place (element wise) division of two NDArraysINDArraydiviColumnVector(INDArray columnVector)In place division of a column vectorINDArraydiviRowVector(INDArray rowVector)In place division of a row vectorINDArraydivRowVector(INDArray rowVector)Division of a row vector (copy)protected INDArraydoColumnWise(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 INDArraydoRowWise(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 divisionINDArraydup()Returns a copy of this ndarrayINDArraydup(char order)Returns a copy of this ndarray, where the returned ndarray has the specified orderObjectelement()Returns a scalar (individual element) of a scalar ndarrayintelementWiseStride()Element wise strideINDArrayentropy(int... dimension)Returns entropy value for this INDArray along specified dimension(s)NumberentropyNumber()Returns entropy value for this INDArrayINDArrayeps(Number other)Returns the binary ndarray for "Epsilon equals" comparison.INDArrayeps(INDArray other)Returns the binary ndarray for "Epsilon equals" comparison.INDArrayeq(Number other)Returns the binary ndarray for "Equals" comparison.INDArrayeq(INDArray other)Returns the binary ndarray for "Equals" comparison.booleanequals(Object o)Compare two matrices.booleanequalShapes(@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 arraysbooleanequalsWithEps(Object o, double eps)This method checks 2 INDArrays equality with given epsINDArrayfmod(Number denominator)remainder of division by scalar.INDArrayfmod(Number denominator, INDArray result)remainder of division by scalar.INDArrayfmod(INDArray denominator)remainder of divisionINDArrayfmod(INDArray denominator, INDArray result)remainder of divisionINDArrayfmodi(Number denominator)In place fmodINDArrayfmodi(INDArray denominator)In place fmodINDArrayget(INDArray indices)Get the elements from this ndarray based on the specified indicesINDArrayget(INDArrayIndex... indexes)Returns a subset of this array based on the specified indexesINDArraygetColumn(long c)Returns the specified column.INDArraygetColumn(long c, boolean keepDim)Returns the specified column.INDArraygetColumns(int... cindices)Get an INDArray comprised of the specified columns only.doublegetDouble(int... indices)Get a double value at the specified indices.doublegetDouble(long i)Get the double value at the specified linear index in the arraydoublegetDouble(long... indices)doublegetDouble(long i, long j)Get the double value at the specified indices.doublegetDoubleUnsafe(long offset)Get a double at the given linear offset unsafe, without checks.floatgetFloat(int... indices)Returns the elements at the specified indicesfloatgetFloat(long i)Return the item at the linear index ifloatgetFloat(long... indices)floatgetFloat(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}longgetId()A unique ID for the INDArray object instance.intgetInt(int... indices)Get an integer value at the specified indices.intgetLeadingOnes()Get the number of leading ones in the array shape.longgetLong(long index)Get a long value at the specified index.longgetLong(long... indices)Get a long value at the specified indices.NumbergetNumber(long i)Get the numeric value at the specified index.NumbergetNumber(long... idx)Get a numeric value at the specified indices.protected doublegetPercentile(Number quantile, INDArray sorted)INDArraygetRow(long r)Returns the specified row as a 1D vector.INDArraygetRow(long r, boolean keepDim)Returns the specified row.INDArraygetRows(int[] rindices)Get an INDArray comprised of the specified rows only.INDArraygetScalar(int[] indexes)Returns the elements at the specified indicesINDArraygetScalar(long i)Returns the element at the specified indexINDArraygetScalar(long... indexes)INDArraygetScalar(long row, long column)Returns the element at the specified row/columnprotected int[]getStrides(int[] shape, char ordering)intgetTrailingOnes()Get the number of trailing ones in the array shape.INDArraygetWhere(Number comp, Condition condition)Boolean indexing: Return the element if it fulfills the condition in result arrayINDArraygetWhere(INDArray comp, Condition condition)Boolean indexing: Return the element if it fulfills the condition in result arrayINDArraygt(Number other)Returns the binary ndarray for "Greater" comparison.INDArraygt(INDArray other)Returns the binary ndarray for "Greater Than" comparison.INDArraygte(Number other)Returns binary ndarray for "Greter or equals" comparison.inthashCode()protected voidinit(int[] shape, int[] stride)protected voidinit(long[] shape, long[] stride)protected static DataBufferinternalCreateBuffer(double[] data)protected static DataBufferinternalCreateBuffer(double[] data, long offset)protected static DataBufferinternalCreateBuffer(float[] data)protected static DataBufferinternalCreateBuffer(float[] data, long offset)protected static DataBufferinternalCreateBuffer(int[] data)booleanisAttached()This method returns True, if this INDArray instance is attached to some Workspace.booleanisB()This method checks if this INDArray instance has boolean typebooleanisColumnVector()Returns true if the number of columns is 1booleanisColumnVectorOrScalar()Returns true if the number of columns is 1booleanisCompressed()Check if this array is compressed.booleanisEmpty()This method returns true if this INDArray is special case: no-value INDArrayINDArrayisInfinite()Returns the binary NDArray with value true where this array's entries are infinite, or false where they are not infinitebooleanisInScope()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 truebooleanisMatrix()Returns true if this ndarray is a matrixINDArrayisNaN()Returns the binary NDArray with value true where this array's entries are NaN, or false where they are not infinitebooleanisR()This method checks if this INDArray instance is one of Real typesbooleanisRowVector()Returns true if the number of rows is 1booleanisRowVectorOrScalar()Returns true if the number of rows is 1booleanisS()This method checks if this INDArray instance has String typebooleanisScalar()Returns true if this ndarray is a scalarbooleanisSparse()Check if this array is sparsebooleanisSquare()Returns whether the matrix has the same rows and columnsbooleanisValid()Deprecated.booleanisVector()Checks whether the matrix is a vector.booleanisVectorOrScalar()Returns true if this ndarray is a vector or scalarbooleanisView()Check if this array is a view or not.booleanisZ()This method checks if this INDArray instance is one of integer typesIterator<Object>iterator()longlength()Returns the total number of elements in the ndarrayINDArrayleverage()This method detaches INDArray from current Workspace, and attaches it to Workspace above, if any.INDArrayleverageOrDetach(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.INDArrayleverageTo(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.INDArrayleverageTo(String id, boolean enforceExistence)This method detaches INDArray from current Workspace, and attaches it to Workspace with a given Id.INDArraylike()This method returns empty array with the same dtype/order/shape as this onelonglinearIndex(long i)Deprecated.INDArraylogEntropy(int... dimension)Returns log entropy value for this INDArray along specified dimension(s)NumberlogEntropyNumber()Returns log entropy value for this INDArrayINDArraylt(Number other)Returns the binary ndarray for "Less" comparison.INDArraylt(INDArray other)Returns the binary ndarray for "Less" comparison.INDArraylte(Number other)Returns the binary ndarray for "Less or equals" comparison.voidmarkAsCompressed(boolean reallyCompressed)This method marks INDArray instance as compressed PLEASE NOTE: Do not use this method unless you 100% have toINDArraymatch(Number comp, Condition condition)Returns a maskINDArraymatch(INDArray comp, Condition condition)Return a mask on whether each element matches the given conditionINDArraymax(boolean keepDims, int... dimension)Returns the overall max of this ndarray along given dimensionsINDArraymax(int... dimension)Returns the overall max of this ndarray along given dimensionsNumbermaxNumber()Returns maximum value in this INDArrayINDArraymean(boolean keepDims, int... dimension)Returns the overall mean of this ndarrayINDArraymean(int... dimension)Returns the overall mean of this ndarrayINDArraymean(@NonNull INDArray result, boolean keepDims, int... dimension)Returns the overall mean of this ndarrayINDArraymean(@NonNull INDArray result, int... dimension)Returns the overall mean of this ndarrayNumbermeanNumber()Returns the overall mean of this ndarrayINDArraymedian(int... dimension)This method returns median along given dimension(s)NumbermedianNumber()This method returns median value for this INDArrayINDArraymigrate()This method pulls this INDArray into current Workspace.INDArraymigrate(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.INDArraymin(boolean keepDims, int... dimension)Returns the overall min of this ndarrayINDArraymin(int... dimension)Returns the overall min of this ndarrayNumberminNumber()Returns min value in this INDArrayINDArraymmul(INDArray other)Perform a copy matrix multiplicationINDArraymmul(INDArray other, char resultOrder)Perform a copy matrix multiplicationINDArraymmul(INDArray other, MMulTranspose mMulTranspose)Perform a copy matrix multiplicationINDArraymmul(INDArray other, INDArray result)Perform an copy matrix multiplicationINDArraymmul(INDArray other, INDArray result, MMulTranspose mMulTranspose)Perform an copy matrix multiplicationINDArraymmuli(INDArray other)Perform an inplace matrix multiplicationINDArraymmuli(INDArray other, MMulTranspose transpose)Perform an copy matrix multiplicationINDArraymmuli(INDArray other, INDArray result)Perform an inplace matrix multiplicationINDArraymmuli(INDArray other, INDArray result, MMulTranspose transpose)Perform an in place matrix multiplicationINDArraymul(Number n)Scalar multiplication (copy)INDArraymul(Number n, INDArray result)Multiplication of ndarray.INDArraymul(INDArray other)copy (element wise) multiplication of two NDArraysINDArraymul(INDArray other, INDArray result)copy (element wise) multiplication of two NDArraysINDArraymulColumnVector(INDArray columnVector)Multiplication of a column vector (copy)INDArraymuli(Number n)In place scalar multiplicationINDArraymuli(Number n, INDArray result)In place multiplication of this ndarrayINDArraymuli(INDArray other)in place (element wise) multiplication of two NDArraysINDArraymuli(INDArray other, INDArray result)in place (element wise) multiplication of two NDArraysINDArraymuliColumnVector(INDArray columnVector)In place multiplication of a column vectorINDArraymuliRowVector(INDArray rowVector)In place multiplication of a row vectorINDArraymulRowVector(INDArray rowVector)Multiplication of a row vector (copy)INDArrayneg()Returns the ndarray negative (cloned)INDArraynegi()In place setting of the negative version of this ndarrayINDArrayneq(Number other)Returns the binary ndarray for "Not equals" comparison.INDArrayneq(INDArray other)Returns the binary ndarray for "Not equals" comparison.protected INDArraynewShape(long[] newShape, char ordering)booleannone()This method checks if any of the elements within this array are non-zero (or true, in case of boolean)INDArraynorm1(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 dimensionINDArraynorm1(int... dimension)Returns the norm1 (L1 norm, i.e., sum of absolute values; also known as Taxicab or Manhattan norm) along the specified dimensionNumbernorm1Number()Calculate and return norm1 (L1 norm, i.e., sum of absolute values; also known as Taxicab or Manhattan norm) for the entire arrayINDArraynorm2(boolean keepDims, int... dimension)Returns the norm2 (L2 norm, sqrt(sum(x_i^2), also known as Euclidean norm) along the specified dimension(s)INDArraynorm2(int... dimension)Returns the norm2 (L2 norm, sqrt(sum(x_i^2), also known as Euclidean norm) along the specified dimension(s)Numbernorm2Number()Return the norm2 (L2 norm, sqrt(sum(x_i^2), also known as Euclidean norm) for the entire arrayINDArraynormmax(boolean keepDims, int... dimension)Returns the max norm (aka infinity norm, equal to the maximum absolute value) along the specified dimension(s)INDArraynormmax(int... dimension)Returns the max norm (aka infinity norm, equal to the maximum absolute value) along the specified dimension(s)NumbernormmaxNumber()Return the max norm (aka infinity norm, equal to the maximum absolute value) for the entire arraylongoffset()Returns the start of where the ndarray is for the underlying datacharordering()Return the ordering (fortran or c 'f' and 'c' respectively) of this ndarraylongoriginalOffset()Returns the start of where the ndarray is for the original data bufferINDArraypercentile(Number quantile, int... dimension)This method returns percentile along given dimension(s)NumberpercentileNumber(Number quantile)This method returns percentile value for this INDArrayINDArraypermute(int... rearrange)See: http://www.mathworks.com/help/matlab/ref/permute.htmlINDArraypermutei(int... rearrange)An in-place version of permute.INDArrayprod(boolean keepDims, int... dimension)Returns the product along a given dimensionINDArrayprod(int... dimension)Returns the product along a given dimensionNumberprodNumber()Calculate the product of all values in the arrayINDArrayput(int[] indices, INDArray element)Inserts the element at the specified indexINDArrayput(int i, int j, Number element)Inserts the element at the specified indexINDArrayput(int i, int j, INDArray element)Inserts the element at the specified indexINDArrayput(int i, INDArray element)Inserts the element at the specified indexINDArrayput(INDArray indices, INDArray element)Put element in to the indices denoted by the indices ndarray.INDArrayput(INDArrayIndex[] indices, Number element)Put the elements of the ndarray in to the specified indicesINDArrayput(INDArrayIndex[] indices, INDArray element)Put the elements of the ndarray in to the specified indicesINDArrayputColumn(int column, INDArray toPut)Insert a column in to this array Will throw an exception if this ndarray is not a matrixINDArrayputiColumnVector(INDArray columnVector)In place assignment of a column vectorINDArrayputiRowVector(INDArray rowVector)in place assignment of row vector, to each row of this arrayINDArrayputRow(long row, INDArray toPut)Insert a row in to this array Will throw an exception if this ndarray is not a matrixINDArrayputScalar(int[] indexes, double value)Insert the item at the specified indicesINDArrayputScalar(int[] indexes, float value)Put the specified float value at the specified indices in this arrayINDArrayputScalar(int[] indexes, int value)Put the specified integer value at the specified indices in this arrayINDArrayputScalar(long[] indexes, double value)INDArrayputScalar(long[] indexes, float value)INDArrayputScalar(long[] indexes, int value)INDArrayputScalar(long i, double value)Insert the number linearly in to the ndarrayINDArrayputScalar(long i, float value)Insert a scalar float at the specified indexINDArrayputScalar(long i, int value)Insert a scalar int at the specified indexINDArrayputScalar(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[] creationINDArrayputScalar(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[] creationINDArrayputScalar(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[] creationINDArrayputScalarUnsafe(long offset, double value)Insert a scalar at the given linear offsetINDArrayputSlice(int slice, INDArray put)Assigns the given matrix (put) to the specified sliceINDArrayputWhere(Number comp, Number put, Condition condition)Assign the element according to the comparison arrayINDArrayputWhere(Number comp, INDArray put, Condition condition)Assign the element according to the comparison arrayINDArrayputWhere(INDArray comp, INDArray put, Condition condition)Assign the element according to the comparison arrayINDArrayputWhereWithMask(INDArray mask, Number put)Use a pre computed mask for assigning arraysINDArrayputWhereWithMask(INDArray mask, INDArray put)Use a pre computed mask for assigning arraysintrank()Returns the rank of the ndarray (the number of dimensions).INDArrayravel()Returns a flattened version (row vector) of this ndarrayINDArrayravel(char ordering)Returns a flattened version (row vector) of this ndarrayINDArrayrdiv(Number n)Reverse division with a scalar - i.e., (n / thisArrayValues)INDArrayrdiv(Number n, INDArray result)Reverse division (number / ndarray)INDArrayrdiv(INDArray other)Reverse division, elements wise.INDArrayrdiv(INDArray other, INDArray result)Reverse divisionINDArrayrdivColumnVector(INDArray columnVector)Reverse division of a column vector (copy)INDArrayrdivi(Number n)In place reverse division - i.e., (n / thisArrayValues)INDArrayrdivi(Number n, INDArray result)Reverse in place divisionINDArrayrdivi(INDArray other)Reverse divsion (in place).INDArrayrdivi(INDArray other, INDArray result)Reverse division (in-place)INDArrayrdiviColumnVector(INDArray columnVector)In place reverse divison of a column vectorINDArrayrdiviRowVector(INDArray rowVector)In place reverse division of a column vectorINDArrayrdivRowVector(INDArray rowVector)Reverse division of a column vector (copy)protected voidread(ObjectInputStream s)INDArrayremainder(Number denominator)The scalar remainderINDArrayremainder(Number denominator, INDArray result)The scalar remainderINDArrayremainder(INDArray denominator)Remainder operatorINDArrayremainder(INDArray denominator, INDArray result)Remainder operatorINDArrayremainderi(Number denominator)In place remainderINDArrayremainderi(INDArray denominator)In place remainderINDArrayrepeat(int dimension, long... repeats)Repeat elements along a specified dimension.INDArrayreplaceWhere(INDArray arr, Condition condition)Replaces all elements in this ndarray that are matching give condition, with corresponding elements from given arrayINDArrayrepmat(int[] shape)Deprecated.INDArrayrepmat(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-L358INDArrayreshape(char order, boolean enforceView, long... newShape)Reshapes the ndarray (note: it's not possible to change the length of the ndarray).INDArrayreshape(char order, int... newShape)Deprecated.INDArrayreshape(char order, int rows, int columns)Reshapes the ndarray (can't change the length of the ndarray).INDArrayreshape(char order, long... newShape)Reshapes the ndarray (can't change the length of the ndarray).INDArrayreshape(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.INDArrayreshape(long... shape)Reshapes the ndarray (can't change the length of the ndarray).INDArrayreshape(long newRows, long newColumns)Reshapes the ndarray (can't change the length of the ndarray).introws()Returns the number of rows in this matrix (throws exception if not 2d)INDArrayrsub(Number n)Reverse subtraction with duplicates - i.e., (n - thisArrayValues)INDArrayrsub(Number n, INDArray result)Reverse subtractionINDArrayrsub(INDArray other)Element-wise reverse subtraction (copy op).INDArrayrsub(INDArray other, INDArray result)Reverse subtractionINDArrayrsubColumnVector(INDArray columnVector)Reverse subtraction of a column vector (copy)INDArrayrsubi(Number n)Reverse subtraction in place - i.e., (n - thisArrayValues)INDArrayrsubi(Number n, INDArray result)Reverse in place subtractionINDArrayrsubi(INDArray other)Element-wise reverse subtraction (in the place op) - i.e., other - thisINDArrayrsubi(INDArray other, INDArray result)Reverse subtraction (in-place)INDArrayrsubiColumnVector(INDArray columnVector)In place reverse subtraction of a column vectorINDArrayrsubiRowVector(INDArray rowVector)In place reverse subtraction of a row vectorINDArrayrsubRowVector(INDArray rowVector)Reverse subtraction of a row vector (copy)Numberscan(Condition condition)This method takes boolean condition, and returns number of elements matching this conditionvoidsetData(DataBuffer data)Set the data for this ndarray.voidsetOrder(char order)Set the orderingvoidsetShapeAndStride(int[] shape, int[] stride)Shape and stride setterINDArrayshannonEntropy(int... dimension)Returns Shannon entropy value for this INDArray along specified dimension(s)NumbershannonEntropyNumber()Returns non-normalized Shannon entropy value for this INDArraylong[]shape()Returns the shape of this ndarrayLongBuffershapeInfo()Shape infoDataBuffershapeInfoDataBuffer()Shape infolong[]shapeInfoJava()This method returns shapeInformation as jvm long arrayStringshapeInfoToString()Returns the shape information debugging informationprotected DataBuffershapeOf()longsize(int dimension)Returns the size along a specified dimensionINDArrayslice(long slice)Returns the specified slice of this ndarrayINDArrayslice(long slice, int dimension)Returns the slice of this from the specified dimensionlongslices()Returns the number of slices in this ndarrayvoidsliceVectors(List<INDArray> list)Flattens the array for linear indexing in list.doublesquaredDistance(INDArray other)Returns the square of the Euclidean distance.INDArraystd(boolean biasCorrected, boolean keepDims, int... dimension)Standard deviation of an ndarray along a dimensionINDArraystd(boolean biasCorrected, int... dimension)Standard deviation of an ndarray along a dimensionINDArraystd(int... dimension)Standard deviation of an INDArray along one or more dimensionsNumberstdNumber()Calculate the standard deviation for the entire arrayNumberstdNumber(boolean biasCorrected)Calculate the standard deviation for the entire array, specifying whether it is bias corrected or notlong[]stride()Returns the stride of this ndarrayintstride(int dimension)Calculate the stride along a particular dimensionprotected DataBufferstrideOf()protected abstract intstringBuffer(com.google.flatbuffers.FlatBufferBuilder builder, DataBuffer buffer)INDArraysub(Number n)Scalar subtraction (copied)INDArraysub(Number n, INDArray result)Subtraction of this ndarrayINDArraysub(INDArray other)copy subtraction of two NDArraysINDArraysub(INDArray other, INDArray result)copy subtraction of two NDArraysINDArraysubColumnVector(INDArray columnVector)Subtraction of a column vector (copy)INDArraysubi(Number n)In place scalar subtractionINDArraysubi(Number n, INDArray result)In place subtraction of this ndarrayINDArraysubi(INDArray other)in place (element wise) subtraction of two NDArraysINDArraysubi(INDArray other, INDArray result)in place subtraction of two matricesINDArraysubiColumnVector(INDArray columnVector)In place subtraction of a column vectorINDArraysubiRowVector(INDArray rowVector)In place subtraction of a row vectorINDArraysubRowVector(INDArray rowVector)Subtraction of a row vector (copy)INDArraysum(boolean keepDim, int... dimension)Returns the sum along the last dimension of this ndarrayINDArraysum(int... dimension)Returns the sum along the last dimension of this ndarrayINDArraysum(@NonNull INDArray result, boolean keepDims, int... dimension)Returns the sum along the last dimension of this ndarrayINDArraysum(@NonNull INDArray result, int... dimension)Returns the sum along the last dimension of this ndarrayNumbersumNumber()Sum the entire arrayINDArrayswapAxes(int dimension, int with)Mainly here for people coming from numpy.INDArraytensorAlongDimension(long index, int... dimension)Get the vector along a particular dimensionlongtensorsAlongDimension(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.inttoFlatArray(com.google.flatbuffers.FlatBufferBuilder builder)Add anINDArrayto 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.StringtoString()Generate string representation of the matrix.StringtoString(long maxElements, boolean forceSummarize, int precision)Get a string representation of the arrayStringtoString(@NonNull NDArrayStrings options)Get a string representation of the array with configurable formattingStringtoStringFull()ToString with unlimited elements and precisionINDArraytranspose()Flip the rows and columns of a matrixINDArraytransposei()Return transposed version of this matrix.INDArrayulike()This method returns uninitialized array with the same dtype/order/shape as this oneprotected voidvalidateNumericalArray(String opName, boolean allowEmpty)Validate that the operation is being applied on a numerical array (not boolean or utf8).INDArrayvar(boolean biasCorrected, int... dimension)Returns the overall variance of this ndarrayINDArrayvar(int... dimension)Returns the overall variance of this ndarrayNumbervarNumber()Returns the overall variance of all values in this INDArrayINDArrayvectorAlongDimension(int index, int dimension)Get the vector along a particular dimensionlongvectorsAlongDimension(int dimension)Returns the number of possible vectors for a given dimensionbooleanwasClosed()This method checks if array or its buffer was closed beforeprotected voidwrite(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:INDArrayCheck if this array is compressed.- Specified by:
isCompressedin interfaceINDArray- Returns:
- true if this array is compressed.
-
markAsCompressed
public void markAsCompressed(boolean reallyCompressed)
Description copied from interface:INDArrayThis method marks INDArray instance as compressed PLEASE NOTE: Do not use this method unless you 100% have to- Specified by:
markAsCompressedin 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:INDArrayElement wise stride- Specified by:
elementWiseStridein interfaceINDArray- Returns:
- the element wise stride
-
tensorsAlongDimension
public long tensorsAlongDimension(int... dimension)
Description copied from interface:INDArrayReturns the number of possible vectors for a given dimension- Specified by:
tensorsAlongDimensionin 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:INDArrayGet the vector along a particular dimension- Specified by:
tensorAlongDimensionin 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:INDArrayReturns the number of possible vectors for a given dimension- Specified by:
vectorsAlongDimensionin 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:INDArrayGet the vector along a particular dimension- Specified by:
vectorAlongDimensionin 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:INDArraySet the ordering
-
setShapeAndStride
public void setShapeAndStride(int[] shape, int[] stride)Description copied from interface:INDArrayShape and stride setter- Specified by:
setShapeAndStridein interfaceINDArray- Parameters:
shape- new value for shapestride- new value for stride
-
cumsumi
public INDArray cumsumi(int dimension)
Description copied from interface:INDArrayReturns the cumulative sum along a dimension. In-place method.
-
normmaxNumber
public Number normmaxNumber()
Description copied from interface:INDArrayReturn the max norm (aka infinity norm, equal to the maximum absolute value) for the entire array- Specified by:
normmaxNumberin interfaceINDArray- Returns:
- Max norm for the entire array
-
norm2Number
public Number norm2Number()
Description copied from interface:INDArrayReturn the norm2 (L2 norm, sqrt(sum(x_i^2), also known as Euclidean norm) for the entire array- Specified by:
norm2Numberin interfaceINDArray- Returns:
- L2 norm for the array
-
norm1Number
public Number norm1Number()
Description copied from interface:INDArrayCalculate and return norm1 (L1 norm, i.e., sum of absolute values; also known as Taxicab or Manhattan norm) for the entire array- Specified by:
norm1Numberin interfaceINDArray- Returns:
- Norm 1 for the array
-
stdNumber
public Number stdNumber()
Description copied from interface:INDArrayCalculate the standard deviation for the entire array
-
prodNumber
public Number prodNumber()
Description copied from interface:INDArrayCalculate the product of all values in the array- Specified by:
prodNumberin interfaceINDArray- Returns:
- Product of all values in the array
-
meanNumber
public Number meanNumber()
Description copied from interface:INDArrayReturns the overall mean of this ndarray- Specified by:
meanNumberin interfaceINDArray- Returns:
- the mean along the specified dimension of this ndarray
-
ameanNumber
public Number ameanNumber()
Description copied from interface:INDArrayReturns the absolute overall mean of this ndarray- Specified by:
ameanNumberin interfaceINDArray- Returns:
- the mean along the specified dimension of this ndarray
-
varNumber
public Number varNumber()
Description copied from interface:INDArrayReturns the overall variance of all values in this INDArray
-
maxNumber
public Number maxNumber()
Description copied from interface:INDArrayReturns maximum value in this INDArray
-
amaxNumber
public Number amaxNumber()
Description copied from interface:INDArrayReturns maximum (absolute) value in this INDArray- Specified by:
amaxNumberin interfaceINDArray- Returns:
- Max absolute value
-
minNumber
public Number minNumber()
Description copied from interface:INDArrayReturns min value in this INDArray
-
aminNumber
public Number aminNumber()
Description copied from interface:INDArrayReturns absolute min value in this INDArray- Specified by:
aminNumberin interfaceINDArray- Returns:
- Absolute min value
-
scan
public Number scan(Condition condition)
Description copied from interface:INDArrayThis method takes boolean condition, and returns number of elements matching this condition
-
sumNumber
public Number sumNumber()
Description copied from interface:INDArraySum the entire array
-
entropyNumber
public Number entropyNumber()
Description copied from interface:INDArrayReturns entropy value for this INDArray- Specified by:
entropyNumberin interfaceINDArray- Returns:
- entropy value
-
shannonEntropyNumber
public Number shannonEntropyNumber()
Description copied from interface:INDArrayReturns non-normalized Shannon entropy value for this INDArray- Specified by:
shannonEntropyNumberin interfaceINDArray- Returns:
- non-normalized Shannon entropy
-
logEntropyNumber
public Number logEntropyNumber()
Description copied from interface:INDArrayReturns log entropy value for this INDArray- Specified by:
logEntropyNumberin interfaceINDArray- Returns:
- log entropy value
-
cumsum
public INDArray cumsum(int dimension)
Description copied from interface:INDArrayReturns the cumulative sum along a dimension.
-
assign
public INDArray assign(INDArray arr)
Description copied from interface:INDArrayAssign all of the elements in the given ndarray to this ndarray
-
putScalar
public INDArray putScalar(long i, double value)
Description copied from interface:INDArrayInsert the number linearly in to the ndarray
-
putScalar
public INDArray putScalar(long i, float value)
Description copied from interface:INDArrayInsert a scalar float at the specified index
-
putScalar
public INDArray putScalar(long i, int value)
Description copied from interface:INDArrayInsert a scalar int at the specified index
-
putScalar
public INDArray putScalar(int[] indexes, double value)
Description copied from interface:INDArrayInsert 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:INDArrayInsert 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:INDArrayInsert 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:INDArrayInsert 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:INDArrayPut the specified float value at the specified indices in this array
-
putScalar
public INDArray putScalar(int[] indexes, int value)
Description copied from interface:INDArrayPut 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:INDArrayReturns the binary ndarray for "Epsilon equals" comparison.
-
eps
public INDArray eps(INDArray other)
Description copied from interface:INDArrayReturns the binary ndarray for "Epsilon equals" comparison.
-
lt
public INDArray lt(Number other)
Description copied from interface:INDArrayReturns the binary ndarray for "Less" comparison.
-
lte
public INDArray lte(Number other)
Description copied from interface:INDArrayReturns the binary ndarray for "Less or equals" comparison.
-
eq
public INDArray eq(Number other)
Description copied from interface:INDArrayReturns the binary ndarray for "Equals" comparison.
-
gt
public INDArray gt(Number other)
Description copied from interface:INDArrayReturns the binary ndarray for "Greater" comparison.
-
gte
public INDArray gte(Number other)
Description copied from interface:INDArrayReturns binary ndarray for "Greter or equals" comparison.
-
lt
public INDArray lt(INDArray other)
Description copied from interface:INDArrayReturns the binary ndarray for "Less" comparison.
-
neq
public INDArray neq(Number other)
Description copied from interface:INDArrayReturns the binary ndarray for "Not equals" comparison.
-
neq
public INDArray neq(INDArray other)
Description copied from interface:INDArrayReturns the binary ndarray for "Not equals" comparison.
-
eq
public INDArray eq(INDArray other)
Description copied from interface:INDArrayReturns the binary ndarray for "Equals" comparison.
-
gt
public INDArray gt(INDArray other)
Description copied from interface:INDArrayReturns the binary ndarray for "Greater Than" comparison.
-
isInfinite
public INDArray isInfinite()
Description copied from interface:INDArrayReturns the binary NDArray with value true where this array's entries are infinite, or false where they are not infinite- Specified by:
isInfinitein interfaceINDArray
-
isNaN
public INDArray isNaN()
Description copied from interface:INDArrayReturns 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:INDArrayReturns the ndarray negative (cloned)
-
negi
public INDArray negi()
Description copied from interface:INDArrayIn place setting of the negative version of this ndarray
-
rdiv
public INDArray rdiv(Number n, INDArray result)
Description copied from interface:INDArrayReverse division (number / ndarray)
-
rdivi
public INDArray rdivi(Number n, INDArray result)
Description copied from interface:INDArrayReverse in place division
-
rsub
public INDArray rsub(Number n, INDArray result)
Description copied from interface:INDArrayReverse subtraction
-
rsubi
public INDArray rsubi(Number n, INDArray result)
Description copied from interface:INDArrayReverse in place subtraction
-
div
public INDArray div(Number n, INDArray result)
Description copied from interface:INDArrayDivision if ndarray by number
-
divi
public INDArray divi(Number n, INDArray result)
Description copied from interface:INDArrayIn place division of this ndarray
-
mul
public INDArray mul(Number n, INDArray result)
Description copied from interface:INDArrayMultiplication of ndarray.
-
muli
public INDArray muli(Number n, INDArray result)
Description copied from interface:INDArrayIn place multiplication of this ndarray
-
sub
public INDArray sub(Number n, INDArray result)
Description copied from interface:INDArraySubtraction of this ndarray
-
subi
public INDArray subi(Number n, INDArray result)
Description copied from interface:INDArrayIn place subtraction of this ndarray
-
add
public INDArray add(Number n, INDArray result)
Description copied from interface:INDArrayAddition of this ndarray.
-
addi
public INDArray addi(Number n, INDArray result)
Description copied from interface:INDArrayIn place addition
-
getScalar
public INDArray getScalar(long row, long column)
Description copied from interface:INDArrayReturns the element at the specified row/column
-
dup
public INDArray dup()
Description copied from interface:INDArrayReturns a copy of this ndarray
-
dup
public INDArray dup(char order)
Description copied from interface:INDArrayReturns a copy of this ndarray, where the returned ndarray has the specified order
-
getInt
public int getInt(int... indices)
Description copied from interface:INDArrayGet 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:INDArrayGet a long value at the specified index.
-
getLong
public long getLong(long... indices)
Description copied from interface:INDArrayGet a long value at the specified indices.
-
getDouble
public double getDouble(int... indices)
Description copied from interface:INDArrayGet 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:INDArrayReturns 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:INDArrayReturns true if this ndarray is a scalar
-
put
public INDArray put(int[] indices, INDArray element)
Description copied from interface:INDArrayInserts the element at the specified index
-
match
public INDArray match(INDArray comp, Condition condition)
Description copied from interface:INDArrayReturn a mask on whether each element matches the given condition
-
match
public INDArray match(Number comp, Condition condition)
Description copied from interface:INDArrayReturns a mask
-
getWhere
public INDArray getWhere(INDArray comp, Condition condition)
Description copied from interface:INDArrayBoolean indexing: Return the element if it fulfills the condition in result array
-
getWhere
public INDArray getWhere(Number comp, Condition condition)
Description copied from interface:INDArrayBoolean 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:INDArrayAssign the element according to the comparison array
-
putWhere
public INDArray putWhere(Number comp, INDArray put, Condition condition)
Description copied from interface:INDArrayAssign the element according to the comparison array
-
putWhere
public INDArray putWhere(Number comp, Number put, Condition condition)
Description copied from interface:INDArrayAssign the element according to the comparison array
-
putWhereWithMask
public INDArray putWhereWithMask(INDArray mask, INDArray put)
Description copied from interface:INDArrayUse a pre computed mask for assigning arrays- Specified by:
putWhereWithMaskin 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:INDArrayUse a pre computed mask for assigning arrays- Specified by:
putWhereWithMaskin 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:INDArrayInserts the element at the specified index
-
put
public INDArray put(int i, int j, Number element)
Description copied from interface:INDArrayInserts the element at the specified index
-
putSlice
public INDArray putSlice(int slice, INDArray put)
Description copied from interface:INDArrayAssigns the given matrix (put) to the specified slice
-
assertSlice
protected void assertSlice(INDArray put, long slice)
-
isMatrix
public boolean isMatrix()
Description copied from interface:INDArrayReturns 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:INDArrayReturns the square of the Euclidean distance.- Specified by:
squaredDistancein interfaceINDArray
-
distance2
public double distance2(INDArray other)
Description copied from interface:INDArrayReturns the (euclidean) distance.
-
distance1
public double distance1(INDArray other)
Description copied from interface:INDArrayReturns the (1-norm) distance.
-
get
public INDArray get(INDArray indices)
Description copied from interface:INDArrayGet the elements from this ndarray based on the specified indices
-
put
public INDArray put(INDArray indices, INDArray element)
Description copied from interface:INDArrayPut 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:INDArrayPut the elements of the ndarray in to the specified indices
-
put
public INDArray put(INDArrayIndex[] indices, Number element)
Description copied from interface:INDArrayPut the elements of the ndarray in to the specified indices
-
swapAxes
public INDArray swapAxes(int dimension, int with)
Description copied from interface:INDArrayMainly here for people coming from numpy. This is equivalent to a call to permute
-
isView
public boolean isView()
Description copied from interface:INDArrayCheck if this array is a view or not.
-
isSparse
public boolean isSparse()
Description copied from interface:INDArrayCheck if this array is sparse
-
data
public DataBuffer data()
Description copied from interface:INDArrayReturns a linear double array representation of this ndarray
-
setData
public void setData(DataBuffer data)
Description copied from interface:INDArraySet the data for this ndarray.
-
slices
public long slices()
Description copied from interface:INDArrayReturns the number of slices in this ndarray
-
create
protected INDArray create(DataBuffer buffer)
-
cond
public INDArray cond(Condition condition)
Description copied from interface:INDArrayReturns 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:INDArrayReturns 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:INDArrayCalculate the stride along a particular dimension
-
rdiviColumnVector
public INDArray rdiviColumnVector(INDArray columnVector)
Description copied from interface:INDArrayIn place reverse divison of a column vector- Specified by:
rdiviColumnVectorin 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:INDArrayReverse division of a column vector (copy)- Specified by:
rdivColumnVectorin 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:INDArrayIn place reverse division of a column vector- Specified by:
rdiviRowVectorin 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:INDArrayReverse division of a column vector (copy)- Specified by:
rdivRowVectorin 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:INDArrayIn place reverse subtraction of a column vector- Specified by:
rsubiColumnVectorin interfaceINDArray- Parameters:
columnVector- the column vector to subtract- Returns:
- the result of the subtraction
-
rsubColumnVector
public INDArray rsubColumnVector(INDArray columnVector)
Description copied from interface:INDArrayReverse subtraction of a column vector (copy)- Specified by:
rsubColumnVectorin interfaceINDArray- Parameters:
columnVector- the column vector to subtract- Returns:
- the result of the subtraction
-
rsubiRowVector
public INDArray rsubiRowVector(INDArray rowVector)
Description copied from interface:INDArrayIn place reverse subtraction of a row vector- Specified by:
rsubiRowVectorin interfaceINDArray- Parameters:
rowVector- the row vector to subtract- Returns:
- the result of the subtraction
-
rsubRowVector
public INDArray rsubRowVector(INDArray rowVector)
Description copied from interface:INDArrayReverse subtraction of a row vector (copy)- Specified by:
rsubRowVectorin 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:INDArrayInserts the element at the specified index
-
diviColumnVector
public INDArray diviColumnVector(INDArray columnVector)
Description copied from interface:INDArrayIn place division of a column vector- Specified by:
diviColumnVectorin 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:INDArrayDivision of a column vector (copy)- Specified by:
divColumnVectorin 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:INDArrayIn place division of a row vector- Specified by:
diviRowVectorin 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:INDArrayDivision of a row vector (copy)- Specified by:
divRowVectorin 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:INDArrayIn place multiplication of a column vector- Specified by:
muliColumnVectorin 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:INDArrayMultiplication of a column vector (copy)- Specified by:
mulColumnVectorin 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:INDArrayIn place multiplication of a row vector- Specified by:
muliRowVectorin 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:INDArrayMultiplication of a row vector (copy)- Specified by:
mulRowVectorin 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:INDArrayIn place subtraction of a column vector- Specified by:
subiColumnVectorin interfaceINDArray- Parameters:
columnVector- the column vector to subtract- Returns:
- the result of the subtraction
-
subColumnVector
public INDArray subColumnVector(INDArray columnVector)
Description copied from interface:INDArraySubtraction of a column vector (copy)- Specified by:
subColumnVectorin interfaceINDArray- Parameters:
columnVector- the column vector to subtract- Returns:
- the result of the subtraction
-
subiRowVector
public INDArray subiRowVector(INDArray rowVector)
Description copied from interface:INDArrayIn place subtraction of a row vector- Specified by:
subiRowVectorin interfaceINDArray- Parameters:
rowVector- the row vector to subtract- Returns:
- the result of the subtraction
-
subRowVector
public INDArray subRowVector(INDArray rowVector)
Description copied from interface:INDArraySubtraction of a row vector (copy)- Specified by:
subRowVectorin interfaceINDArray- Parameters:
rowVector- the row vector to subtract- Returns:
- the result of the subtraction
-
addiColumnVector
public INDArray addiColumnVector(INDArray columnVector)
Description copied from interface:INDArrayIn place addition of a column vector- Specified by:
addiColumnVectorin interfaceINDArray- Parameters:
columnVector- the column vector to add- Returns:
- the result of the addition
-
putiColumnVector
public INDArray putiColumnVector(INDArray columnVector)
Description copied from interface:INDArrayIn place assignment of a column vector- Specified by:
putiColumnVectorin interfaceINDArray- Parameters:
columnVector- the column vector to add- Returns:
- the result of the addition
-
addColumnVector
public INDArray addColumnVector(INDArray columnVector)
Description copied from interface:INDArrayAddition of a column vector (copy)- Specified by:
addColumnVectorin interfaceINDArray- Parameters:
columnVector- the column vector to add- Returns:
- the result of the addition
-
addiRowVector
public INDArray addiRowVector(INDArray rowVector)
Description copied from interface:INDArrayIn place addition of a row vector- Specified by:
addiRowVectorin interfaceINDArray- Parameters:
rowVector- the row vector to add- Returns:
- the result of the addition
-
putiRowVector
public INDArray putiRowVector(INDArray rowVector)
Description copied from interface:INDArrayin place assignment of row vector, to each row of this array- Specified by:
putiRowVectorin 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:INDArrayAddition of a row vector (copy)- Specified by:
addRowVectorin 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:INDArrayPerform an copy matrix multiplication
-
mmul
public INDArray mmul(INDArray other, MMulTranspose mMulTranspose)
Description copied from interface:INDArrayPerform a copy matrix multiplication
-
mmul
public INDArray mmul(INDArray other, char resultOrder)
Description copied from interface:INDArrayPerform a copy matrix multiplication
-
mmul
public INDArray mmul(INDArray other)
Description copied from interface:INDArrayPerform a copy matrix multiplication
-
create
protected INDArray create(int[] shape, char ordering)
-
toDoubleMatrix
public double[][] toDoubleMatrix()
Description copied from interface:INDArrayConvert 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:
toDoubleMatrixin interfaceINDArray- Returns:
- a copy of this array as a 2d double array
-
toDoubleVector
public double[] toDoubleVector()
Description copied from interface:INDArrayConvert 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:
toDoubleVectorin interfaceINDArray- Returns:
- a copy of this array as a 1d double array
-
toFloatVector
public float[] toFloatVector()
Description copied from interface:INDArrayConvert 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:
toFloatVectorin interfaceINDArray- Returns:
- a copy of this array as a 1d float array
-
toFloatMatrix
public float[][] toFloatMatrix()
Description copied from interface:INDArrayConvert 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:
toFloatMatrixin interfaceINDArray- Returns:
- a copy of this array as a 2d float array
-
toIntVector
public int[] toIntVector()
Description copied from interface:INDArrayConvert 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:
toIntVectorin interfaceINDArray- Returns:
- a copy of this array as a 1d int array
-
toLongVector
public long[] toLongVector()
Description copied from interface:INDArrayConvert 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:
toLongVectorin interfaceINDArray- Returns:
- a copy of this array as a 1d long array
-
toLongMatrix
public long[][] toLongMatrix()
Description copied from interface:INDArrayConvert 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:
toLongMatrixin interfaceINDArray- Returns:
- a copy of this array as a 2d int array
-
toIntMatrix
public int[][] toIntMatrix()
Description copied from interface:INDArrayConvert 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:
toIntMatrixin interfaceINDArray- Returns:
- a copy of this array as a 2d int array
-
div
public INDArray div(INDArray other)
Description copied from interface:INDArrayCopy (element wise) division of two NDArrays
-
div
public INDArray div(INDArray other, INDArray result)
Description copied from interface:INDArraycopy (element wise) division of two NDArrays
-
mul
public INDArray mul(INDArray other)
Description copied from interface:INDArraycopy (element wise) multiplication of two NDArrays
-
mul
public INDArray mul(INDArray other, INDArray result)
Description copied from interface:INDArraycopy (element wise) multiplication of two NDArrays
-
sub
public INDArray sub(INDArray other)
Description copied from interface:INDArraycopy subtraction of two NDArrays
-
sub
public INDArray sub(INDArray other, INDArray result)
Description copied from interface:INDArraycopy subtraction of two NDArrays
-
add
public INDArray add(INDArray other)
Description copied from interface:INDArrayElement-wise copy addition of two NDArrays
-
add
public INDArray add(INDArray other, INDArray result)
Description copied from interface:INDArrayElement-wise copy addition of two NDArrays
-
mmuli
public INDArray mmuli(INDArray other, MMulTranspose transpose)
Description copied from interface:INDArrayPerform an copy matrix multiplication
-
mmuli
public INDArray mmuli(INDArray other)
Description copied from interface:INDArrayPerform an inplace matrix multiplication
-
mmuli
public INDArray mmuli(INDArray other, INDArray result, MMulTranspose transpose)
Description copied from interface:INDArrayPerform an in place matrix multiplication
-
mmuli
public INDArray mmuli(INDArray other, INDArray result)
Description copied from interface:INDArrayPerform an inplace matrix multiplication
-
divi
public INDArray divi(INDArray other)
Description copied from interface:INDArrayin place (element wise) division of two NDArrays
-
divi
public INDArray divi(INDArray other, INDArray result)
Description copied from interface:INDArrayin place (element wise) division of two NDArrays
-
muli
public INDArray muli(INDArray other)
Description copied from interface:INDArrayin place (element wise) multiplication of two NDArrays
-
muli
public INDArray muli(INDArray other, INDArray result)
Description copied from interface:INDArrayin place (element wise) multiplication of two NDArrays
-
subi
public INDArray subi(INDArray other)
Description copied from interface:INDArrayin place (element wise) subtraction of two NDArrays
-
addi
public INDArray addi(INDArray other)
Description copied from interface:INDArrayin place (element wise) addition of two NDArrays
-
addi
public INDArray addi(INDArray other, INDArray result)
Description copied from interface:INDArrayin place (element wise) addition of two NDArrays
-
normmax
public INDArray normmax(boolean keepDims, int... dimension)
Description copied from interface:INDArrayReturns 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:INDArrayReturns 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:INDArrayReverse division, elements wise. i.e., other / this
-
rdivi
public INDArray rdivi(INDArray other)
Description copied from interface:INDArrayReverse divsion (in place). i.e., other / this
-
rdiv
public INDArray rdiv(INDArray other, INDArray result)
Description copied from interface:INDArrayReverse division
-
rdivi
public INDArray rdivi(INDArray other, INDArray result)
Description copied from interface:INDArrayReverse division (in-place)
-
rsub
public INDArray rsub(INDArray other, INDArray result)
Description copied from interface:INDArrayReverse subtraction
-
rsub
public INDArray rsub(INDArray other)
Description copied from interface:INDArrayElement-wise reverse subtraction (copy op). i.e., other - this
-
rsubi
public INDArray rsubi(INDArray other)
Description copied from interface:INDArrayElement-wise reverse subtraction (in the place op) - i.e., other - this
-
rsubi
public INDArray rsubi(INDArray other, INDArray result)
Description copied from interface:INDArrayReverse subtraction (in-place)
-
assign
public INDArray assign(Number value)
Description copied from interface:INDArraySet all entries of the ndarray to the specified value
-
assign
public INDArray assign(boolean value)
Description copied from interface:INDArraySet all entries of the ndarray to the specified value
-
assignIf
public INDArray assignIf(INDArray arr, Condition condition)
Description copied from interface:INDArrayAssign 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:INDArrayReplaces all elements in this ndarray that are matching give condition, with corresponding elements from given array- Specified by:
replaceWherein 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:INDArrayGet the linear index of the data in to the array- Specified by:
linearIndexin 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:INDArrayReturns 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:INDArrayGet 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:
getTrailingOnesin interfaceINDArray- Returns:
- Number of trailing ones in shape
-
getLeadingOnes
public int getLeadingOnes()
Description copied from interface:INDArrayGet 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:
getLeadingOnesin interfaceINDArray- Returns:
- Number of leading ones in shape
-
slice
public INDArray slice(long slice, int dimension)
Description copied from interface:INDArrayReturns the slice of this from the specified dimension
-
getScalar
public INDArray getScalar(int[] indexes)
Description copied from interface:INDArrayReturns the elements at the specified indices
-
rdiv
public INDArray rdiv(Number n)
Description copied from interface:INDArrayReverse division with a scalar - i.e., (n / thisArrayValues)
-
rdivi
public INDArray rdivi(Number n)
Description copied from interface:INDArrayIn place reverse division - i.e., (n / thisArrayValues)
-
rsub
public INDArray rsub(Number n)
Description copied from interface:INDArrayReverse subtraction with duplicates - i.e., (n - thisArrayValues)
-
rsubi
public INDArray rsubi(Number n)
Description copied from interface:INDArrayReverse subtraction in place - i.e., (n - thisArrayValues)
-
divi
public INDArray divi(Number n)
Description copied from interface:INDArrayIn place scalar division
-
mul
public INDArray mul(Number n)
Description copied from interface:INDArrayScalar multiplication (copy)
-
muli
public INDArray muli(Number n)
Description copied from interface:INDArrayIn place scalar multiplication
-
sub
public INDArray sub(Number n)
Description copied from interface:INDArrayScalar subtraction (copied)
-
subi
public INDArray subi(Number n)
Description copied from interface:INDArrayIn place scalar subtraction
-
add
public INDArray add(Number n)
Description copied from interface:INDArrayScalar addition (cloning)
-
addi
public INDArray addi(Number n)
Description copied from interface:INDArrayIn place scalar addition
-
repmat
public INDArray repmat(long[] shape)
Description copied from interface:INDArrayReplicate 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:INDArrayRepeat elements along a specified dimension.
-
putRow
public INDArray putRow(long row, INDArray toPut)
Description copied from interface:INDArrayInsert 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:INDArrayInsert 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:INDArrayGet the numeric value at the specified index.
-
getNumber
public Number getNumber(long... idx)
Description copied from interface:INDArrayGet a numeric value at the specified indices.
-
getDouble
public double getDouble(long i)
Description copied from interface:INDArrayGet the double value at the specified linear index in the array
-
getDouble
public double getDouble(long i, long j)Description copied from interface:INDArrayGet 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:INDArrayReturn the item at the linear index i
-
getFloat
public float getFloat(long i, long j)Description copied from interface:INDArrayReturn 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:INDArrayFlip 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:
transposeiin 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:INDArrayReshapes 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:INDArrayReshapes 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:INDArrayReshapes 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:INDArrayGet a double at the given linear offset unsafe, without checks.- Specified by:
getDoubleUnsafein 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:INDArrayInsert a scalar at the given linear offset- Specified by:
putScalarUnsafein 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:INDArrayReshapes 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:INDArrayReshapes 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:INDArrayReturns the product along a given dimension
-
prod
public INDArray prod(int... dimension)
Description copied from interface:INDArrayReturns the product along a given dimension
-
mean
public INDArray mean(boolean keepDims, int... dimension)
Description copied from interface:INDArrayReturns the overall mean of this ndarray
-
mean
public INDArray mean(int... dimension)
Description copied from interface:INDArrayReturns the overall mean of this ndarray
-
amean
public INDArray amean(int... dimension)
Description copied from interface:INDArrayReturns the absolute overall mean of this ndarray
-
mean
public INDArray mean(@NonNull @NonNull INDArray result, boolean keepDims, int... dimension)
Description copied from interface:INDArrayReturns the overall mean of this ndarray
-
mean
public INDArray mean(@NonNull @NonNull INDArray result, int... dimension)
Description copied from interface:INDArrayReturns the overall mean of this ndarray
-
var
public INDArray var(int... dimension)
Description copied from interface:INDArrayReturns the overall variance of this ndarray
-
var
public INDArray var(boolean biasCorrected, int... dimension)
Description copied from interface:INDArrayReturns the overall variance of this ndarray
-
max
public INDArray max(boolean keepDims, int... dimension)
Description copied from interface:INDArrayReturns the overall max of this ndarray along given dimensions
-
max
public INDArray max(int... dimension)
Description copied from interface:INDArrayReturns the overall max of this ndarray along given dimensions
-
amax
public INDArray amax(int... dimension)
Description copied from interface:INDArrayReturns the absolute overall max of this ndarray along given dimensions
-
min
public INDArray min(boolean keepDims, int... dimension)
Description copied from interface:INDArrayReturns the overall min of this ndarray
-
min
public INDArray min(int... dimension)
Description copied from interface:INDArrayReturns the overall min of this ndarray
-
amin
public INDArray amin(int... dimension)
Description copied from interface:INDArrayReturns minimum (absolute) value in this INDArray, along the specified dimensions
-
sum
public INDArray sum(int... dimension)
Description copied from interface:INDArrayReturns the sum along the last dimension of this ndarray
-
sum
public INDArray sum(boolean keepDim, int... dimension)
Description copied from interface:INDArrayReturns the sum along the last dimension of this ndarray
-
entropy
public INDArray entropy(int... dimension)
Description copied from interface:INDArrayReturns entropy value for this INDArray along specified dimension(s)
-
shannonEntropy
public INDArray shannonEntropy(int... dimension)
Description copied from interface:INDArrayReturns Shannon entropy value for this INDArray along specified dimension(s)- Specified by:
shannonEntropyin interfaceINDArray- Parameters:
dimension- specified dimension(s)- Returns:
- Shannon entropy
-
logEntropy
public INDArray logEntropy(int... dimension)
Description copied from interface:INDArrayReturns log entropy value for this INDArray along specified dimension(s)- Specified by:
logEntropyin 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:INDArrayReturns the sum along the last dimension of this ndarray
-
sum
public INDArray sum(@NonNull @NonNull INDArray result, int... dimension)
Description copied from interface:INDArrayReturns the sum along the last dimension of this ndarray
-
norm1
public INDArray norm1(int... dimension)
Description copied from interface:INDArrayReturns 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:INDArrayReturns 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:INDArrayStandard deviation of an INDArray along one or more dimensions
-
std
public INDArray std(boolean biasCorrected, int... dimension)
Description copied from interface:INDArrayStandard deviation of an ndarray along a dimension
-
std
public INDArray std(boolean biasCorrected, boolean keepDims, int... dimension)
Description copied from interface:INDArrayStandard deviation of an ndarray along a dimension
-
stdNumber
public Number stdNumber(boolean biasCorrected)
Description copied from interface:INDArrayCalculate 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:INDArrayReturns 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:INDArrayReturns 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:INDArrayReturns the number of columns in this matrix (throws exception if not 2d)
-
rows
public int rows()
Description copied from interface:INDArrayReturns the number of rows in this matrix (throws exception if not 2d)
-
ravel
public INDArray ravel(char ordering)
Description copied from interface:INDArrayReturns a flattened version (row vector) of this ndarray
-
ravel
public INDArray ravel()
Description copied from interface:INDArrayReturns a flattened version (row vector) of this ndarray
-
sliceVectors
public void sliceVectors(List<INDArray> list)
Description copied from interface:INDArrayFlattens the array for linear indexing in list.- Specified by:
sliceVectorsin interfaceINDArray
-
reshape
public INDArray reshape(long newRows, long newColumns)
Description copied from interface:INDArrayReshapes 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:INDArrayReturns the specified column. Throws an exception if its not a matrix
-
getColumn
public INDArray getColumn(long c, boolean keepDim)
Description copied from interface:INDArrayReturns 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:INDArrayGet an INDArray comprised of the specified rows only. Copy operation
-
get
public INDArray get(INDArrayIndex... indexes)
Description copied from interface:INDArrayReturns a subset of this array based on the specified indexes
-
getColumns
public INDArray getColumns(int... cindices)
Description copied from interface:INDArrayGet an INDArray comprised of the specified columns only. Copy operation.- Specified by:
getColumnsin 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:INDArrayReturns 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:INDArrayReturns 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:INDArrayThis method checks 2 INDArrays equality with given eps- Specified by:
equalsWithEpsin 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:INDArrayThis 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:
equalShapesin 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:INDArrayShape info- Specified by:
shapeInfoDataBufferin interfaceINDArray- Returns:
- Shape info
-
shapeInfo
public LongBuffer shapeInfo()
Description copied from interface:INDArrayShape info
-
shape
public long[] shape()
Description copied from interface:INDArrayReturns the shape of this ndarray
-
shapeInfoToString
public String shapeInfoToString()
Description copied from interface:INDArrayReturns the shape information debugging information- Specified by:
shapeInfoToStringin interfaceINDArray- Returns:
- the shape information.
-
stride
public long[] stride()
Description copied from interface:INDArrayReturns the stride of this ndarray
-
offset
public long offset()
Description copied from interface:INDArrayReturns the start of where the ndarray is for the underlying data
-
ordering
public char ordering()
Description copied from interface:INDArrayReturn the ordering (fortran or c 'f' and 'c' respectively) of this ndarray
-
size
public long size(int dimension)
Description copied from interface:INDArrayReturns the size along a specified dimension
-
rank
public int rank()
Description copied from interface:INDArrayReturns the rank of the ndarray (the number of dimensions).
-
length
public long length()
Description copied from interface:INDArrayReturns the total number of elements in the ndarray
-
broadcast
public INDArray broadcast(INDArray result)
Description copied from interface:INDArrayBroadcasts this ndarray to be the specified shape
-
broadcast
public INDArray broadcast(long... shape)
Description copied from interface:INDArrayBroadcasts this ndarray to be the specified shape
-
dimShuffle
@Deprecated public INDArray dimShuffle(Object[] rearrange, int[] newOrder, boolean[] broadCastable)
Deprecated.Description copied from interface:INDArrayDimshuffle: 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:
dimShufflein 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:
dimShufflein interfaceINDArray- Parameters:
rearrange- the dimensions to swap to- Returns:
- the newly permuted array
-
permute
public INDArray permute(int... rearrange)
Description copied from interface:INDArraySee: http://www.mathworks.com/help/matlab/ref/permute.html
-
permutei
public INDArray permutei(int... rearrange)
Description copied from interface:INDArrayAn 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:INDArrayReturns true if this ndarray is a vector or scalar- Specified by:
isVectorOrScalarin interfaceINDArray- Returns:
- whether this ndarray is a vector or scalar
-
isSquare
public boolean isSquare()
Description copied from interface:INDArrayReturns whether the matrix has the same rows and columns
-
isRowVector
public boolean isRowVector()
Description copied from interface:INDArrayReturns true if the number of rows is 1- Specified by:
isRowVectorin interfaceINDArray- Returns:
- true if the number of rows is 1
-
isColumnVector
public boolean isColumnVector()
Description copied from interface:INDArrayReturns true if the number of columns is 1- Specified by:
isColumnVectorin interfaceINDArray- Returns:
- true if the number of columns is 1
-
isColumnVectorOrScalar
public boolean isColumnVectorOrScalar()
Description copied from interface:INDArrayReturns true if the number of columns is 1- Specified by:
isColumnVectorOrScalarin interfaceINDArray- Returns:
- true if the number of columns is 1
-
isRowVectorOrScalar
public boolean isRowVectorOrScalar()
Description copied from interface:INDArrayReturns true if the number of rows is 1- Specified by:
isRowVectorOrScalarin 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:INDArrayGet a string representation of the array with configurable formatting
-
toString
public String toString(long maxElements, boolean forceSummarize, int precision)
Description copied from interface:INDArrayGet a string representation of the array- Specified by:
toStringin 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:INDArrayToString with unlimited elements and precision- Specified by:
toStringFullin interfaceINDArray- See Also:
toString(long, boolean, int)
-
element
public Object element()
Description copied from interface:INDArrayReturns a scalar (individual element) of a scalar ndarray
-
remainder
public INDArray remainder(INDArray denominator)
Description copied from interface:INDArrayRemainder operator
-
remainder
public INDArray remainder(INDArray denominator, INDArray result)
Description copied from interface:INDArrayRemainder operator
-
remainder
public INDArray remainder(Number denominator)
Description copied from interface:INDArrayThe scalar remainder
-
remainder
public INDArray remainder(Number denominator, INDArray result)
Description copied from interface:INDArrayThe scalar remainder
-
remainderi
public INDArray remainderi(INDArray denominator)
Description copied from interface:INDArrayIn place remainder- Specified by:
remainderiin interfaceINDArray- Parameters:
denominator- the denominator- Returns:
- Remainder
-
remainderi
public INDArray remainderi(Number denominator)
Description copied from interface:INDArrayIn place remainder- Specified by:
remainderiin interfaceINDArray- Parameters:
denominator- the denominator- Returns:
- Remainder
-
fmod
public INDArray fmod(INDArray denominator)
Description copied from interface:INDArrayremainder of division
-
fmod
public INDArray fmod(INDArray denominator, INDArray result)
Description copied from interface:INDArrayremainder of division
-
fmod
public INDArray fmod(Number denominator)
Description copied from interface:INDArrayremainder of division by scalar.
-
fmod
public INDArray fmod(Number denominator, INDArray result)
Description copied from interface:INDArrayremainder of division by scalar.
-
fmodi
public INDArray fmodi(INDArray denominator)
Description copied from interface:INDArrayIn place fmod
-
fmodi
public INDArray fmodi(Number denominator)
Description copied from interface:INDArrayIn place fmod
-
originalOffset
public long originalOffset()
Description copied from interface:INDArrayReturns the start of where the ndarray is for the original data buffer- Specified by:
originalOffsetin 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:INDArrayThis method returns index of highest value along specified dimension(s)
-
isAttached
public boolean isAttached()
Description copied from interface:INDArrayThis method returns True, if this INDArray instance is attached to some Workspace. False otherwise.- Specified by:
isAttachedin interfaceINDArray- Returns:
- True if attached to workspace, false otherwise
-
isInScope
public boolean isInScope()
Description copied from interface:INDArrayThis 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:INDArrayThis 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:INDArrayThis 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:INDArrayThis 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:
leverageToin interfaceINDArray- See Also:
INDArray.leverageTo(String, boolean)
-
leverageTo
public INDArray leverageTo(String id, boolean enforceExistence) throws Nd4jNoSuchWorkspaceException
Description copied from interface:INDArrayThis 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 anNd4jNoSuchWorkspaceExceptionis 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:
leverageToin interfaceINDArray- Parameters:
id- ID of the workspace to leverage toenforceExistence- If true, and the specified workspace does not exist: anNd4jNoSuchWorkspaceExceptionwill 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:INDArrayThis 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:
leverageOrDetachin 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:INDArrayThis method pulls this INDArray into current Workspace. PLEASE NOTE: If there's no current Workspace - INDArray returned as is- Specified by:
migratein 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:INDArrayThis 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:INDArrayThis method returns percentile value for this INDArray- Specified by:
percentileNumberin interfaceINDArray- Parameters:
quantile- target percentile in range of 0..100- Returns:
- percentile value
-
medianNumber
public Number medianNumber()
Description copied from interface:INDArrayThis method returns median value for this INDArray- Specified by:
medianNumberin interfaceINDArray- Returns:
- Median value for array
-
median
public INDArray median(int... dimension)
Description copied from interface:INDArrayThis method returns median along given dimension(s)
-
percentile
public INDArray percentile(Number quantile, int... dimension)
Description copied from interface:INDArrayThis method returns percentile along given dimension(s)- Specified by:
percentilein 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:INDArrayAdd anINDArrayto flatbuffers builder- Specified by:
toFlatArrayin 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:INDArrayThis method returns true if this INDArray is special case: no-value INDArray
-
shapeInfoJava
public long[] shapeInfoJava()
Description copied from interface:INDArrayThis method returns shapeInformation as jvm long array- Specified by:
shapeInfoJavain interfaceINDArray- Returns:
- shapeInformation
-
dataType
public DataType dataType()
Description copied from interface:INDArrayThis method returns dtype for this INDArray
-
isR
public boolean isR()
Description copied from interface:INDArrayThis method checks if this INDArray instance is one of Real types
-
isZ
public boolean isZ()
Description copied from interface:INDArrayThis method checks if this INDArray instance is one of integer types
-
isB
public boolean isB()
Description copied from interface:INDArrayThis method checks if this INDArray instance has boolean type
-
isS
public boolean isS()
Description copied from interface:INDArrayThis method checks if this INDArray instance has String type
-
castTo
public INDArray castTo(DataType dataType)
Description copied from interface:INDArrayThis method cast elements of this INDArray to new data type
-
all
public boolean all()
Description copied from interface:INDArrayThis 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:INDArrayThis 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:INDArrayThis 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:INDArrayThis method checks, if this INDArray instalce can use close() method
-
close
public void close()
Description copied from interface:INDArrayThis 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:
closein interfaceAutoCloseable- Specified by:
closein interfaceINDArray
-
like
public INDArray like()
Description copied from interface:INDArrayThis method returns empty array with the same dtype/order/shape as this one
-
ulike
public INDArray ulike()
Description copied from interface:INDArrayThis method returns uninitialized array with the same dtype/order/shape as this one
-
wasClosed
public boolean wasClosed()
Description copied from interface:INDArrayThis method checks if array or its buffer was closed before
-
getId
public long getId()
Description copied from interface:INDArrayA unique ID for the INDArray object instance. Does not account for views.
-
assignNewId
public void assignNewId()
-
-