Class BooleanIndexing


  • public class BooleanIndexing
    extends Object
    Boolean indexing
    Author:
    Adam Gibson
    • Constructor Detail

      • BooleanIndexing

        public BooleanIndexing()
    • Method Detail

      • and

        public static boolean and​(INDArray n,
                                  Condition cond)
        And over the whole ndarray given some condition
        Parameters:
        n - the ndarray to test
        cond - the condition to test against
        Returns:
        true if all of the elements meet the specified condition false otherwise
      • and

        public static boolean[] and​(INDArray n,
                                    Condition condition,
                                    int... dimension)
        And over the whole ndarray given some condition, with respect to dimensions
        Parameters:
        n - the ndarray to test
        condition - the condition to test against
        Returns:
        true if all of the elements meet the specified condition false otherwise
      • or

        public static boolean[] or​(INDArray n,
                                   Condition condition,
                                   int... dimension)
        Or over the whole ndarray given some condition, with respect to dimensions
        Parameters:
        n - the ndarray to test
        condition - the condition to test against
        Returns:
        true if all of the elements meet the specified condition false otherwise
      • or

        public static boolean or​(INDArray n,
                                 Condition cond)
        Or over the whole ndarray given some condition
        Parameters:
        n -
        cond -
        Returns:
      • assignIf

        public static void assignIf​(@NonNull
                                    @NonNull INDArray to,
                                    @NonNull
                                    @NonNull INDArray from,
                                    @NonNull
                                    @NonNull Condition condition)
        This method does element-wise comparison for 2 equal-sized matrices, for each element that matches Condition. To is the array to apply the indexing to from is a condition mask array (0 or 1). This would come from the output of a bit masking method like: INDArray.gt(Number),INDArray.gte(Number), INDArray.lt(Number),..
        Parameters:
        to - the array to apply the condition to
        from - the mask array
        condition - the condition to apply
      • replaceWhere

        public static void replaceWhere​(@NonNull
                                        @NonNull INDArray to,
                                        @NonNull
                                        @NonNull INDArray from,
                                        @NonNull
                                        @NonNull Condition condition)
        This method does element-wise comparison for 2 equal-sized matrices, for each element that matches Condition
        Parameters:
        to -
        from -
        condition -
      • chooseFrom

        public static INDArray chooseFrom​(@NonNull
                                          @NonNull INDArray[] input,
                                          @NonNull
                                          @NonNull Condition condition)
        Choose from the inputs based on the given condition. This returns a row vector of all elements fulfilling the condition listed within the array for input
        Parameters:
        input - the input to filter
        condition - the condition to filter based on
        Returns:
        a row vector of the input elements that are true ffor the given conditions
      • applyMask

        public static INDArray applyMask​(INDArray arr,
                                         INDArray mask)
        A minor shortcut for applying a bitmask to a matrix
        Parameters:
        arr - The array to apply the mask to
        mask - the mask to apply
        Returns:
        the array with the mask applied
      • applyMaskInPlace

        public static INDArray applyMaskInPlace​(INDArray arr,
                                                INDArray mask)
        A minor shortcut for applying a bitmask to a matrix
        Parameters:
        arr - The array to apply the mask to
        mask - the mask to apply
        Returns:
        the array with the mask applied
      • chooseFrom

        public static INDArray chooseFrom​(@NonNull
                                          @NonNull INDArray[] input,
                                          @NonNull
                                          @NonNull List<Double> tArgs,
                                          @NonNull
                                          @NonNull List<Integer> iArgs,
                                          @NonNull
                                          @NonNull Condition condition)
        Choose from the inputs based on the given condition. This returns a row vector of all elements fulfilling the condition listed within the array for input. The double and integer arguments are only relevant for scalar operations (like when you have a scalar you are trying to compare each element in your input against)
        Parameters:
        input - the input to filter
        tArgs - the double args
        iArgs - the integer args
        condition - the condition to filter based on
        Returns:
        a row vector of the input elements that are true ffor the given conditions
      • replaceWhere

        public static void replaceWhere​(@NonNull
                                        @NonNull INDArray to,
                                        @NonNull
                                        @NonNull Number set,
                                        @NonNull
                                        @NonNull Condition condition)
        This method does element-wise assessing for 2 equal-sized matrices, for each element that matches Condition
        Parameters:
        to -
        set -
        condition -
      • firstIndex

        public static INDArray firstIndex​(INDArray array,
                                          Condition condition)
        This method returns first index matching given condition PLEASE NOTE: This method will return -1 value if condition wasn't met
        Parameters:
        array -
        condition -
        Returns:
      • firstIndex

        public static INDArray firstIndex​(INDArray array,
                                          Condition condition,
                                          int... dimension)
        This method returns first index matching given condition along given dimensions PLEASE NOTE: This method will return -1 values for missing conditions
        Parameters:
        array -
        condition -
        dimension -
        Returns:
      • lastIndex

        public static INDArray lastIndex​(INDArray array,
                                         Condition condition)
        This method returns last index matching given condition PLEASE NOTE: This method will return -1 value if condition wasn't met
        Parameters:
        array -
        condition -
        Returns:
      • lastIndex

        public static INDArray lastIndex​(INDArray array,
                                         Condition condition,
                                         int... dimension)
        This method returns first index matching given condition along given dimensions PLEASE NOTE: This method will return -1 values for missing conditions
        Parameters:
        array -
        condition -
        dimension -
        Returns: