Package org.nd4j.linalg.indexing
Class BooleanIndexing
- java.lang.Object
-
- org.nd4j.linalg.indexing.BooleanIndexing
-
public class BooleanIndexing extends Object
Boolean indexing- Author:
- Adam Gibson
-
-
Constructor Summary
Constructors Constructor Description BooleanIndexing()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
and(INDArray n, Condition cond)
And over the whole ndarray given some conditionstatic boolean[]
and(INDArray n, Condition condition, int... dimension)
And over the whole ndarray given some condition, with respect to dimensionsstatic INDArray
applyMask(INDArray arr, INDArray mask)
A minor shortcut for applying a bitmask to a matrixstatic INDArray
applyMaskInPlace(INDArray arr, INDArray mask)
A minor shortcut for applying a bitmask to a matrixstatic void
assignIf(@NonNull INDArray to, @NonNull INDArray from, @NonNull Condition condition)
This method does element-wise comparison for 2 equal-sized matrices, for each element that matches Condition.static INDArray
chooseFrom(@NonNull INDArray[] input, @NonNull List<Double> tArgs, @NonNull List<Integer> iArgs, @NonNull Condition condition)
Choose from the inputs based on the given condition.static INDArray
chooseFrom(@NonNull INDArray[] input, @NonNull Condition condition)
Choose from the inputs based on the given condition.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 metstatic 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 conditionsstatic 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 metstatic 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 conditionsstatic boolean
or(INDArray n, Condition cond)
Or over the whole ndarray given some conditionstatic boolean[]
or(INDArray n, Condition condition, int... dimension)
Or over the whole ndarray given some condition, with respect to dimensionsstatic void
replaceWhere(@NonNull INDArray to, @NonNull Number set, @NonNull Condition condition)
This method does element-wise assessing for 2 equal-sized matrices, for each element that matches Conditionstatic void
replaceWhere(@NonNull INDArray to, @NonNull INDArray from, @NonNull Condition condition)
This method does element-wise comparison for 2 equal-sized matrices, for each element that matches Condition
-
-
-
Method Detail
-
and
public static boolean and(INDArray n, Condition cond)
And over the whole ndarray given some condition- Parameters:
n
- the ndarray to testcond
- 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 testcondition
- 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 testcondition
- 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 tofrom
- the mask arraycondition
- 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 filtercondition
- 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 tomask
- 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 tomask
- 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 filtertArgs
- the double argsiArgs
- the integer argscondition
- 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:
-
-