mikera.vectorz
Class AScalar
- java.lang.Object
-
- mikera.arrayz.impl.AbstractArray<java.lang.Object>
-
- mikera.vectorz.AScalar
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<INDArray>, java.lang.Iterable<java.lang.Object>, IDense, INDArray, IScalar
- Direct Known Subclasses:
- ArrayIndexScalar, ImmutableScalar, MatrixIndexScalar, Scalar, VectorIndexScalar
public abstract class AScalar extends AbstractArray<java.lang.Object> implements IScalar, IDense
Abstract base class for scalar arrays that represent a wrapped 0-d scalar value. These may be a 0-d view into another vector/matrix/array- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description AScalar()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method and Description voidabs()Replaces all elements of this array with their absolute values, according to Math.abs(double)voidadd(double d)Adds a double value to all elements in this array.voidadd(INDArray a)Adds all the elements of another array to this array, in an elementwise order.voidaddAt(long i, double v)Adds to a mutable array, indexed by element position in row major order.AScalaraddCopy(double d)Creates a new array equal to this array with a constant value added to every elementINDArrayaddCopy(INDArray a)Creates a new array equal to the sum of this array with another array.voidaddInnerProduct(INDArray a, INDArray b)Adds the inner product of two arrays to this array.voidaddInnerProduct(INDArray a, INDArray b, double d)Adds a scalar multiple of the inner product of two arrays to this array.voidaddMultiple(INDArray src, double factor)Adds a scaled multiple of another array to this arrayvoidaddPower(INDArray src, double factor)Adds an array with all elements of the source array raised to the specified powervoidaddToArray(double[] data, int offset)Adds all the elements of this array to a double array at the specified offset, in row-major ordervoidapplyOp(IOperator op)Applies a unary operator to all elements of the array (in-place)voidapplyOp(Op op)Applies a unary operator to all elements of the array (in-place)voidapplyOp(Op2 op, double b)Applies a binary operator to this array and a double value.voidapplyOp(Op2 op, INDArray b)Applies a binary operator to this array and a second array.double[]asDoubleArray()Returns the underlying double array representing the densely packed elements of this array.AVectorasVector()Constructs a view of all elements in the array as a single vector in row-major order.INDArraybroadcast(int... targetShape)Returns a view of this array broadcasted up to a larger shapeAMatrixbroadcastLike(AMatrix v)Broadcasts an array to match the shape of the target matrixAVectorbroadcastLike(AVector v)Broadcasts an array to match the shape of the target vectorINDArraybroadcastLike(INDArray v)Broadcasts an array to match the shape of the targetvoidclamp(double min, double max)Clamps all the elements of this array within the specified [min,max] rangeScalarclone()Returns a clone of the array data, as a new array which will be fully mutable and may be of a different class to the original.intcompareTo(INDArray a)INDArraydense()Coerces this INDArray to a dense format, without changing its element values.ScalardenseClone()Creates a fully mutable dense clone of this array.intdimensionality()Returns the dimensionality of the array (i.e.voiddivide(double factor)Divides all elements by a given factorlongelementCount()Returns the total number of elements in this array.java.util.Iterator<java.lang.Double>elementIterator()Returns an iterator over all elements in this array, in row-major orderdoubleelementMax()Returns the maximum element value in this array.doubleelementMaxAbs()Returns the maximum absolute element value in this array.doubleelementMin()Returns the maximum element value in this array.doubleelementProduct()Returns the product of all elements in the array.booleanelementsEqual(double value)Returns true if all elements are equal to a specific valuedoubleelementSquaredSum()Returns the sum of squared elements in this array.doubleelementSum()Returns the sum of all elements in this array.booleanepsilonEquals(INDArray a, double epsilon)Tests is this array is approximately equal to another array, up to a given tolerance (epsilon) The arrays must have the same shapebooleanequals(AScalar o)Returns true if this scalar is equal in value to another scalar.booleanequals(INDArray o)Checks if two arrays are equal exactly in terms of both value and shape Element equality checks are consistent with compareTobooleanequals(java.lang.Object o)booleanequalsArray(double[] data, int offset)Returns true if the elements in this array exactly match the elements in the given array, in row-major orderabstract AScalarexactClone()Creates a deep clone of an array, using the same class implementation as the original arrayabstract doubleget()Returns the double value of a scalar arraydoubleget(int... indexes)Returns the double value at the specified index position in an arraydoubleget(int x)Returns the double value at the specified position in a 1D vectordoubleget(int x, int y)Returns the double value at the specified position in a 2D matrixdoublegetElement(long i)Gets a specific element of this array, indexed in row-major ordervoidgetElements(double[] arr)Copies all elements of this INDArray to the specified double arrayvoidgetElements(double[] dest, int offset)Copies all elements of this array a double array at the specified offsetlong[]getLongShape()Returns the shape of the array as an array of longs.int[]getShape()Returns the shape of the array as an array of ints.intgetShape(int dim)Returns the dimension size for a specific dimension in the array's shapejava.util.List<java.lang.Object>getSlices()Returns a list of all major slices of this array.AScalargetTranspose()Returns the transpose of this array.AScalargetTransposeView()Returns a transposed view of the array.inthashCode()booleanhasUncountable()Returns true if any element is this array is NaN or infiniteImmutableScalarimmutable()Returns an immutable version of this array.ScalarinnerProduct(AScalar a)Calculates the inner product of this array with a scalarAVectorinnerProduct(AVector a)Computes the inner product of this array with a vectorScalarinnerProduct(double a)Calculates the inner product of this array with a double valueINDArrayinnerProduct(INDArray a)Calculates the inner product of this array with another array.booleanisBoolean()Returns true if the array is boolean (contains only 0.0 or 1.0 values)booleanisElementConstrained()Returns true if this array has some constraints on element valuesbooleanisFullyMutable()If this method returns true, the INDArray is guaranteed to be fully mutable in all positions i.e.booleanisMutable()Returns true if the INDArray is mutable (at least partially)booleanisZero()Returns true if the array is zero (all elements equal to zero)java.util.Iterator<java.lang.Object>iterator()voidmultiply(double factor)Multiplies all elements of the array in place by a given double valuevoidmultiply(INDArray a)Multiplies all elements by the equivalent elements in a second array, i.e.INDArraymultiplyCopy(INDArray a)Multiplies all elements by the equivalent elements in a second array, i.e.AScalarmutable()Coerces this INDArray to a fully mutable format.voidnegate()Negates all elements in the array in placelongnonZeroCount()Returns the number of non-zero elements in the array.INDArrayouterProduct(INDArray a)Calculates the outer product of this array with another array.voidpow(double exponent)Raises all elements of the array to a specified power in placedoublereduce(Op2 op)Reduces over all elements of the array in row-major order.doublereduce(Op2 op, double init)Reduces over all elements of the array in row-major order.INDArrayreshape(int... dimensions)Returns a new array by rearranging the elements of this array into the desired shape Truncates or zero-pads the elements as required to fill the new shapeabstract voidset(double value)Sets all elements of an array to a specific double valuevoidset(int[] indexes, double value)Sets the element at the given indexed position in a mutable arrayvoidsetApplyOp(Op op, INDArray a)Sets this array to the result of applying an operation to a source arrayvoidsetElements(double... values)Sets all elements in an array using the given double valuesvoidsetElements(double[] values, int offset)Sets all elements in an array using the given double valuesvoidsetElements(int pos, double[] values, int offset, int length)Sets elements in an array using the given double values.voidsetSparse(double v)Sets the non-sparse elements of this array to the specified value May throw an exception if non-sparse elements are not mutableINDArrayslice(int position)Returns the specified major slice of this array as a view (slice along dimension 0) 0 dimensional slice results are permitted, but attempting to slice a 0 dimensional array will result in an error.INDArrayslice(int dimension, int index)Returns a slice view of this array along the specified dimensionintsliceCount()Returns the number of major slices in this array (i.e.AScalarsparse()Coerces this INDArray to a sparse format, without changing its element values.ScalarsparseClone()Creates a fully mutable clone of this array.voidsquare()Squares all elements of the array in placevoidsub(double d)Subtracts a double value from all elements in this arrayvoidsub(INDArray a)Subtracts all the elements of another array from this array, in an elementwise order.AScalarsubArray(int[] offsets, int[] shape)Returns a subarray view of a larger arraydouble[]toDoubleArray()Copies the elements of this array to a new double[] array.voidtoDoubleBuffer(java.nio.DoubleBuffer dest)Copies the elements of this INDArray to the specified double buffer.INDArray[]toSliceArray()Copies the slices of this array to a new INDArray[] Throws an error if the array has no slices (i.e.java.lang.StringtoString()voidvalidate()Validates the internal data structure of the INDArray.-
Methods inherited from class mikera.arrayz.impl.AbstractArray
absCopy, absDiff, absDiffCopy, add, addApplyOp, addCopy, addInnerProduct, addInnerProduct, addMultipleSparse, addOuterProduct, addOuterProductSparse, addPower, addSparse, addSparse, applyOpCopy, asElementList, broadcastCloneLike, broadcastCopyLike, componentCount, copy, density, divide, divideCopy, divideCopy, elementAbsPowSum, elementPowSum, ensureMutable, epsilonEquals, equals, equalsArray, exp, fill, get, get, get, get, get, getComponent, getComponents, getElements, getElements, getShapeClone, getSlices, getSliceViews, getTransposeCopy, isDense, isSameShape, isSparse, join, join, log, multiplyCopy, negateCopy, reciprocal, reciprocalCopy, reduceSlices, reduceSlices, reorder, reorder, rotateView, scale, scaleAdd, scaleAdd, scaleCopy, set, set, set, set, set, setInnerProduct, setMultiple, setMultiple, setSparse, signum, signumCopy, sliceValue, sqrt, squareCopy, sub, subCopy, toStringFull, toVector, withComponents
-
Methods inherited from interface mikera.arrayz.INDArray
absCopy, absDiff, absDiffCopy, addApplyOp, addMultipleSparse, addOuterProduct, addOuterProductSparse, addPower, addSparse, addSparse, applyOpCopy, asElementList, broadcastCloneLike, broadcastCopyLike, componentCount, copy, divide, divideCopy, divideCopy, elementAbsPowSum, elementPowSum, ensureMutable, epsilonEquals, equalsArray, exp, fill, get, get, get, get, get, getComponent, getComponents, getElements, getElements, getShapeClone, getSlices, getSliceViews, getTransposeCopy, isDense, isSameShape, isSparse, isView, join, join, log, multiplyCopy, negateCopy, reciprocal, reciprocalCopy, reduceSlices, reduceSlices, reorder, reorder, rotateView, scale, scaleAdd, scaleAdd, scaleCopy, set, set, set, set, set, setInnerProduct, setMultiple, setMultiple, setSparse, signum, signumCopy, sliceValue, sqrt, squareCopy, subCopy, toVector, withComponents
-
-
-
-
Method Detail
-
get
public abstract double get()
Description copied from interface:INDArrayReturns the double value of a scalar array
-
set
public abstract void set(double value)
Description copied from interface:INDArraySets all elements of an array to a specific double value
-
setSparse
public void setSparse(double v)
Description copied from interface:INDArraySets the non-sparse elements of this array to the specified value May throw an exception if non-sparse elements are not mutable- Specified by:
setSparsein interfaceINDArray- Overrides:
setSparsein classAbstractArray<java.lang.Object>
-
get
public double get(int x)
Description copied from interface:INDArrayReturns the double value at the specified position in a 1D vector- Specified by:
getin interfaceINDArray- Specified by:
getin classAbstractArray<java.lang.Object>
-
get
public double get(int x, int y)Description copied from interface:INDArrayReturns the double value at the specified position in a 2D matrix- Specified by:
getin interfaceINDArray- Specified by:
getin classAbstractArray<java.lang.Object>
-
setElements
public void setElements(int pos, double[] values, int offset, int length)Description copied from interface:INDArraySets elements in an array using the given double values. The source array must contain at least the specified length in terms of number of elements- Specified by:
setElementsin interfaceINDArray- Overrides:
setElementsin classAbstractArray<java.lang.Object>- Parameters:
pos- Offset into this array, expressed in terms of number of elements in row major ordervalues- Element values in a double[] array. There must be at least as many element values as elements in this array.offset- Position in the values array from which to start taking values.length- Number of elements to set.
-
getElements
public void getElements(double[] dest, int offset)Description copied from interface:INDArrayCopies all elements of this array a double array at the specified offset- Specified by:
getElementsin interfaceINDArray- Overrides:
getElementsin classAbstractArray<java.lang.Object>
-
getTranspose
public final AScalar getTranspose()
Description copied from interface:INDArrayReturns the transpose of this array. A transpose of an array is equivalent to reversing the order of dimensions. May or may not return a view depending on the array type.- Specified by:
getTransposein interfaceINDArray- Overrides:
getTransposein classAbstractArray<java.lang.Object>
-
getTransposeView
public final AScalar getTransposeView()
Description copied from interface:INDArrayReturns a transposed view of the array. May throw UnsupportedOperationException if the array type does not support this capability- Specified by:
getTransposeViewin interfaceINDArray- Overrides:
getTransposeViewin classAbstractArray<java.lang.Object>
-
dimensionality
public final int dimensionality()
Description copied from interface:INDArrayReturns the dimensionality of the array (i.e. the number of dimensions in the array shape) e.g. 0 for a scalar, 1 for a vector, 2 for a matrix etc.- Specified by:
dimensionalityin interfaceINDArray
-
slice
public INDArray slice(int position)
Description copied from interface:INDArrayReturns the specified major slice of this array as a view (slice along dimension 0) 0 dimensional slice results are permitted, but attempting to slice a 0 dimensional array will result in an error.
-
slice
public INDArray slice(int dimension, int index)
Description copied from interface:INDArrayReturns a slice view of this array along the specified dimension
-
sliceCount
public final int sliceCount()
Description copied from interface:INDArrayReturns the number of major slices in this array (i.e. the size of dimension 0)- Specified by:
sliceCountin interfaceINDArray
-
getSlices
public java.util.List<java.lang.Object> getSlices()
Description copied from interface:INDArrayReturns a list of all major slices of this array. Returns a list of Double values if a 1-dimensional array is sliced, otherwise a list of INDArray instances- Specified by:
getSlicesin interfaceINDArray- Overrides:
getSlicesin classAbstractArray<java.lang.Object>
-
subArray
public AScalar subArray(int[] offsets, int[] shape)
Description copied from interface:INDArrayReturns a subarray view of a larger array- Specified by:
subArrayin interfaceINDArray- Overrides:
subArrayin classAbstractArray<java.lang.Object>
-
iterator
public java.util.Iterator<java.lang.Object> iterator()
- Specified by:
iteratorin interfacejava.lang.Iterable<java.lang.Object>- Overrides:
iteratorin classAbstractArray<java.lang.Object>
-
isMutable
public boolean isMutable()
Description copied from interface:INDArrayReturns true if the INDArray is mutable (at least partially)- Specified by:
isMutablein interfaceINDArray- Overrides:
isMutablein classAbstractArray<java.lang.Object>
-
isFullyMutable
public boolean isFullyMutable()
Description copied from interface:INDArrayIf this method returns true, the INDArray is guaranteed to be fully mutable in all positions i.e. every position can store any valid double value- Specified by:
isFullyMutablein interfaceINDArray- Overrides:
isFullyMutablein classAbstractArray<java.lang.Object>
-
isElementConstrained
public boolean isElementConstrained()
Description copied from interface:INDArrayReturns true if this array has some constraints on element values- Specified by:
isElementConstrainedin interfaceINDArray- Overrides:
isElementConstrainedin classAbstractArray<java.lang.Object>
-
isZero
public boolean isZero()
Description copied from interface:INDArrayReturns true if the array is zero (all elements equal to zero)- Specified by:
isZeroin interfaceINDArray- Overrides:
isZeroin classAbstractArray<java.lang.Object>
-
isBoolean
public boolean isBoolean()
Description copied from interface:INDArrayReturns true if the array is boolean (contains only 0.0 or 1.0 values)- Specified by:
isBooleanin interfaceINDArray- Overrides:
isBooleanin classAbstractArray<java.lang.Object>
-
add
public void add(double d)
Description copied from interface:INDArrayAdds a double value to all elements in this array. Implementations may optimize the case of 0.0- Specified by:
addin interfaceINDArray- Overrides:
addin classAbstractArray<java.lang.Object>
-
addCopy
public AScalar addCopy(double d)
Description copied from interface:INDArrayCreates a new array equal to this array with a constant value added to every element- Specified by:
addCopyin interfaceINDArray- Overrides:
addCopyin classAbstractArray<java.lang.Object>- Returns:
-
addCopy
public final INDArray addCopy(INDArray a)
Description copied from interface:INDArrayCreates a new array equal to the sum of this array with another array.- Specified by:
addCopyin interfaceINDArray- Overrides:
addCopyin classAbstractArray<java.lang.Object>- Returns:
-
addAt
public void addAt(long i, double v)Description copied from interface:INDArrayAdds to a mutable array, indexed by element position in row major order. This is an unsafe operation: bounds are not checked- Specified by:
addAtin interfaceINDArray- Overrides:
addAtin classAbstractArray<java.lang.Object>
-
addToArray
public void addToArray(double[] data, int offset)Description copied from interface:INDArrayAdds all the elements of this array to a double array at the specified offset, in row-major order- Specified by:
addToArrayin interfaceINDArray- Overrides:
addToArrayin classAbstractArray<java.lang.Object>
-
addInnerProduct
public final void addInnerProduct(INDArray a, INDArray b)
Description copied from interface:INDArrayAdds the inner product of two arrays to this array.- Specified by:
addInnerProductin interfaceINDArray- Overrides:
addInnerProductin classAbstractArray<java.lang.Object>
-
addInnerProduct
public void addInnerProduct(INDArray a, INDArray b, double d)
Description copied from interface:INDArrayAdds a scalar multiple of the inner product of two arrays to this array.- Specified by:
addInnerProductin interfaceINDArray- Overrides:
addInnerProductin classAbstractArray<java.lang.Object>
-
addMultiple
public void addMultiple(INDArray src, double factor)
Description copied from interface:INDArrayAdds a scaled multiple of another array to this array- Specified by:
addMultiplein interfaceINDArray- Overrides:
addMultiplein classAbstractArray<java.lang.Object>
-
addPower
public void addPower(INDArray src, double factor)
Description copied from interface:INDArrayAdds an array with all elements of the source array raised to the specified power- Specified by:
addPowerin interfaceINDArray- Overrides:
addPowerin classAbstractArray<java.lang.Object>
-
sub
public void sub(double d)
Description copied from interface:INDArraySubtracts a double value from all elements in this array- Specified by:
subin interfaceINDArray- Overrides:
subin classAbstractArray<java.lang.Object>
-
add
public void add(INDArray a)
Description copied from interface:INDArrayAdds all the elements of another array to this array, in an elementwise order.- Specified by:
addin interfaceINDArray- Overrides:
addin classAbstractArray<java.lang.Object>
-
sub
public void sub(INDArray a)
Description copied from interface:INDArraySubtracts all the elements of another array from this array, in an elementwise order.- Specified by:
subin interfaceINDArray- Overrides:
subin classAbstractArray<java.lang.Object>
-
negate
public void negate()
Description copied from interface:INDArrayNegates all elements in the array in place- Specified by:
negatein interfaceINDArray- Overrides:
negatein classAbstractArray<java.lang.Object>
-
square
public void square()
Description copied from interface:INDArraySquares all elements of the array in place- Specified by:
squarein interfaceINDArray- Overrides:
squarein classAbstractArray<java.lang.Object>
-
pow
public void pow(double exponent)
Description copied from interface:INDArrayRaises all elements of the array to a specified power in place- Specified by:
powin interfaceINDArray- Overrides:
powin classAbstractArray<java.lang.Object>
-
clamp
public void clamp(double min, double max)Description copied from interface:INDArrayClamps all the elements of this array within the specified [min,max] range- Specified by:
clampin interfaceINDArray- Overrides:
clampin classAbstractArray<java.lang.Object>
-
innerProduct
public INDArray innerProduct(INDArray a)
Description copied from interface:INDArrayCalculates the inner product of this array with another array.- Specified by:
innerProductin interfaceINDArray- Overrides:
innerProductin classAbstractArray<java.lang.Object>
-
innerProduct
public Scalar innerProduct(AScalar a)
Description copied from interface:INDArrayCalculates the inner product of this array with a scalar- Specified by:
innerProductin interfaceINDArray- Overrides:
innerProductin classAbstractArray<java.lang.Object>
-
innerProduct
public Scalar innerProduct(double a)
Description copied from interface:INDArrayCalculates the inner product of this array with a double value- Specified by:
innerProductin interfaceINDArray- Overrides:
innerProductin classAbstractArray<java.lang.Object>
-
innerProduct
public AVector innerProduct(AVector a)
Description copied from interface:INDArrayComputes the inner product of this array with a vector- Specified by:
innerProductin interfaceINDArray- Overrides:
innerProductin classAbstractArray<java.lang.Object>- Parameters:
a- A vector- Returns:
- A new array representing the inner product
-
outerProduct
public INDArray outerProduct(INDArray a)
Description copied from interface:INDArrayCalculates the outer product of this array with another array.- Specified by:
outerProductin interfaceINDArray- Overrides:
outerProductin classAbstractArray<java.lang.Object>
-
get
public double get(int... indexes)
Description copied from interface:INDArrayReturns the double value at the specified index position in an array
-
set
public void set(int[] indexes, double value)Description copied from interface:INDArraySets the element at the given indexed position in a mutable array
-
getShape
public int[] getShape()
Description copied from interface:INDArrayReturns the shape of the array as an array of ints. WARNING: May return the internal int[] array describing the shape. Modifying this may cause undefined behaviour. If you want to guarantee a new int[] array that can be safely modified, use getShapeClone() instead
-
getShape
public int getShape(int dim)
Description copied from interface:INDArrayReturns the dimension size for a specific dimension in the array's shape- Specified by:
getShapein interfaceINDArray- Overrides:
getShapein classAbstractArray<java.lang.Object>
-
getLongShape
public long[] getLongShape()
Description copied from interface:INDArrayReturns the shape of the array as an array of longs.- Specified by:
getLongShapein interfaceINDArray- Overrides:
getLongShapein classAbstractArray<java.lang.Object>
-
elementCount
public final long elementCount()
Description copied from interface:INDArrayReturns the total number of elements in this array. Equivalent to the product of all dimension sizes.- Specified by:
elementCountin interfaceINDArray
-
nonZeroCount
public long nonZeroCount()
Description copied from interface:INDArrayReturns the number of non-zero elements in the array.- Specified by:
nonZeroCountin interfaceINDArray- Overrides:
nonZeroCountin classAbstractArray<java.lang.Object>
-
getElement
public double getElement(long i)
Description copied from interface:INDArrayGets a specific element of this array, indexed in row-major order- Specified by:
getElementin interfaceINDArray- Returns:
- The element value
-
getElements
public void getElements(double[] arr)
Description copied from interface:INDArrayCopies all elements of this INDArray to the specified double array- Specified by:
getElementsin interfaceINDArray- Overrides:
getElementsin classAbstractArray<java.lang.Object>
-
setElements
public void setElements(double... values)
Description copied from interface:INDArraySets all elements in an array using the given double values- Specified by:
setElementsin interfaceINDArray- Overrides:
setElementsin classAbstractArray<java.lang.Object>- Parameters:
values- Element values in a double[] array. There must be at least as many element values as elements in this array.
-
setElements
public void setElements(double[] values, int offset)Description copied from interface:INDArraySets all elements in an array using the given double values- Specified by:
setElementsin interfaceINDArray- Overrides:
setElementsin classAbstractArray<java.lang.Object>- Parameters:
values- Element values in a double[] array. There must be at least as many element values as elements in this array.offset- Position in the values array from which to start taking values.
-
asVector
public AVector asVector()
Description copied from interface:INDArrayConstructs a view of all elements in the array as a single vector in row-major order.- Specified by:
asVectorin interfaceINDArray- Overrides:
asVectorin classAbstractArray<java.lang.Object>
-
reshape
public INDArray reshape(int... dimensions)
Description copied from interface:INDArrayReturns a new array by rearranging the elements of this array into the desired shape Truncates or zero-pads the elements as required to fill the new shape- Specified by:
reshapein interfaceINDArray- Overrides:
reshapein classAbstractArray<java.lang.Object>
-
applyOp
public void applyOp(IOperator op)
Description copied from interface:INDArrayApplies a unary operator to all elements of the array (in-place)- Specified by:
applyOpin interfaceINDArray- Overrides:
applyOpin classAbstractArray<java.lang.Object>- Parameters:
op- The operator to apply to the array
-
applyOp
public void applyOp(Op op)
Description copied from interface:INDArrayApplies a unary operator to all elements of the array (in-place)- Specified by:
applyOpin interfaceINDArray- Overrides:
applyOpin classAbstractArray<java.lang.Object>
-
setApplyOp
public void setApplyOp(Op op, INDArray a)
Description copied from interface:INDArraySets this array to the result of applying an operation to a source array- Specified by:
setApplyOpin interfaceINDArray- Overrides:
setApplyOpin classAbstractArray<java.lang.Object>
-
applyOp
public void applyOp(Op2 op, INDArray b)
Description copied from interface:INDArrayApplies a binary operator to this array and a second array. Broadcasts the second array to the shape of this array if required.- Specified by:
applyOpin interfaceINDArray- Overrides:
applyOpin classAbstractArray<java.lang.Object>
-
applyOp
public void applyOp(Op2 op, double b)
Description copied from interface:INDArrayApplies a binary operator to this array and a double value. Works as if the double value was broadcast to the shape of this array.- Specified by:
applyOpin interfaceINDArray- Overrides:
applyOpin classAbstractArray<java.lang.Object>
-
reduce
public double reduce(Op2 op, double init)
Description copied from interface:INDArrayReduces over all elements of the array in row-major order. Applies the operator to the initial/previous result at each step. Returns the final result.- Specified by:
reducein interfaceINDArray- Overrides:
reducein classAbstractArray<java.lang.Object>
-
reduce
public final double reduce(Op2 op)
Description copied from interface:INDArrayReduces over all elements of the array in row-major order. Applies the operator to the previous result at each step. Returns the final result.- Specified by:
reducein interfaceINDArray- Overrides:
reducein classAbstractArray<java.lang.Object>
-
clone
public Scalar clone()
Description copied from interface:INDArrayReturns a clone of the array data, as a new array which will be fully mutable and may be of a different class to the original. Clone should attempt to return the most efficient possible array type. Clone should preserve sparsity property where possible, but this is not guaranteed.- Specified by:
clonein interfaceINDArray- Overrides:
clonein classAbstractArray<java.lang.Object>
-
multiply
public void multiply(double factor)
Description copied from interface:INDArrayMultiplies all elements of the array in place by a given double value- Specified by:
multiplyin interfaceINDArray- Overrides:
multiplyin classAbstractArray<java.lang.Object>
-
divide
public void divide(double factor)
Description copied from interface:INDArrayDivides all elements by a given factor- Specified by:
dividein interfaceINDArray- Overrides:
dividein classAbstractArray<java.lang.Object>
-
multiply
public void multiply(INDArray a)
Description copied from interface:INDArrayMultiplies all elements by the equivalent elements in a second array, i.e. performs elementwise multiplication. If matrix-style multiplication is required, use innerProduct instead.- Specified by:
multiplyin interfaceINDArray- Overrides:
multiplyin classAbstractArray<java.lang.Object>
-
multiplyCopy
public final INDArray multiplyCopy(INDArray a)
Description copied from interface:INDArrayMultiplies all elements by the equivalent elements in a second array, i.e. performs elementwise multiplication. Returns a new array. If matrix-style multiplication is required, use innerProduct instead.- Specified by:
multiplyCopyin interfaceINDArray- Overrides:
multiplyCopyin classAbstractArray<java.lang.Object>
-
elementSum
public final double elementSum()
Description copied from interface:INDArrayReturns the sum of all elements in this array.- Specified by:
elementSumin interfaceINDArray- Overrides:
elementSumin classAbstractArray<java.lang.Object>
-
elementProduct
public final double elementProduct()
Description copied from interface:INDArrayReturns the product of all elements in the array.- Specified by:
elementProductin interfaceINDArray- Overrides:
elementProductin classAbstractArray<java.lang.Object>- Returns:
-
elementMaxAbs
public double elementMaxAbs()
Description copied from interface:INDArrayReturns the maximum absolute element value in this array. Throws an error if there are no elements.- Specified by:
elementMaxAbsin interfaceINDArray- Overrides:
elementMaxAbsin classAbstractArray<java.lang.Object>
-
elementMax
public double elementMax()
Description copied from interface:INDArrayReturns the maximum element value in this array. Throws an error if there are no elements.- Specified by:
elementMaxin interfaceINDArray- Overrides:
elementMaxin classAbstractArray<java.lang.Object>
-
elementMin
public double elementMin()
Description copied from interface:INDArrayReturns the maximum element value in this array. Throws an error if there are no elements.- Specified by:
elementMinin interfaceINDArray- Overrides:
elementMinin classAbstractArray<java.lang.Object>
-
elementSquaredSum
public final double elementSquaredSum()
Description copied from interface:INDArrayReturns the sum of squared elements in this array.- Specified by:
elementSquaredSumin interfaceINDArray- Overrides:
elementSquaredSumin classAbstractArray<java.lang.Object>
-
broadcast
public INDArray broadcast(int... targetShape)
Description copied from interface:INDArrayReturns a view of this array broadcasted up to a larger shape- Specified by:
broadcastin interfaceINDArray- Overrides:
broadcastin classAbstractArray<java.lang.Object>
-
broadcastLike
public INDArray broadcastLike(INDArray v)
Description copied from interface:INDArrayBroadcasts an array to match the shape of the target- Specified by:
broadcastLikein interfaceINDArray- Overrides:
broadcastLikein classAbstractArray<java.lang.Object>- Parameters:
v- The target array
-
broadcastLike
public AVector broadcastLike(AVector v)
Description copied from interface:INDArrayBroadcasts an array to match the shape of the target vector- Specified by:
broadcastLikein interfaceINDArray- Overrides:
broadcastLikein classAbstractArray<java.lang.Object>- Parameters:
v- The target vector
-
broadcastLike
public AMatrix broadcastLike(AMatrix v)
Description copied from interface:INDArrayBroadcasts an array to match the shape of the target matrix- Specified by:
broadcastLikein interfaceINDArray- Overrides:
broadcastLikein classAbstractArray<java.lang.Object>- Parameters:
v- The target matrix
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classAbstractArray<java.lang.Object>
-
epsilonEquals
public boolean epsilonEquals(INDArray a, double epsilon)
Description copied from interface:INDArrayTests is this array is approximately equal to another array, up to a given tolerance (epsilon) The arrays must have the same shape- Specified by:
epsilonEqualsin interfaceINDArray- Overrides:
epsilonEqualsin classAbstractArray<java.lang.Object>
-
compareTo
public int compareTo(INDArray a)
- Specified by:
compareToin interfacejava.lang.Comparable<INDArray>- Overrides:
compareToin classAbstractArray<java.lang.Object>
-
equals
public boolean equals(INDArray o)
Description copied from interface:INDArrayChecks if two arrays are equal exactly in terms of both value and shape Element equality checks are consistent with compareTo- Specified by:
equalsin interfaceINDArray- Overrides:
equalsin classAbstractArray<java.lang.Object>
-
equalsArray
public boolean equalsArray(double[] data, int offset)Description copied from interface:INDArrayReturns true if the elements in this array exactly match the elements in the given array, in row-major order- Specified by:
equalsArrayin interfaceINDArray- Overrides:
equalsArrayin classAbstractArray<java.lang.Object>- Parameters:
data- Array of double element values to check for equalityoffset- Offset into the data array- Returns:
-
equals
public boolean equals(AScalar o)
Returns true if this scalar is equal in value to another scalar.- Parameters:
o-- Returns:
-
hashCode
public int hashCode()
- Overrides:
hashCodein classAbstractArray<java.lang.Object>
-
toString
public java.lang.String toString()
- Overrides:
toStringin classAbstractArray<java.lang.Object>
-
elementIterator
public java.util.Iterator<java.lang.Double> elementIterator()
Description copied from interface:INDArrayReturns an iterator over all elements in this array, in row-major order- Specified by:
elementIteratorin interfaceINDArray- Overrides:
elementIteratorin classAbstractArray<java.lang.Object>
-
toDoubleBuffer
public void toDoubleBuffer(java.nio.DoubleBuffer dest)
Description copied from interface:INDArrayCopies the elements of this INDArray to the specified double buffer.- Specified by:
toDoubleBufferin interfaceINDArray- Overrides:
toDoubleBufferin classAbstractArray<java.lang.Object>
-
asDoubleArray
public double[] asDoubleArray()
Description copied from interface:INDArrayReturns the underlying double array representing the densely packed elements of this array. Modifications to this double array will change the original array. Returns null if there is no such array.- Specified by:
asDoubleArrayin interfaceINDArray- Overrides:
asDoubleArrayin classAbstractArray<java.lang.Object>
-
toDoubleArray
public double[] toDoubleArray()
Description copied from interface:INDArrayCopies the elements of this array to a new double[] array.- Specified by:
toDoubleArrayin interfaceINDArray- Overrides:
toDoubleArrayin classAbstractArray<java.lang.Object>
-
toSliceArray
public INDArray[] toSliceArray()
Description copied from interface:INDArrayCopies the slices of this array to a new INDArray[] Throws an error if the array has no slices (i.e. is zero-dimensional)- Specified by:
toSliceArrayin interfaceINDArray- Overrides:
toSliceArrayin classAbstractArray<java.lang.Object>
-
exactClone
public abstract AScalar exactClone()
Description copied from interface:INDArrayCreates a deep clone of an array, using the same class implementation as the original array- Specified by:
exactClonein interfaceINDArray- Returns:
- A clone of the original array
-
mutable
public AScalar mutable()
Description copied from interface:INDArrayCoerces this INDArray to a fully mutable format. May return the same INDArray if already fully mutable
-
elementsEqual
public boolean elementsEqual(double value)
Description copied from interface:INDArrayReturns true if all elements are equal to a specific value- Specified by:
elementsEqualin interfaceINDArray- Overrides:
elementsEqualin classAbstractArray<java.lang.Object>
-
sparse
public AScalar sparse()
Description copied from interface:INDArrayCoerces this INDArray to a sparse format, without changing its element values. May return the same INDArray if already sparse. May also mutate the internal structure of the original NDArray, or create a view over parts of the original INDArray. You should take a defensive copy of the original NDArray if any of this concerns you. The returned sparse array may not be fully mutable in all elements.- Specified by:
sparsein interfaceINDArray- Overrides:
sparsein classAbstractArray<java.lang.Object>
-
dense
public INDArray dense()
Description copied from interface:INDArrayCoerces this INDArray to a dense format, without changing its element values. May return the same INDArray if already dense. May also mutate the internal structure of the original NDArray, or create a view over parts of the original INDArray. You should take a defensive copy of the original NDArray if any of this concerns you. The returned dense array may not be fully mutable in all elements.- Specified by:
densein interfaceINDArray- Overrides:
densein classAbstractArray<java.lang.Object>
-
denseClone
public final Scalar denseClone()
Description copied from interface:INDArrayCreates a fully mutable dense clone of this array. Will always use a dense format, even if the array data is sparse.- Specified by:
denseClonein interfaceINDArray- Overrides:
denseClonein classAbstractArray<java.lang.Object>
-
sparseClone
public final Scalar sparseClone()
Description copied from interface:INDArrayCreates a fully mutable clone of this array. Will use a sparse format if possible.- Specified by:
sparseClonein interfaceINDArray- Overrides:
sparseClonein classAbstractArray<java.lang.Object>
-
immutable
public ImmutableScalar immutable()
Description copied from interface:INDArrayReturns an immutable version of this array. May return the same array if already immutable. Guarantees a defensive copy if the array is mutable.
-
validate
public void validate()
Description copied from interface:INDArrayValidates the internal data structure of the INDArray. Throws an exception on failure. Failure indicates a serious bug and/or data corruption.- Specified by:
validatein interfaceINDArray- Overrides:
validatein classAbstractArray<java.lang.Object>
-
abs
public void abs()
Description copied from interface:INDArrayReplaces all elements of this array with their absolute values, according to Math.abs(double)- Specified by:
absin interfaceINDArray- Overrides:
absin classAbstractArray<java.lang.Object>
-
hasUncountable
public boolean hasUncountable()
Description copied from class:AbstractArrayReturns true if any element is this array is NaN or infinite- Specified by:
hasUncountablein interfaceINDArray- Overrides:
hasUncountablein classAbstractArray<java.lang.Object>- Returns:
- True if any element is this array is NaN or infinite, false otherwise
-
-
DMelt 3.0 © DataMelt by jWork.ORG