Documentation of 'mikera.vectorz.AScalar' Java class
AScalar
mikera.vectorz

Class AScalar

    • Constructor Detail

      • AScalar

        public AScalar()
    • Method Detail

      • get

        public abstract double get()
        Description copied from interface: INDArray
        Returns the double value of a scalar array
        Specified by:
        get in interface INDArray
        Specified by:
        get in interface IScalar
        Specified by:
        get in class AbstractArray<java.lang.Object>
      • set

        public abstract 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
        Specified by:
        set in interface IScalar
        Overrides:
        set in class AbstractArray<java.lang.Object>
      • setSparse

        public void setSparse(double v)
        Description copied from interface: INDArray
        Sets the non-sparse elements of this array to the specified value May throw an exception if non-sparse elements are not mutable
        Specified by:
        setSparse in interface INDArray
        Overrides:
        setSparse in class AbstractArray<java.lang.Object>
      • 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<java.lang.Object>
      • 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<java.lang.Object>
      • 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<java.lang.Object>
        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[] dest,
                                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<java.lang.Object>
      • getTranspose

        public final AScalar 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<java.lang.Object>
      • getTransposeView

        public final AScalar getTransposeView()
        Description copied from interface: INDArray
        Returns a transposed view of the array. May throw UnsupportedOperationException if the array type does not support this capability
        Specified by:
        getTransposeView in interface INDArray
        Overrides:
        getTransposeView in class AbstractArray<java.lang.Object>
      • dimensionality

        public final 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
      • slice

        public INDArray slice(int position)
        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
      • sliceCount

        public final int sliceCount()
        Description copied from interface: INDArray
        Returns the number of major slices in this array (i.e. the size of dimension 0)
        Specified by:
        sliceCount in interface INDArray
      • getSlices

        public java.util.List<java.lang.Object> 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<java.lang.Object>
      • subArray

        public AScalar subArray(int[] offsets,
                                int[] shape)
        Description copied from interface: INDArray
        Returns a subarray view of a larger array
        Specified by:
        subArray in interface INDArray
        Overrides:
        subArray in class AbstractArray<java.lang.Object>
      • iterator

        public java.util.Iterator<java.lang.Object> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<java.lang.Object>
        Overrides:
        iterator in class AbstractArray<java.lang.Object>
      • isMutable

        public boolean isMutable()
        Description copied from interface: INDArray
        Returns true if the INDArray is mutable (at least partially)
        Specified by:
        isMutable in interface INDArray
        Overrides:
        isMutable in class AbstractArray<java.lang.Object>
      • 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<java.lang.Object>
      • 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 AbstractArray<java.lang.Object>
      • isBoolean

        public boolean isBoolean()
        Description copied from interface: INDArray
        Returns true if the array is boolean (contains only 0.0 or 1.0 values)
        Specified by:
        isBoolean in interface INDArray
        Overrides:
        isBoolean in class AbstractArray<java.lang.Object>
      • add

        public void add(double d)
        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<java.lang.Object>
      • addCopy

        public AScalar addCopy(double d)
        Description copied from interface: INDArray
        Creates a new array equal to this array with a constant value added to every element
        Specified by:
        addCopy in interface INDArray
        Overrides:
        addCopy in class AbstractArray<java.lang.Object>
        Returns:
      • addAt

        public void addAt(long i,
                          double v)
        Description copied from interface: INDArray
        Adds to a mutable array, indexed by element position in row major order. This is an unsafe operation: bounds are not checked
        Specified by:
        addAt in interface INDArray
        Overrides:
        addAt in class AbstractArray<java.lang.Object>
      • addToArray

        public void addToArray(double[] data,
                               int offset)
        Description copied from interface: INDArray
        Adds all the elements of this array to a double array at the specified offset, in row-major order
        Specified by:
        addToArray in interface INDArray
        Overrides:
        addToArray in class AbstractArray<java.lang.Object>
      • addPower

        public void addPower(INDArray src,
                             double factor)
        Description copied from interface: INDArray
        Adds an array with all elements of the source array raised to the specified power
        Specified by:
        addPower in interface INDArray
        Overrides:
        addPower in class AbstractArray<java.lang.Object>
      • sub

        public void sub(double d)
        Description copied from interface: INDArray
        Subtracts a double value from all elements in this array
        Specified by:
        sub in interface INDArray
        Overrides:
        sub in class AbstractArray<java.lang.Object>
      • add

        public void add(INDArray a)
        Description copied from interface: INDArray
        Adds all the elements of another array to this array, in an elementwise order.
        Specified by:
        add in interface INDArray
        Overrides:
        add in class AbstractArray<java.lang.Object>
      • sub

        public void sub(INDArray a)
        Description copied from interface: INDArray
        Subtracts all the elements of another array from this array, in an elementwise order.
        Specified by:
        sub in interface INDArray
        Overrides:
        sub in class AbstractArray<java.lang.Object>
      • negate

        public void negate()
        Description copied from interface: INDArray
        Negates all elements in the array in place
        Specified by:
        negate in interface INDArray
        Overrides:
        negate in class AbstractArray<java.lang.Object>
      • square

        public void square()
        Description copied from interface: INDArray
        Squares all elements of the array in place
        Specified by:
        square in interface INDArray
        Overrides:
        square in class AbstractArray<java.lang.Object>
      • pow

        public void pow(double exponent)
        Description copied from interface: INDArray
        Raises all elements of the array to a specified power in place
        Specified by:
        pow in interface INDArray
        Overrides:
        pow in class AbstractArray<java.lang.Object>
      • clamp

        public void clamp(double min,
                          double max)
        Description copied from interface: INDArray
        Clamps all the elements of this array within the specified [min,max] range
        Specified by:
        clamp in interface INDArray
        Overrides:
        clamp in class AbstractArray<java.lang.Object>
      • innerProduct

        public AVector innerProduct(AVector a)
        Description copied from interface: INDArray
        Computes the inner product of this array with a vector
        Specified by:
        innerProduct in interface INDArray
        Overrides:
        innerProduct in class AbstractArray<java.lang.Object>
        Parameters:
        a - A vector
        Returns:
        A new array representing the inner product
      • 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
      • getShape

        public int[] getShape()
        Description copied from interface: INDArray
        Returns 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:
        getShape in interface INDArray
      • getShape

        public int getShape(int dim)
        Description copied from interface: INDArray
        Returns the dimension size for a specific dimension in the array's shape
        Specified by:
        getShape in interface INDArray
        Overrides:
        getShape in class AbstractArray<java.lang.Object>
      • elementCount

        public final 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
      • getElement

        public double getElement(long i)
        Description copied from interface: INDArray
        Gets a specific element of this array, indexed in row-major order
        Specified by:
        getElement in interface INDArray
        Returns:
        The element value
      • getElements

        public void getElements(double[] arr)
        Description copied from interface: INDArray
        Copies all elements of this INDArray to the specified double array
        Specified by:
        getElements in interface INDArray
        Overrides:
        getElements in class AbstractArray<java.lang.Object>
      • setElements

        public void setElements(double... values)
        Description copied from interface: INDArray
        Sets all elements in an array using the given double values
        Specified by:
        setElements in interface INDArray
        Overrides:
        setElements in class AbstractArray<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: INDArray
        Sets all elements in an array using the given double values
        Specified by:
        setElements in interface INDArray
        Overrides:
        setElements in class AbstractArray<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: INDArray
        Constructs a view of all elements in the array as a single vector in row-major order.
        Specified by:
        asVector in interface INDArray
        Overrides:
        asVector in class AbstractArray<java.lang.Object>
      • 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<java.lang.Object>
      • 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<java.lang.Object>
        Parameters:
        op - The operator to apply to the array
      • applyOp

        public void applyOp(Op 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<java.lang.Object>
      • applyOp

        public void applyOp(Op2 op,
                            INDArray b)
        Description copied from interface: INDArray
        Applies a binary operator to this array and a second array. Broadcasts the second array to the shape of this array if required.
        Specified by:
        applyOp in interface INDArray
        Overrides:
        applyOp in class AbstractArray<java.lang.Object>
      • applyOp

        public void applyOp(Op2 op,
                            double b)
        Description copied from interface: INDArray
        Applies 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:
        applyOp in interface INDArray
        Overrides:
        applyOp in class AbstractArray<java.lang.Object>
      • 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 AbstractArray<java.lang.Object>
      • reduce

        public final 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 AbstractArray<java.lang.Object>
      • clone

        public Scalar 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<java.lang.Object>
      • 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<java.lang.Object>
      • divide

        public void divide(double factor)
        Description copied from interface: INDArray
        Divides all elements by a given factor
        Specified by:
        divide in interface INDArray
        Overrides:
        divide in class AbstractArray<java.lang.Object>
      • multiply

        public void multiply(INDArray a)
        Description copied from interface: INDArray
        Multiplies 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:
        multiply in interface INDArray
        Overrides:
        multiply in class AbstractArray<java.lang.Object>
      • multiplyCopy

        public final INDArray multiplyCopy(INDArray a)
        Description copied from interface: INDArray
        Multiplies 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:
        multiplyCopy in interface INDArray
        Overrides:
        multiplyCopy in class AbstractArray<java.lang.Object>
      • elementSum

        public final double elementSum()
        Description copied from interface: INDArray
        Returns the sum of all elements in this array.
        Specified by:
        elementSum in interface INDArray
        Overrides:
        elementSum in class AbstractArray<java.lang.Object>
      • elementMaxAbs

        public double elementMaxAbs()
        Description copied from interface: INDArray
        Returns the maximum absolute element value in this array. Throws an error if there are no elements.
        Specified by:
        elementMaxAbs in interface INDArray
        Overrides:
        elementMaxAbs in class AbstractArray<java.lang.Object>
      • elementMax

        public double elementMax()
        Description copied from interface: INDArray
        Returns the maximum element value in this array. Throws an error if there are no elements.
        Specified by:
        elementMax in interface INDArray
        Overrides:
        elementMax in class AbstractArray<java.lang.Object>
      • elementMin

        public double elementMin()
        Description copied from interface: INDArray
        Returns the maximum element value in this array. Throws an error if there are no elements.
        Specified by:
        elementMin in interface INDArray
        Overrides:
        elementMin in class AbstractArray<java.lang.Object>
      • broadcast

        public INDArray broadcast(int... targetShape)
        Description copied from interface: INDArray
        Returns a view of this array broadcasted up to a larger shape
        Specified by:
        broadcast in interface INDArray
        Overrides:
        broadcast in class AbstractArray<java.lang.Object>
      • equals

        public boolean equals(java.lang.Object o)
        Overrides:
        equals in class AbstractArray<java.lang.Object>
      • epsilonEquals

        public boolean epsilonEquals(INDArray a,
                                     double epsilon)
        Description copied from interface: INDArray
        Tests is this array is approximately equal to another array, up to a given tolerance (epsilon) The arrays must have the same shape
        Specified by:
        epsilonEquals in interface INDArray
        Overrides:
        epsilonEquals in class AbstractArray<java.lang.Object>
      • equals

        public boolean equals(INDArray o)
        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<java.lang.Object>
      • 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<java.lang.Object>
        Parameters:
        data - Array of double element values to check for equality
        offset - 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:
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class AbstractArray<java.lang.Object>
      • elementIterator

        public java.util.Iterator<java.lang.Double> elementIterator()
        Description copied from interface: INDArray
        Returns an iterator over all elements in this array, in row-major order
        Specified by:
        elementIterator in interface INDArray
        Overrides:
        elementIterator in class AbstractArray<java.lang.Object>
      • toDoubleBuffer

        public void toDoubleBuffer(java.nio.DoubleBuffer dest)
        Description copied from interface: INDArray
        Copies the elements of this INDArray to the specified double buffer.
        Specified by:
        toDoubleBuffer in interface INDArray
        Overrides:
        toDoubleBuffer in class AbstractArray<java.lang.Object>
      • 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<java.lang.Object>
      • toSliceArray

        public INDArray[] toSliceArray()
        Description copied from interface: INDArray
        Copies 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:
        toSliceArray in interface INDArray
        Overrides:
        toSliceArray in class AbstractArray<java.lang.Object>
      • exactClone

        public abstract AScalar 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
      • mutable

        public AScalar mutable()
        Description copied from interface: INDArray
        Coerces this INDArray to a fully mutable format. May return the same INDArray if already fully mutable
        Specified by:
        mutable in interface INDArray
        Specified by:
        mutable in interface IScalar
        Overrides:
        mutable in class AbstractArray<java.lang.Object>
      • elementsEqual

        public boolean elementsEqual(double value)
        Description copied from interface: INDArray
        Returns true if all elements are equal to a specific value
        Specified by:
        elementsEqual in interface INDArray
        Overrides:
        elementsEqual in class AbstractArray<java.lang.Object>
      • sparse

        public AScalar sparse()
        Description copied from interface: INDArray
        Coerces 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:
        sparse in interface INDArray
        Overrides:
        sparse in class AbstractArray<java.lang.Object>
      • dense

        public INDArray dense()
        Description copied from interface: INDArray
        Coerces 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:
        dense in interface INDArray
        Overrides:
        dense in class AbstractArray<java.lang.Object>
      • denseClone

        public final Scalar denseClone()
        Description copied from interface: INDArray
        Creates a fully mutable dense clone of this array. Will always use a dense format, even if the array data is sparse.
        Specified by:
        denseClone in interface INDArray
        Overrides:
        denseClone in class AbstractArray<java.lang.Object>
      • sparseClone

        public final Scalar sparseClone()
        Description copied from interface: INDArray
        Creates a fully mutable clone of this array. Will use a sparse format if possible.
        Specified by:
        sparseClone in interface INDArray
        Overrides:
        sparseClone in class AbstractArray<java.lang.Object>
      • immutable

        public ImmutableScalar 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
        Specified by:
        immutable in interface IScalar
        Overrides:
        immutable in class AbstractArray<java.lang.Object>
      • 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<java.lang.Object>
      • 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<java.lang.Object>
      • hasUncountable

        public boolean hasUncountable()
        Description copied from class: AbstractArray
        Returns true if any element is this array is NaN or infinite
        Specified by:
        hasUncountable in interface INDArray
        Overrides:
        hasUncountable in class AbstractArray<java.lang.Object>
        Returns:
        True if any element is this array is NaN or infinite, false otherwise

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.