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

Class Array

    • Method Detail

      • wrap

        public static Array wrap(double[] data,
                                 int... shape)
        Wraps double[] array data in an Array of the specified shape. The number of elements in the array must exactly match the length of the array.
        Parameters:
        data -
        shape -
        Returns:
      • wrap

        public static Array wrap(Vector v)
        Wraps the underlying data from a dense Vector as an array with the same shape
        Parameters:
        v -
        Returns:
      • wrap

        public static Array wrap(Matrix m)
        Wraps the underlying data from a dense Matrix as an array with the same shape
        Parameters:
        v -
        Returns:
      • newArray

        public static Array newArray(int... shape)
        Creates a new zero-filled mutable Array of the specified shape.
        Parameters:
        shape -
        Returns:
      • create

        public static Array create(INDArray a)
        Crates a new Array with a copy of the data from the specified array, in the same shape
        Parameters:
        a -
        Returns:
      • dimensionality

        public int dimensionality()
        Description copied from interface: INDArray
        Returns 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:
        dimensionality in interface INDArray
        Overrides:
        dimensionality in class BaseShapedArray
      • getStride

        public int getStride(int dim)
        Description copied from interface: IStridedArray
        Gets the stide for a specific dimension in this strided array.
        Specified by:
        getStride in interface IStridedArray
        Returns:
      • get

        public double get(int... indexes)
        Description copied from interface: INDArray
        Returns the double value at the specified index position in an array
        Specified by:
        get in interface 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
        Specified by:
        set in interface INDArray
      • toVector

        public Vector toVector()
        Description copied from interface: INDArray
        Coerces the array into a flattened dense Vector, in row-major order. May return the same array if it is already a Vector instance.
        Specified by:
        toVector in interface INDArray
        Overrides:
        toVector 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.
        Specified by:
        slice in interface INDArray
      • slice

        public INDArray slice(int dimension,
                              int index)
        Description copied from interface: INDArray
        Returns a slice view of this array along the specified dimension
        Specified by:
        slice in interface INDArray
      • 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>
      • elementCount

        public long elementCount()
        Description copied from interface: INDArray
        Returns the total number of elements in this array. Equivalent to the product of all dimension sizes.
        Specified by:
        elementCount in interface INDArray
        Overrides:
        elementCount in class BaseShapedArray
      • abs

        public void abs()
        Description copied from interface: INDArray
        Replaces all elements of this array with their absolute values, according to Math.abs(double)
        Specified by:
        abs in interface INDArray
        Overrides:
        abs in class AbstractArray<INDArray>
      • signum

        public void signum()
        Description copied from interface: INDArray
        Calculates the signum of all elements of this mutable array Sets each component of the array to its sign value (-1, 0 or 1)
        Specified by:
        signum in interface INDArray
        Overrides:
        signum in class AbstractArray<INDArray>
      • exp

        public void exp()
        Description copied from interface: INDArray
        Computes the function e^x (in-place) for all array elements
        Specified by:
        exp in interface INDArray
        Overrides:
        exp in class AbstractArray<INDArray>
      • log

        public void log()
        Description copied from interface: INDArray
        Computes the natural logarithm (in-place) for all array elements
        Specified by:
        log in interface INDArray
        Overrides:
        log in class AbstractArray<INDArray>
      • 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.
        Specified by:
        isView in interface INDArray
      • reduce

        public double reduce(Op2 op)
        Description copied from interface: INDArray
        Reduces 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:
        reduce in interface INDArray
        Overrides:
        reduce in class BaseShapedArray
      • reduce

        public double reduce(Op2 op,
                             double init)
        Description copied from interface: INDArray
        Reduces 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:
        reduce in interface INDArray
        Overrides:
        reduce in class BaseShapedArray
      • 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 Array exactClone()
        Description copied from interface: INDArray
        Creates a deep clone of an array, using the same class implementation as the original array
        Specified by:
        exactClone in interface INDArray
        Returns:
        A clone of the original array
      • 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.
      • getElements

        public void getElements(double[] values,
                                int offset)
        Description copied from interface: INDArray
        Copies all elements of this array a double array at the specified offset
        Specified by:
        getElements in interface INDArray
        Overrides:
        getElements in class AbstractArray<INDArray>
      • multiply

        public void multiply(double factor)
        Description copied from interface: INDArray
        Multiplies all elements of the array in place by a given double value
        Specified by:
        multiply in interface INDArray
        Overrides:
        multiply in class AbstractArray<INDArray>
      • getSlices

        public java.util.List<?> 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>
      • 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>
      • 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>
      • 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>
      • createFromVector

        public static Array createFromVector(AVector a,
                                             int... shape)
        Creates a new matrix using the elements in the specified vector. Truncates or zero-pads the data as required to fill the new matrix
        Parameters:
        data -
        rows -
        columns -
        Returns:
      • 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
        Specified by:
        getArray in interface IDenseArray
        Specified by:
        getArray in interface IStridedArray
      • getStrides

        public int[] getStrides()
        Description copied from interface: IStridedArray
        Gets the strides for each dimension of this strided array. The returned array should not be modified
        Specified by:
        getStrides in interface IStridedArray
        Returns:
      • isPackedArray

        public boolean isPackedArray()
        Description copied from interface: IStridedArray
        Checks if this array is fully packed in row major order.
        Specified by:
        isPackedArray in interface IStridedArray
        Returns:
      • isZero

        public boolean isZero()
        Description copied from interface: INDArray
        Returns true if the array is zero (all elements equal to zero)
        Specified by:
        isZero in interface INDArray
        Overrides:
        isZero in class BaseShapedArray
      • 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>
      • add

        public void add(double x)
        Description copied from interface: INDArray
        Adds a double value to all elements in this array. Implementations may optimize the case of 0.0
        Specified by:
        add in interface INDArray
        Overrides:
        add in class AbstractArray<INDArray>
      • get

        public double get(int x)
        Description copied from interface: INDArray
        Returns the double value at the specified position in a 1D vector
        Specified by:
        get in interface INDArray
        Specified by:
        get in class AbstractArray<INDArray>
      • get

        public double get(int x,
                          int y)
        Description copied from interface: INDArray
        Returns the double value at the specified position in a 2D matrix
        Specified by:
        get in interface INDArray
        Specified by:
        get in class AbstractArray<INDArray>
      • equalsArray

        public boolean equalsArray(double[] data,
                                   int offset)
        Description copied from interface: INDArray
        Returns true if the elements in this array exactly match the elements in the given array, in row-major order
        Specified by:
        equalsArray in interface INDArray
        Overrides:
        equalsArray in class AbstractArray<INDArray>
        Parameters:
        data - Array of double element values to check for equality
        offset - Offset into the data array
        Returns:

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.