nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/indexing/BooleanIndexing.java
public static void applyWhere(final INDArray to, final Condition condition, final Function<Number, Number> function,
                                  final Function<Number, Number> alternativeFunction) {
        Shape.iterate(to, new CoordinateFunction() {
            @Override
            public void process(long[]... coord) {
                if (condition.apply(to.getDouble(coord[0]))) {
                    to.putScalar(coord[0], function.apply(to.getDouble(coord[0])).doubleValue());
                } else {
                    to.putScalar(coord[0], alternativeFunction.apply(to.getDouble(coord[0])).doubleValue());
                }
            }
        });

    }
public static void applyWhere(final INDArray to, final Condition condition, final Function<Number, Number> function,
                                  final Function<Number, Number> alternativeFunction) {
        Shape.iterate(to, new CoordinateFunction() {
            @Override
            public void process(long[]... coord) {
                if (condition.apply(to.getDouble(coord[0]))) {
                    to.putScalar(coord[0], function.apply(to.getDouble(coord[0])).doubleValue());
                } else {
                    to.putScalar(coord[0], alternativeFunction.apply(to.getDouble(coord[0])).doubleValue());
                }
            }
        });

    }
public static void applyWhere ( final INDArray to , final Condition condition , final Function < Number , Number > function , final Function < Number , Number > alternativeFunction ) { Shape . iterate ( to , new CoordinateFunction ( ) { @ Override public void process ( long [ ] ... coord ) { if ( condition . apply ( to . getDouble ( coord [ 0 ] ) ) ) { to . putScalar ( coord [ 0 ] , function . apply ( to . getDouble ( coord [ 0 ] ) ) . doubleValue ( ) ) ; } else { to . putScalar ( coord [ 0 ] , alternativeFunction . apply ( to . getDouble ( coord [ 0 ] ) ) . doubleValue ( ) ) ; } } } ) ; }
Based on the matching elements
op to based on condition to with function function

@param to        the ndarray to op
@param condition the condition on op
@param function  the function to apply the op to
Based on the matching elements op to based on condition to with function function