Interface RealNDArray<T extends Number>

    • Method Detail

      • sum

        default NDArray<T> sum​(int... selectedDims)
        Description copied from interface: NDArray
        Returns the sum of all elements along the specified dimensions in this NDArray.

        For example, if A is a [5 × 8 × 3] array, then B = A.sum(2) returns a [5 × 8] array, and B.get(1,1) == A.get(1,1,0) + A.get(1,1,1) + A.get(1,1,2).

        Specified by:
        sum in interface NDArray<T extends Number>
        Parameters:
        selectedDims - dimensions along which the summation should be performed
        Returns:
        sum of all elementsalong the specified dimensions
      • prod

        default NDArray<T> prod​(int... selectedDims)
        Description copied from interface: NDArray
        Returns the product of all elements along the specified dimensions in this NDArray.

        For example, if A is a [5 × 8 × 3] array, then B = A.prod(2) returns a [5 × 8] array, and B.get(1,1) == A.get(1,1,0) * A.get(1,1,1) * A.get(1,1,2).

        Specified by:
        prod in interface NDArray<T extends Number>
        Parameters:
        selectedDims - dimensions along which multiplication should be performed
        Returns:
        product of all elements along the specified dimensions
      • accumulate

        default NDArray<T> accumulate​(BinaryOperator<T> func,
                                      int... selectedDims)
        Description copied from interface: NDArray
        Returns the accumulation of all elements along the specified dimensions in this NDArray.

        For example, if A is a [5 × 8 × 3] array, then B = A.accumulate(func, 2) returns a [5 × 8] array, and B.get(1,1) == func(func(A.get(1,1,0), A.get(1,1,1)), A.get(1,1,2)).

        Specified by:
        accumulate in interface NDArray<T extends Number>
        Parameters:
        func - accumulation function that accepts two elements and returns accumulation result
        selectedDims - dimensions along which the accumulation should be performed
        Returns:
        result of accumulation of all elements along the specified dimensions
      • add

        default NDArray<T> add​(Object... addends)
        Description copied from interface: NDArray
        Creates a new NDArray of the same shape and fills it with the element-wise sum of this NDArray and the parameter NDArrays and scalars. If list of parameters contains scalar values than these will be added to all elements of the resulting array.

        Note: The type of this NDArray determines type of the resulting NDArray.

        Specified by:
        add in interface NDArray<T extends Number>
        Parameters:
        addends - NDArrays and scalars to be added to this NDArray
        Returns:
        a new NDArray of the same shape, and fills it with the element-wise sum of this NDArray and the parameters NDArrays and scalars
      • addInplace

        default NDArray<T> addInplace​(Object... addends)
        Description copied from interface: NDArray
        Updates this NDArray with the element-wise sum of this NDArray and the ones given as parameters. The list of parameters can also contain scalar values - these will be added to all elements of the resulting array.

        Note: The type of this NDArray determines type of the resulting NDArray.

        Specified by:
        addInplace in interface NDArray<T extends Number>
        Parameters:
        addends - NDArrays and scalars to be added to this NDArray
        Returns:
        this NDArray after addition
      • subtract

        default NDArray<T> subtract​(Object... substrahends)
        Description copied from interface: NDArray
        Creates a new NDArray of the same shape and fills it with the result of the element-wise substraction the parameter NDArrays and scalars from this NDArray. If list of parameters contains scalar values than these will be substracted from all elements of this NDArray.

        Note: The type of this NDArray determines type of the resulting NDArray.

        Specified by:
        subtract in interface NDArray<T extends Number>
        Parameters:
        substrahends - NDArrays and scalars to be substracted from this NDArray
        Returns:
        a new NDArray filled with the result of the element-wise substraction of the parameter NDArrays and scalars from this NDArray
      • subtractInplace

        default NDArray<T> subtractInplace​(Object... substrahends)
        Description copied from interface: NDArray
        Updates the elements this NDArray with the result of the element-wise subtraction the parameter NDArrays and scalars from this NDArray. If list of parameters contains scalar values than these will be substracted from all elements of this NDArray.

        Note: The type of this NDArray determines type of the resulting NDArray.

        Specified by:
        subtractInplace in interface NDArray<T extends Number>
        Parameters:
        substrahends - NDArrays and scalars to be substracted from this NDArray
        Returns:
        this NDArray after substraction
      • multiply

        default NDArray<T> multiply​(Object... multiplicand)
        Description copied from interface: NDArray
        Creates a new NDArray of the same shape and fills it with the element-wise product of this NDArray and the parameter NDArrays and scalars. If list of parameters contains scalar values than these will be multiplied to all elements of the resulting array.

        Note: The type of this NDArray determines type of the resulting NDArray.

        Specified by:
        multiply in interface NDArray<T extends Number>
        Parameters:
        multiplicand - NDArrays and scalars to be multiplied together
        Returns:
        a new NDArray of the same shape, and fills it with the element-wise product of this NDArray and the parameters NDArrays and scalars
      • multiplyInplace

        default NDArray<T> multiplyInplace​(Object... multiplicand)
        Description copied from interface: NDArray
        Updates the elements of this NDArray with the element-wise product of this NDArray and the parameter NDArrays and scalars. If list of parameters contains scalar values than these will be multiplied to all elements of the resulting array.

        Note: The type of this NDArray determines type of the resulting NDArray.

        Specified by:
        multiplyInplace in interface NDArray<T extends Number>
        Parameters:
        multiplicand - NDArrays and scalars to be multiplied with this NDArray
        Returns:
        this NDArray after multiplication
      • divide

        default NDArray<T> divide​(Object... divisor)
        Description copied from interface: NDArray
        Creates a new NDArray of the same shape and fills it with the result of the element-wise division of this NDArray by the parameter NDArrays and scalars. If list of parameters contains scalar values than all elements of this NDArray will be divided by them.

        Note: The type of this NDArray determines type of the resulting NDArray.

        Specified by:
        divide in interface NDArray<T extends Number>
        Parameters:
        divisor - divisors of this NDArray
        Returns:
        a new NDArray of the same shape, and fills it with the result of the element-wise division of this NDArray by the parameter NDArrays and scalars
      • divideInplace

        default NDArray<T> divideInplace​(Object... divisor)
        Description copied from interface: NDArray
        Updates the elements this NDArray with the result of the element-wise division of this NDArray by the parameter NDArrays and scalars. If list of parameters contains scalar values than all elements of this NDArray will be divided by them.

        Note: The type of this NDArray determines type of the resulting NDArray.

        Specified by:
        divideInplace in interface NDArray<T extends Number>
        Parameters:
        divisor - divisors of this NDArray
        Returns:
        this NDArray after division
      • fill

        default NDArray<T> fill​(double value)
        Description copied from interface: NDArray
        Fill this NDArray with the specified value
        Specified by:
        fill in interface NDArray<T extends Number>
        Parameters:
        value - value assigned to all elements of this NDArray
        Returns:
        this NDArray
      • fill

        default NDArray<T> fill​(T value)
        Description copied from interface: NDArray
        Fill this NDArray with the specified value
        Specified by:
        fill in interface NDArray<T extends Number>
        Parameters:
        value - value assigned to all elements of this NDArray
        Returns:
        this NDArray
      • slice

        default NDArray<T> slice​(Object... slicingExpressions)
        Description copied from interface: NDArray
        Returns an array view referencing this NDArray as parent that gives read-write access to a specific multi-dimensional slice of the array.

        View: An NDArray that references the specified region its parent array. All modifications in the parent array are reflected in the view, and vice versa.

        Possible slicing expressions:

        • integer values: selects a specific slice along the positionally selected dimension
        • range (string that consists of two integer values specifying the start and the end of the range separated by a colon): selects a specific range of slices along the positionally selected dimension
        • all-range (string literal ":" or Range.ALL): selects all slices along the positionally selected dimension

        For example, if A is a [5 × 8 × 3] array, then B = A.slice(1, "2:5", ":") returns a [3 × 3] array, and B.get(1,1) == A.get(1,3,1).

        Specified by:
        slice in interface NDArray<T extends Number>
        Parameters:
        slicingExpressions - Slicing expressions
        Returns:
        an array view that gives read-write access to a specific multi-dimensional slice of the array
      • mask

        default NDArray<T> mask​(NDArray<?> mask)
        Description copied from interface: NDArray
        Returns an array view referencing this NDArray as parent that gives read-write access to a specific elements of the array selected by the given mask. The mask must have the same shape as this array, and those entries are selected which has the same indices as the non-zero entries in the mask. In other words: All places where the mask contains a zero value are skipped, and all other values are copied into a new vector.
        Specified by:
        mask in interface NDArray<T extends Number>
        Parameters:
        mask - NDArray in which non-zero entries marks elements to keep
        Returns:
        an array view that gives read-write access to a specific elements of the array selected by the given mask
      • mask

        default NDArray<T> mask​(Predicate<T> func)
        Description copied from interface: NDArray
        Returns an array view referencing this NDArray as parent that gives read-write access to a specific elements for which the given function returns true.
        Specified by:
        mask in interface NDArray<T extends Number>
        Parameters:
        func - function that accepts the values of entries as input and returns boolean
        Returns:
        an array view that gives read-write access to a specific elements for which the given function returns true
      • maskWithLinearIndices

        default NDArray<T> maskWithLinearIndices​(BiPredicate<T,​Integer> func)
        Description copied from interface: NDArray
        Returns an array view referencing this NDArray as parent that gives read-write access to a specific elements for which the given function returns true.
        Specified by:
        maskWithLinearIndices in interface NDArray<T extends Number>
        Parameters:
        func - function that accepts the values of entries and their linear indices as input and returns boolean
        Returns:
        an array view that gives read-write access to a specific elements for which the given function returns true
      • maskWithCartesianIndices

        default NDArray<T> maskWithCartesianIndices​(BiPredicate<T,​int[]> func)
        Description copied from interface: NDArray
        Returns an array view referencing this NDArray as parent that gives read-write access to a specific elements for which the given function returns true.
        Specified by:
        maskWithCartesianIndices in interface NDArray<T extends Number>
        Parameters:
        func - function that accepts the values of entries and their Cartesian indices as input and returns boolean
        Returns:
        an array view that gives read-write access to a specific elements for which the given function returns true
      • inverseMask

        default NDArray<T> inverseMask​(NDArray<?> mask)
        Description copied from interface: NDArray
        Returns an array view referencing this NDArray as parent that gives read-write access to a specific elements of the array selected by the given inverseMask. The inverseMask must have the same shape as this array, and those entries are selected which has the same indices as the non-zero entries in the inverseMask. In other words: All places where the inverseMask contains a zero value are skipped, and all other values are copied into a new vector.
        Specified by:
        inverseMask in interface NDArray<T extends Number>
        Parameters:
        mask - NDArray in which non-zero entries marks elements to keep
        Returns:
        an array view that gives read-write access to a specific elements of the array selected by the given inverseMask
      • permuteDims

        default NDArray<T> permuteDims​(int... permutation)
        Description copied from interface: NDArray
        Returns a view that references this NDArray as parent, but the order of dimensions are swiched in this view.

        View: An NDArray that references the specified region its parent array. All modifications in the parent array are reflected in the view, and vice versa.

        For example, if A is a [5 × 8 × 3] array, then B = A.permuteDims(1, 0, 2) returns a [8 × 5 × 3] array, and B.get(3,1,0) == A.get(1,3,0).

        Specified by:
        permuteDims in interface NDArray<T extends Number>
        Parameters:
        permutation - new order of dimensions / permutation vector
        Returns:
        a view that references this NDArray as parent, but the order of dimensions are swiched in this view.
      • reshape

        default NDArray<T> reshape​(int... newShape)
        Description copied from interface: NDArray
        Returns a view that references this NDArray as parent but has a different shape.

        View: An NDArray that references the specified region its parent array. All modifications in the parent array are reflected in the view, and vice versa.

        For example, if A is a [5 × 8 × 3] array, then B = A.reshape(40, 3) returns a [40 × 3] array, and B.get(10) == B.get(10,0) == A.get(1,0,0) == A.get(10).

        Note: the linear indexing of the two arrays remain the same, and the corresponding cartesian indices determined by column-first ordering.

        Specified by:
        reshape in interface NDArray<T extends Number>
        Parameters:
        newShape - new shape/dimensions
        Returns:
        a view that references this NDArray as parent but has a different shape
      • concatenate

        default NDArray<T> concatenate​(int axis,
                                       NDArray<?>... arrays)
        Description copied from interface: NDArray
        Creates a new NDArray that contains the elements of this NDArrays and all other NDArrays concatenated along the dimension/axis specified by the first parameter.
        Specified by:
        concatenate in interface NDArray<T extends Number>
        Parameters:
        axis - Axis/dimension along which the concatenation should occur.
        arrays - Arrays to be concatenated to this NDArray.
        Returns:
        a new NDArray that contains the elements of this NDArrays and all other NDArrays concatenated along the dimension/axis specified by the first parameter.
      • selectDims

        default NDArray<T> selectDims​(int... selectedDims)
        Description copied from interface: NDArray
        Returns a view that references this NDArray as parent, and skips all singleton dimensions not included in the parameter list.

        View: An NDArray that references the specified region its parent array. All modifications in the parent array are reflected in the view, and vice versa.

        Singleton dimension: dimension of shape 1.

        Specified by:
        selectDims in interface NDArray<T extends Number>
        Parameters:
        selectedDims - dimensions kept in the returned view
        Returns:
        a view that references this NDArray as parent, and skips all singleton dimensions not included in the parameter list
      • dropDims

        default NDArray<T> dropDims​(int... selectedDims)
        Description copied from interface: NDArray
        Returns a view that references this NDArray as parent, and skips all singleton dimensions included in the parameter list.

        View: An NDArray that references the specified region its parent array. All modifications in the parent array are reflected in the view, and vice versa.

        Singleton dimension: dimension of shape 1.

        Specified by:
        dropDims in interface NDArray<T extends Number>
        Parameters:
        selectedDims - dimensions skipped in the returned view
        Returns:
        a view that references this NDArray as parent, and skips all singleton dimensions included in the parameter list
      • squeeze

        default NDArray<T> squeeze()
        Description copied from interface: NDArray
        Returns a view that references this NDArray as parent, and skips all singleton dimensions.

        View: An NDArray that references the specified region its parent array. All modifications in the parent array are reflected in the view, and vice versa.

        Singleton dimension: dimension of shape 1.

        Specified by:
        squeeze in interface NDArray<T extends Number>
        Returns:
        a view that references this NDArray as parent, and skips all singleton dimensions.
      • copyFrom

        default NDArray<T> copyFrom​(float[] array)
        Description copied from interface: NDArray
        Updates this NDArray with the elements of the array given as parameter.

        Note: the parameter array must have the same shape and this NDArray!

        Specified by:
        copyFrom in interface NDArray<T extends Number>
        Parameters:
        array - array holding the new values to be copied to this NDArray
        Returns:
        this NDArray
      • copyFrom

        default NDArray<T> copyFrom​(double[] array)
        Description copied from interface: NDArray
        Updates this NDArray with the elements of the array given as parameter.

        Note: the parameter array must have the same shape and this NDArray!

        Specified by:
        copyFrom in interface NDArray<T extends Number>
        Parameters:
        array - array holding the new values to be copied to this NDArray
        Returns:
        this NDArray
      • copyFrom

        default NDArray<T> copyFrom​(byte[] array)
        Description copied from interface: NDArray
        Updates this NDArray with the elements of the array given as parameter.

        Note: the parameter array must have the same shape and this NDArray!

        Specified by:
        copyFrom in interface NDArray<T extends Number>
        Parameters:
        array - array holding the new values to be copied to this NDArray
        Returns:
        this NDArray
      • copyFrom

        default NDArray<T> copyFrom​(short[] array)
        Description copied from interface: NDArray
        Updates this NDArray with the elements of the array given as parameter.

        Note: the parameter array must have the same shape and this NDArray!

        Specified by:
        copyFrom in interface NDArray<T extends Number>
        Parameters:
        array - array holding the new values to be copied to this NDArray
        Returns:
        this NDArray
      • copyFrom

        default NDArray<T> copyFrom​(int[] array)
        Description copied from interface: NDArray
        Updates this NDArray with the elements of the array given as parameter.

        Note: the parameter array must have the same shape and this NDArray!

        Specified by:
        copyFrom in interface NDArray<T extends Number>
        Parameters:
        array - array holding the new values to be copied to this NDArray
        Returns:
        this NDArray
      • copyFrom

        default NDArray<T> copyFrom​(long[] array)
        Description copied from interface: NDArray
        Updates this NDArray with the elements of the array given as parameter.

        Note: the parameter array must have the same shape and this NDArray!

        Specified by:
        copyFrom in interface NDArray<T extends Number>
        Parameters:
        array - array holding the new values to be copied to this NDArray
        Returns:
        this NDArray
      • copyFrom

        default NDArray<T> copyFrom​(Object[] array)
        Description copied from interface: NDArray
        Updates this NDArray with the elements of the array given as parameter.

        Note: the parameter array must have the same shape and this NDArray!

        Specified by:
        copyFrom in interface NDArray<T extends Number>
        Parameters:
        array - array holding the new values to be copied to this NDArray
        Returns:
        this NDArray
      • map

        default NDArray<T> map​(UnaryOperator<T> func)
        Description copied from interface: NDArray
        Apply the given function to each element of the array, and create a new NDArray with the calculated new values. Please note that entries might not be processed in a sequential order!
        Specified by:
        map in interface NDArray<T extends Number>
        Parameters:
        func - function that receives the value of the current entry, and returns the new value
        Returns:
        the new NDArray with the calculated new values
      • mapWithLinearIndices

        default NDArray<T> mapWithLinearIndices​(BiFunction<T,​Integer,​T> func)
        Description copied from interface: NDArray
        Apply the given function to each element of the array, and create a new NDArray with the calculated new values. Please note that entries might not be processed in a sequential order!
        Specified by:
        mapWithLinearIndices in interface NDArray<T extends Number>
        Parameters:
        func - function that receives the value of the current entry and its linear index, and returns the new value
        Returns:
        the new NDArray with the calculated new values
      • mapWithCartesianIndices

        default NDArray<T> mapWithCartesianIndices​(BiFunction<T,​int[],​T> func)
        Description copied from interface: NDArray
        Apply the given function to each element of the array, and create a new NDArray with the calculated new values. Please note that entries might not be processed in a sequential order!
        Specified by:
        mapWithCartesianIndices in interface NDArray<T extends Number>
        Parameters:
        func - function that receives the value of the current entry and its Cartesian coordinate, and returns the new value
        Returns:
        the new NDArray with the calculated new values