mikera.arrayz.impl
Class SliceArray<T extends INDArray>
- java.lang.Object
-
- mikera.arrayz.impl.AbstractArray<INDArray>
-
- mikera.arrayz.impl.BaseShapedArray
-
- mikera.arrayz.impl.SliceArray<T>
-
- Type Parameters:
T-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<INDArray>, java.lang.Iterable<INDArray>, INDArray
public final class SliceArray<T extends INDArray> extends BaseShapedArray
A general N-dimensional double array implemented as a collection of (n-1) dimensional slices Must have dimensionality 1 or above, and contain at least one slice- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidapplyOp(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)AVectorasVector()Constructs a view of all elements in the array as a single vector in row-major order.intcomponentCount()Returns the number of components of this array.static <T extends INDArray>
SliceArray<T>create(INDArray a)static SliceArray<INDArray>create(java.util.List<INDArray> slices)static SliceArray<INDArray>create(java.util.List<INDArray> slices, int[] shape)intdimensionality()Returns the dimensionality of the array (i.e.longelementCount()Returns the total number of elements in this array.booleanequals(INDArray a)Checks if two arrays are equal exactly in terms of both value and shape Element equality checks are consistent with compareTobooleanequalsArray(double[] values, int offset)Returns true if the elements in this array exactly match the elements in the given array, in row-major orderSliceArray<T>exactClone()Creates a deep clone of an array, using the same class implementation as the original arrayvoidfill(double value)Fills this array with a single double value.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 matrixTgetComponent(int k)Gets a component from the array at the specified index Will throw an error if components are not supported, or if the component is out of bounds as defined by 0 <= kINDArray[]getComponents()Gets all components in a new array, with length componentCount();long[]getLongShape()Returns the shape of the array as an array of longs.java.util.List<?>getSlices()Returns a list of all major slices of this array.INDArrayinnerProduct(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)booleanisView()Return true if this array is considered as a view type.booleanisZero()Returns true if the array is zero (all elements equal to zero)voidmultiply(double d)Multiplies all elements of the array in place by a given double valuestatic <T extends INDArray>
SliceArray<T>of(T... slices)Create a SliceArray by wrapping a set of slices.INDArrayouterProduct(INDArray a)Calculates the outer product of this array with another array.static SliceArray<INDArray>repeat(INDArray slice, int n)Create a SliceArray by repeating the same slice instance a given number of timesINDArrayreshape(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 shapevoidset(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 arrayTslice(int majorSlice)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 dimensiondouble[]toDoubleArray()Copies the elements of this array to a new double[] array.INDArray[]toSliceArray()Copies the slices of this array to a new INDArray[] Throws an error if the array has no slices (i.e.voidvalidate()Validates the internal data structure of the INDArray.-
Methods inherited from class mikera.arrayz.impl.BaseShapedArray
getElement, getShape, getShape, getShapeClone, reduce, reduce, sliceCount
-
Methods inherited from class mikera.arrayz.impl.AbstractArray
abs, absCopy, absDiff, absDiffCopy, add, add, add, addApplyOp, addAt, addCopy, addCopy, addCopy, addInnerProduct, addInnerProduct, addInnerProduct, addInnerProduct, addMultiple, addMultipleSparse, addOuterProduct, addOuterProductSparse, addPower, addPower, addSparse, addSparse, addToArray, applyOp, applyOp, applyOpCopy, asDoubleArray, asElementList, broadcast, broadcastCloneLike, broadcastCopyLike, broadcastLike, broadcastLike, broadcastLike, clamp, clone, compareTo, copy, dense, denseClone, density, divide, divide, divideCopy, divideCopy, elementAbsPowSum, elementIterator, elementMax, elementMaxAbs, elementMin, elementPowSum, elementProduct, elementsEqual, elementSquaredSum, elementSum, ensureMutable, epsilonEquals, epsilonEquals, equals, equals, equalsArray, exp, get, get, get, get, get, getElements, getElements, getElements, getElements, getSlices, getSliceViews, getTranspose, getTransposeCopy, getTransposeView, hashCode, hasUncountable, immutable, innerProduct, innerProduct, innerProduct, isDense, isSameShape, isSparse, iterator, join, join, log, multiply, multiplyCopy, multiplyCopy, mutable, negate, negateCopy, nonZeroCount, pow, reciprocal, reciprocalCopy, reduceSlices, reduceSlices, reorder, reorder, rotateView, scale, scaleAdd, scaleAdd, scaleCopy, set, set, set, set, set, setApplyOp, setElements, setElements, setElements, setInnerProduct, setMultiple, setMultiple, setSparse, setSparse, signum, signumCopy, sliceValue, sparse, sparseClone, sqrt, square, squareCopy, sub, sub, sub, subArray, subCopy, toDoubleBuffer, toString, toStringFull, toVector, withComponents
-
-
-
-
Method Detail
-
create
public static <T extends INDArray> SliceArray<T> create(INDArray a)
-
of
@SafeVarargs public static <T extends INDArray> SliceArray<T> of(T... slices)
Create a SliceArray by wrapping a set of slices.- Parameters:
slices-- Returns:
-
repeat
public static SliceArray<INDArray> repeat(INDArray slice, int n)
Create a SliceArray by repeating the same slice instance a given number of times- Parameters:
slice-n-- Returns:
-
create
public static SliceArray<INDArray> create(java.util.List<INDArray> slices)
-
create
public static SliceArray<INDArray> create(java.util.List<INDArray> slices, int[] shape)
-
dimensionality
public 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- Overrides:
dimensionalityin classBaseShapedArray
-
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<INDArray>
-
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(double value)
Description copied from interface:INDArraySets all elements of an array to a specific double value- Specified by:
setin interfaceINDArray- Overrides:
setin classAbstractArray<INDArray>
-
fill
public void fill(double value)
Description copied from interface:INDArrayFills this array with a single double value. Requires the array to be mutable.- Specified by:
fillin interfaceINDArray- Overrides:
fillin classAbstractArray<INDArray>
-
set
public void set(int[] indexes, double value)Description copied from interface:INDArraySets the element at the given indexed position in a mutable array
-
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<INDArray>
-
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<INDArray>
-
slice
public T slice(int majorSlice)
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.
-
componentCount
public int componentCount()
Description copied from interface:INDArrayReturns the number of components of this array. May return 0 if components are not supported- Specified by:
componentCountin interfaceINDArray- Overrides:
componentCountin classAbstractArray<INDArray>- Returns:
-
getComponent
public T getComponent(int k)
Description copied from interface:INDArrayGets a component from the array at the specified index Will throw an error if components are not supported, or if the component is out of bounds as defined by 0 <= k- Specified by:
getComponentin interfaceINDArray- Overrides:
getComponentin classAbstractArray<INDArray>- Returns:
-
slice
public INDArray slice(int dimension, int index)
Description copied from interface:INDArrayReturns a slice view of this array along the specified dimension
-
elementCount
public 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- Overrides:
elementCountin classBaseShapedArray
-
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<INDArray>
-
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<INDArray>
-
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<INDArray>
-
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<INDArray>
-
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 classBaseShapedArray
-
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<INDArray>
-
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<INDArray>
-
isView
public boolean isView()
Description copied from interface:INDArrayReturn true if this array is considered as a view type. This indicates (but does not guarantee): a) Data is *likely* to be shared with other arrays, so mutation of one may affect others b) It is *unlikely* to be in the most efficient general purpose format isView is intended to be used as for heuristics. It should *not* be used where the outcome might affect correctness.
-
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<INDArray>
-
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<INDArray>- Parameters:
op- The operator to apply to the array
-
multiply
public void multiply(double d)
Description copied from interface:INDArrayMultiplies all elements of the array in place by a given double value- Specified by:
multiplyin interfaceINDArray- Overrides:
multiplyin classAbstractArray<INDArray>
-
equals
public boolean equals(INDArray a)
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<INDArray>
-
exactClone
public SliceArray<T> exactClone()
Description copied from interface:INDArrayCreates a deep clone of an array, using the same class implementation as the original array- Returns:
- A clone of the original array
-
getSlices
public java.util.List<?> 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<INDArray>
-
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<INDArray>
-
getComponents
public INDArray[] getComponents()
Description copied from interface:INDArrayGets all components in a new array, with length componentCount();- Specified by:
getComponentsin interfaceINDArray- Overrides:
getComponentsin classAbstractArray<INDArray>- Returns:
-
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<INDArray>
-
equalsArray
public boolean equalsArray(double[] values, 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<INDArray>- Parameters:
values- Array of double element values to check for equalityoffset- Offset into the data array- Returns:
-
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<INDArray>
-
get
public double get()
Description copied from interface:INDArrayReturns the double value of a scalar array- Specified by:
getin interfaceINDArray- Specified by:
getin classAbstractArray<INDArray>
-
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<INDArray>
-
-
DMelt 3.0 © DataMelt by jWork.ORG
You see the box below because you did not login.