Documentation of 'mikera.arrayz.NDArray' Java class
NDArray
mikera.arrayz

Class NDArray

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<INDArray>, java.lang.Iterable<INDArray>, IStridedArray, INDArray


    public final class NDArray
    extends BaseNDArray
    General purpose dense strided NDArray class. Allows arbitrary strided access over a dense double[] array.
    See Also:
    Serialized Form
    • Method Detail

      • wrap

        public static NDArray wrap(double[] data,
                                   int[] shape)
        Wraps the given double[] data in an NDArray with the given shape. Does *not* take a defensive copy of either the data or shape array.
        Parameters:
        data -
        shape -
        Returns:
      • newArray

        public static NDArray newArray(int... shape)
        Creates a new zero-filled NDArray with the given shape.
        Parameters:
        shape -
        Returns:
      • set

        public void set(double value)
        Description copied from interface: INDArray
        Sets all elements of an array to a specific double value
        Specified by:
        set in interface INDArray
        Overrides:
        set in class AbstractArray<INDArray>
      • set

        public void set(int x,
                        double value)
        Description copied from interface: INDArray
        Sets a value at a given position in a mutable 1D array
        Specified by:
        set in interface INDArray
        Overrides:
        set in class AbstractArray<INDArray>
      • set

        public void set(int x,
                        int y,
                        double value)
        Description copied from interface: INDArray
        Sets a value at a given position in a mutable 2D array
        Specified by:
        set in interface INDArray
        Overrides:
        set in class AbstractArray<INDArray>
      • set

        public void set(int[] indexes,
                        double value)
        Description copied from interface: INDArray
        Sets the element at the given indexed position in a mutable array
      • getTranspose

        public INDArray getTranspose()
        Description copied from interface: INDArray
        Returns 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:
        getTranspose in interface INDArray
        Overrides:
        getTranspose in class AbstractArray<INDArray>
      • reshape

        public INDArray reshape(int... dimensions)
        Description copied from interface: INDArray
        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 shape
        Specified by:
        reshape in interface INDArray
        Overrides:
        reshape in class AbstractArray<INDArray>
      • slice

        public INDArray slice(int majorSlice)
        Description copied from interface: INDArray
        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.
      • slice

        public INDArray slice(int dimension,
                              int index)
        Description copied from interface: INDArray
        Returns a slice view of this array along the specified dimension
      • isFullyMutable

        public boolean isFullyMutable()
        Description copied from interface: INDArray
        If 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:
        isFullyMutable in interface INDArray
        Overrides:
        isFullyMutable in class AbstractArray<INDArray>
      • isView

        public boolean isView()
        Description copied from interface: INDArray
        Return 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(IOperator op)
        Description copied from interface: INDArray
        Applies a unary operator to all elements of the array (in-place)
        Specified by:
        applyOp in interface INDArray
        Overrides:
        applyOp in class AbstractArray<INDArray>
        Parameters:
        op - The operator to apply to the array
      • equals

        public boolean equals(INDArray a)
        Description copied from interface: INDArray
        Checks if two arrays are equal exactly in terms of both value and shape Element equality checks are consistent with compareTo
        Specified by:
        equals in interface INDArray
        Overrides:
        equals in class AbstractArray<INDArray>
      • exactClone

        public NDArray exactClone()
        Description copied from interface: INDArray
        Creates a deep clone of an array, using the same class implementation as the original array
        Returns:
        A clone of the original array
      • clone

        public INDArray clone()
        Description copied from interface: INDArray
        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. 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:
        clone in interface INDArray
        Overrides:
        clone in class AbstractArray<INDArray>
      • setElements

        public void setElements(int pos,
                                double[] values,
                                int offset,
                                int length)
        Description copied from interface: INDArray
        Sets 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:
        setElements in interface INDArray
        Overrides:
        setElements in class AbstractArray<INDArray>
        Parameters:
        pos - Offset into this array, expressed in terms of number of elements in row major order
        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.
        length - Number of elements to set.
      • asDoubleArray

        public double[] asDoubleArray()
        Description copied from interface: INDArray
        Returns 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:
        asDoubleArray in interface INDArray
        Overrides:
        asDoubleArray in class AbstractArray<INDArray>
      • getSlices

        public java.util.List<INDArray> getSlices()
        Description copied from interface: INDArray
        Returns 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:
        getSlices in interface INDArray
        Overrides:
        getSlices in class AbstractArray<INDArray>
      • validate

        public void validate()
        Description copied from interface: INDArray
        Validates the internal data structure of the INDArray. Throws an exception on failure. Failure indicates a serious bug and/or data corruption.
        Specified by:
        validate in interface INDArray
        Overrides:
        validate in class AbstractArray<INDArray>
      • immutable

        public INDArray immutable()
        Description copied from interface: INDArray
        Returns an immutable version of this array. May return the same array if already immutable. Guarantees a defensive copy if the array is mutable.
        Specified by:
        immutable in interface INDArray
        Overrides:
        immutable in class AbstractArray<INDArray>
      • getArray

        public double[] getArray()
        Description copied from interface: IStridedArray
        Gets the underlying data array for this strided array Unsafe operation - may allow modification of otherwise immutable arrays
        Returns:
      • wrapStrided

        public static INDArray wrapStrided(double[] data,
                                           int offset,
                                           int[] shape,
                                           int[] strides)

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.