mikera.arrayz.impl
Class ImmutableArray
- java.lang.Object
-
- mikera.arrayz.impl.AbstractArray<INDArray>
-
- mikera.arrayz.impl.BaseShapedArray
-
- mikera.arrayz.impl.BaseNDArray
-
- mikera.arrayz.impl.ImmutableArray
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<INDArray>, java.lang.Iterable<INDArray>, IDense, IStridedArray, INDArray
public class ImmutableArray extends BaseNDArray implements IDense
General immutable N-dimensional array class Uses strided array storage- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description AVectorasVector()Constructs a view of all elements in the array as a single vector in row-major order.static INDArraycreate(INDArray a)intdimensionality()Returns the dimensionality of the array (i.e.longelementCount()Returns the total number of elements in this array.booleanequalsArray(double[] data, int offset)Returns true if the elements in this array exactly match the elements in the given array, in row-major orderINDArrayexactClone()Creates a deep clone of an array, using the same class implementation as the original arraydoubleget(int... indexes)Returns the double value at the specified index position in an arraydouble[]getArray()Gets the underlying data array for this strided array Unsafe operation - may allow modification of otherwise immutable arraysintgetIndex(int... indexes)long[]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.int[]getShapeClone()Returns the shape of the array as an array of ints, guaranteed to be a new array i.e.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.voidset(int[] indexes, double value)Sets the element at the given indexed position in a mutable arrayINDArrayslice(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 dimensionintsliceCount()Returns the number of major slices in this array (i.e.INDArraysparseClone()Creates a fully mutable clone of this array.ImmutableArraysubArray(int[] offsets, int[] shape)Returns a subarray view of a larger arrayvoidtoDoubleBuffer(java.nio.DoubleBuffer dest)Copies the elements of this INDArray to the specified double buffer.static INDArraywrap(double[] data, int[] shape)-
Methods inherited from class mikera.arrayz.impl.BaseNDArray
get, get, get, getArrayOffset, getShape, getStride, getStrides, isPackedArray
-
Methods inherited from class mikera.arrayz.impl.BaseShapedArray
getElement, isZero, reduce, reduce
-
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, applyOp, applyOp, applyOpCopy, asDoubleArray, asElementList, broadcast, broadcastCloneLike, broadcastCopyLike, broadcastLike, broadcastLike, broadcastLike, clamp, clone, compareTo, componentCount, copy, dense, denseClone, density, divide, divide, divideCopy, divideCopy, elementAbsPowSum, elementIterator, elementMax, elementMaxAbs, elementMin, elementPowSum, elementProduct, elementsEqual, elementSquaredSum, elementSum, ensureMutable, epsilonEquals, epsilonEquals, equals, equals, equals, equalsArray, exp, fill, get, get, get, get, get, getComponent, getComponents, getElements, getElements, getElements, getElements, getSlices, getSlices, getSliceViews, getTranspose, getTransposeCopy, getTransposeView, hashCode, hasUncountable, immutable, innerProduct, innerProduct, innerProduct, innerProduct, isBoolean, isDense, isSameShape, isSparse, iterator, join, join, log, multiply, multiply, multiplyCopy, multiplyCopy, mutable, negate, negateCopy, nonZeroCount, outerProduct, pow, reciprocal, reciprocalCopy, reduceSlices, reduceSlices, reorder, reorder, reshape, rotateView, scale, scaleAdd, scaleAdd, scaleCopy, set, set, set, set, set, set, setApplyOp, setElements, setElements, setElements, setInnerProduct, setMultiple, setMultiple, setSparse, setSparse, signum, signumCopy, sliceValue, sparse, sqrt, square, squareCopy, sub, sub, sub, subCopy, toDoubleArray, toSliceArray, toString, toStringFull, toVector, validate, withComponents
-
Methods inherited from interface mikera.arrayz.INDArray
abs, absCopy, absDiff, absDiffCopy, add, add, addApplyOp, addAt, addCopy, addCopy, addInnerProduct, addInnerProduct, addMultiple, addMultipleSparse, addOuterProduct, addOuterProductSparse, addPower, addPower, addSparse, addSparse, addToArray, applyOp, applyOp, applyOp, applyOp, applyOpCopy, asDoubleArray, asElementList, broadcast, broadcastCloneLike, broadcastCopyLike, broadcastLike, broadcastLike, broadcastLike, clamp, clone, componentCount, copy, dense, denseClone, divide, divide, divideCopy, divideCopy, elementAbsPowSum, elementIterator, elementMax, elementMaxAbs, elementMin, elementPowSum, elementProduct, elementsEqual, elementSquaredSum, elementSum, ensureMutable, epsilonEquals, epsilonEquals, equals, equalsArray, exp, fill, get, get, get, get, get, getComponent, getComponents, getElement, getElements, getElements, getElements, getElements, getSlices, getSlices, getSliceViews, getTranspose, getTransposeCopy, getTransposeView, hasUncountable, immutable, innerProduct, innerProduct, innerProduct, innerProduct, isBoolean, isDense, isSameShape, isSparse, isZero, join, join, log, multiply, multiply, multiplyCopy, multiplyCopy, mutable, negate, negateCopy, nonZeroCount, outerProduct, pow, reciprocal, reciprocalCopy, reduce, reduce, reduceSlices, reduceSlices, reorder, reorder, reshape, rotateView, scale, scaleAdd, scaleAdd, scaleCopy, set, set, set, set, set, set, setApplyOp, setElements, setElements, setElements, setInnerProduct, setMultiple, setMultiple, setSparse, setSparse, signum, signumCopy, sliceValue, sparse, sqrt, square, squareCopy, sub, sub, subCopy, toDoubleArray, toSliceArray, toVector, validate, withComponents
-
-
-
-
Method Detail
-
wrap
public static INDArray wrap(double[] data, 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 classBaseNDArray
-
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>
-
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>
-
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- Specified by:
getShapein interfaceINDArray- Overrides:
getShapein classBaseShapedArray
-
getShapeClone
public int[] getShapeClone()
Description copied from interface:INDArrayReturns the shape of the array as an array of ints, guaranteed to be a new array i.e. will perform a defensive copy of any internal shape array if required.- Specified by:
getShapeClonein interfaceINDArray- Overrides:
getShapeClonein 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 classBaseNDArray
-
getIndex
public int getIndex(int... indexes)
- Overrides:
getIndexin classBaseNDArray
-
get
public double get(int... indexes)
Description copied from interface:INDArrayReturns the double value at the specified index position in an array- Specified by:
getin interfaceINDArray- Overrides:
getin classBaseNDArray
-
set
public void set(int[] indexes, double value)Description copied from interface:INDArraySets the element at the given indexed position in a mutable array
-
slice
public INDArray 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.
-
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 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- Overrides:
sliceCountin classBaseShapedArray
-
subArray
public ImmutableArray subArray(int[] offsets, int[] shape)
Description copied from interface:INDArrayReturns a subarray view of a larger array- Specified by:
subArrayin interfaceINDArray- Overrides:
subArrayin classAbstractArray<INDArray>
-
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 classBaseNDArray
-
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.
-
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>
-
exactClone
public INDArray 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
-
sparseClone
public INDArray 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<INDArray>
-
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<INDArray>
-
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<INDArray>- Parameters:
data- Array of double element values to check for equalityoffset- Offset into the data array- Returns:
-
getArray
public double[] getArray()
Description copied from interface:IStridedArrayGets the underlying data array for this strided array Unsafe operation - may allow modification of otherwise immutable arrays- Specified by:
getArrayin interfaceIStridedArray- Returns:
-
-
DMelt 3.0 © DataMelt by jWork.ORG