Class ComplexNDArrayMaskView<T extends Number>

  • All Implemented Interfaces:
    ComplexNDArray<T>, NDArray<org.apache.commons.math3.complex.Complex>, Iterable<org.apache.commons.math3.complex.Complex>

    public class ComplexNDArrayMaskView<T extends Number>
    extends AbstractNDArrayMaskView<org.apache.commons.math3.complex.Complex,​T>
    implements ComplexNDArray<T>
    A view for a ComplexNDArray that selects values based on a specified mask. When mask(...) is called for a ComplexNDArray, an instance of this class is returned.
    • Constructor Detail

      • ComplexNDArrayMaskView

        public ComplexNDArrayMaskView​(NDArray<org.apache.commons.math3.complex.Complex> parent,
                                      NDArray<?> mask,
                                      boolean isInverse)
      • ComplexNDArrayMaskView

        public ComplexNDArrayMaskView​(NDArray<org.apache.commons.math3.complex.Complex> parent,
                                      Predicate<org.apache.commons.math3.complex.Complex> func)
      • ComplexNDArrayMaskView

        public ComplexNDArrayMaskView​(NDArray<org.apache.commons.math3.complex.Complex> parent,
                                      BiPredicate<org.apache.commons.math3.complex.Complex,​?> func,
                                      boolean withLinearIndices)
    • Method Detail

      • mapOnComplexSlices

        public ComplexNDArray<T> mapOnComplexSlices​(BiFunction<ComplexNDArray<T>,​int[],​NDArray<?>> func,
                                                    int... iterationDims)
        Description copied from interface: ComplexNDArray
        Apply the given function to each slices of the array, and create a new NDArray with the calculated new values. Please note that slices might not be processed in a sequential order!
        Specified by:
        mapOnComplexSlices in interface ComplexNDArray<T extends Number>
        Parameters:
        func - function that receives slice and its Cartesian coordinate along the iteration dimensions, and returns a new array with the same size as the slice
        iterationDims - dimensions along which iteration is performed
        Returns:
        the new NDArray with the calculated new values
      • applyOnComplexSlices

        public ComplexNDArray<T> applyOnComplexSlices​(BiFunction<ComplexNDArray<T>,​int[],​NDArray<?>> func,
                                                      int... iterationDims)
        Description copied from interface: ComplexNDArray
        Apply the given function to each slices of the array, and override each entry with the returned slice. Please note that slices might not be processed in a sequential order!
        Specified by:
        applyOnComplexSlices in interface ComplexNDArray<T extends Number>
        Parameters:
        func - function that receives the value of the current entry and its Cartesian coordinate, and returns a slice from which values are copied to original array
        iterationDims - dimensions along which iteration is performed
        Returns:
        itself after the update
      • reduceComplexSlices

        public ComplexNDArray<T> reduceComplexSlices​(BiFunction<ComplexNDArray<T>,​int[],​org.apache.commons.math3.complex.Complex> func,
                                                     int... iterationDims)
        Description copied from interface: ComplexNDArray
        Reduces slices along the specified dimensions in this NDArray to scalar values, reducing the number of dimensions.

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

        Specified by:
        reduceComplexSlices in interface ComplexNDArray<T extends Number>
        Parameters:
        func - reduction function that accepts a slice and its index and returns reduction result
        iterationDims - dimensions along which the reduction should be performed
        Returns:
        result of reduction of all slices along the specified dimensions
      • real

        public NDArray<T> real()
        Description copied from interface: ComplexNDArray
        Returns a new array holding the real part of the array
        Specified by:
        real in interface ComplexNDArray<T extends Number>
        Returns:
        the real part of the array
      • imaginary

        public NDArray<T> imaginary()
        Description copied from interface: ComplexNDArray
        Returns a new array holding the imaginary part of the array
        Specified by:
        imaginary in interface ComplexNDArray<T extends Number>
        Returns:
        the imaginary part of the array
      • abs

        public NDArray<T> abs()
        Description copied from interface: ComplexNDArray
        Returns a new array holding the magnitude / absolute values of the elements.
        Specified by:
        abs in interface ComplexNDArray<T extends Number>
        Returns:
        a new array holding the magnitude / absolute values of the elements.
      • argument

        public NDArray<T> argument()
        Description copied from interface: ComplexNDArray
        Returns a new array holding the argument / argument of the elements.
        Specified by:
        argument in interface ComplexNDArray<T extends Number>
        Returns:
        a new array holding the argument / argument of the elements.
      • apply

        public ComplexNDArray<T> apply​(UnaryOperator<org.apache.commons.math3.complex.Complex> func)
        Description copied from interface: NDArray
        Apply the given function to each element of the array, and override each entry with the calculated new values. Please note that entries might not be processed in a sequential order!
        Specified by:
        apply in interface ComplexNDArray<T extends Number>
        Specified by:
        apply in interface NDArray<T extends Number>
        Overrides:
        apply in class AbstractNDArray<org.apache.commons.math3.complex.Complex,​T extends Number>
        Parameters:
        func - function that receives the value of the current entry, and returns the new value
        Returns:
        itself after the update
      • applyWithLinearIndices

        public ComplexNDArray<T> applyWithLinearIndices​(BiFunction<org.apache.commons.math3.complex.Complex,​Integer,​org.apache.commons.math3.complex.Complex> func)
        Description copied from interface: NDArray
        Apply the given function to each element of the array, and override each entry with the calculated new values. Please note that entries might not be processed in a sequential order!
        Specified by:
        applyWithLinearIndices in interface ComplexNDArray<T extends Number>
        Specified by:
        applyWithLinearIndices in interface NDArray<T extends Number>
        Overrides:
        applyWithLinearIndices in class AbstractNDArray<org.apache.commons.math3.complex.Complex,​T extends Number>
        Parameters:
        func - function that receives the value of the current entry and its linear index, and returns the new value
        Returns:
        itself after the update
      • applyWithCartesianIndices

        public ComplexNDArray<T> applyWithCartesianIndices​(BiFunction<org.apache.commons.math3.complex.Complex,​int[],​org.apache.commons.math3.complex.Complex> func)
        Description copied from interface: NDArray
        Apply the given function to each element of the array, and override each entry with the calculated new values. Please note that entries might not be processed in a sequential order!
        Specified by:
        applyWithCartesianIndices in interface ComplexNDArray<T extends Number>
        Specified by:
        applyWithCartesianIndices in interface NDArray<T extends Number>
        Overrides:
        applyWithCartesianIndices in class AbstractNDArray<org.apache.commons.math3.complex.Complex,​T extends Number>
        Parameters:
        func - function that receives the value of the current entry and its Cartesian coordinate, and returns the new value
        Returns:
        itself after the update
      • fillUsingLinearIndices

        public ComplexNDArray<T> fillUsingLinearIndices​(IntFunction<org.apache.commons.math3.complex.Complex> func)
        Description copied from interface: NDArray
        Apply the given function to each element of the array, and override each entry with the calculated new values. Please note that entries might not be processed in a sequential order!
        Specified by:
        fillUsingLinearIndices in interface ComplexNDArray<T extends Number>
        Specified by:
        fillUsingLinearIndices in interface NDArray<T extends Number>
        Overrides:
        fillUsingLinearIndices in class AbstractNDArray<org.apache.commons.math3.complex.Complex,​T extends Number>
        Parameters:
        func - function that receives the linear index of the current entry, and returns the new value
        Returns:
        itself after the update
      • fillUsingCartesianIndices

        public ComplexNDArray<T> fillUsingCartesianIndices​(Function<int[],​org.apache.commons.math3.complex.Complex> func)
        Description copied from interface: NDArray
        Apply the given function to each element of the array, and override each entry with the calculated new values. Please note that entries might not be processed in a sequential order!
        Specified by:
        fillUsingCartesianIndices in interface ComplexNDArray<T extends Number>
        Specified by:
        fillUsingCartesianIndices in interface NDArray<T extends Number>
        Overrides:
        fillUsingCartesianIndices in class AbstractNDArray<org.apache.commons.math3.complex.Complex,​T extends Number>
        Parameters:
        func - function that receives the Cartesian coordinate of the current entry, and returns the new value
        Returns:
        itself after the update
      • set

        public void set​(Number value,
                        int linearIndex)
        Description copied from interface: NDArray
        Sets the value of an element specified by linear indexing.

        Linear indexing: It selects the ith element using the column-major iteration order that linearly spans the entire array. in its particular dimension.

        Negative indexing is supported, e.g. -1 refers to the last element, -2 refers to the item before the last one, etc.

        Specified by:
        set in interface NDArray<T extends Number>
        Parameters:
        value - value to be assigned
        linearIndex - linear coordinates
      • set

        public void set​(Number value,
                        int... indices)
        Description copied from interface: NDArray
        Sets the value of an element specified by cartesian indexing.

        Cartesian indexing: The ordinary way to index into an N-dimensional array is to use exactly N indices; each index selects the position(s) in its particular dimension.

        Negative indexing is supported, e.g. assuming a 3×4 NDArray, index [2,-1] equals to [2,3], and [-1,-3] is an equivalent of [2,1].

        Specified by:
        set in interface NDArray<T extends Number>
        Parameters:
        value - value to be assigned
        indices - cartesian coordinates
      • setReal

        public void setReal​(Number value,
                            int linearIndex)
        Description copied from interface: ComplexNDArray
        Sets the real part of an element specified by linear indexing.

        Linear indexing: It selects the ith element using the column-major iteration order that linearly spans the entire array.

        Negative indexing is supported: e.g. -1 refers to the last element, -2 refers to the item before the last one, etc.

        Note: If used on complex arrays, the imaginary part of the assigned element will be untouched.

        Specified by:
        setReal in interface ComplexNDArray<T extends Number>
        Overrides:
        setReal in class AbstractNDArray<org.apache.commons.math3.complex.Complex,​T extends Number>
        Parameters:
        value - real value to be assigned as real part of some element
        linearIndex - linear index
      • setReal

        public void setReal​(Number value,
                            int... indices)
        Description copied from interface: ComplexNDArray
        Sets the real part of an element specified by cartesian indexing.

        Cartesian indexing: The ordinary way to index into an N-dimensional array is to use exactly N indices; each index selects the position(s) in its particular dimension.

        Negative indexing is supported: e.g. assuming a 3×4 NDArray, index [2,-1] equals to [2,3], and [-1,-3] is an equivalent of [2,1].

        Note: If used on complex arrays, the imaginary part of the assigned element will be untouched.

        Specified by:
        setReal in interface ComplexNDArray<T extends Number>
        Overrides:
        setReal in class AbstractNDArray<org.apache.commons.math3.complex.Complex,​T extends Number>
        Parameters:
        value - real value to be assigned as real part of some element
        indices - cartesian coordinates
      • setImag

        public void setImag​(Number value,
                            int linearIndex)
        Description copied from interface: ComplexNDArray
        Sets the imaginary part of an element specified by linear indexing.

        Linear indexing: It selects the ith element using the column-major iteration order that linearly spans the entire array.

        Negative indexing is supported: e.g. -1 refers to the last element, -2 refers to the item before the last one, etc.

        Note: If used on complex arrays, the imaginary part of the assigned element will be untouched.

        Specified by:
        setImag in interface ComplexNDArray<T extends Number>
        Overrides:
        setImag in class AbstractNDArray<org.apache.commons.math3.complex.Complex,​T extends Number>
        Parameters:
        value - imaginary value to be assigned as imaginary part of some element
        linearIndex - linear index
      • setImag

        public void setImag​(Number value,
                            int... indices)
        Description copied from interface: ComplexNDArray
        Sets the imaginary part of an element specified by cartesian indexing.

        Cartesian indexing: The ordinary way to index into an N-dimensional array is to use exactly N indices; each index selects the position(s) in its particular dimension.

        Negative indexing is supported: e.g. assuming a 3×4 NDArray, index [2,-1] equals to [2,3], and [-1,-3] is an equivalent of [2,1].

        Note: If used on complex arrays, the imaginary part of the assigned element will be untouched.

        Specified by:
        setImag in interface ComplexNDArray<T extends Number>
        Overrides:
        setImag in class AbstractNDArray<org.apache.commons.math3.complex.Complex,​T extends Number>
        Parameters:
        value - imaginary value to be assigned as imaginary part of some element
        indices - cartesian coordinates