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 Number number) {
        if (condition instanceof BaseCondition) {
            // for all static conditions we go native

            Nd4j.getExecutioner().exec(new CompareAndSet(to, number.doubleValue(), condition));

        } else {
            final double value = number.doubleValue();

            final Function<Number, Number> dynamic = new Function<Number, Number>() {
                @Override
                public Number apply(Number number) {
                    return value;
                }
            };

            Shape.iterate(to, new CoordinateFunction() {
                @Override
                public void process(long[]... coord) {
                    if (condition.apply(to.getDouble(coord[0])))
                        to.putScalar(coord[0], dynamic.apply(to.getDouble(coord[0])).doubleValue());

                }
            });
        }
    }
public static void applyWhere(final INDArray to, final Condition condition, final Number number) {
        if (condition instanceof BaseCondition) {
            // for all static conditions we go native

            Nd4j.getExecutioner().exec(new CompareAndSet(to, number.doubleValue(), condition));

        } else {
            final double value = number.doubleValue();

            final Function<Number, Number> dynamic = new Function<Number, Number>() {
                @Override
                public Number apply(Number number) {
                    return value;
                }
            };

            Shape.iterate(to, new CoordinateFunction() {
                @Override
                public void process(long[]... coord) {
                    if (condition.apply(to.getDouble(coord[0])))
                        to.putScalar(coord[0], dynamic.apply(to.getDouble(coord[0])).doubleValue());

                }
            });
        }
    }
public static void applyWhere ( final INDArray to , final Condition condition , final Number number ) { if ( condition instanceof BaseCondition ) { // for all static conditions we go native Nd4j . getExecutioner ( ) . exec ( new CompareAndSet ( to , number . doubleValue ( ) , condition ) ) ; } else { final double value = number . doubleValue ( ) ; final Function < Number , Number > dynamic = new Function < Number , Number > ( ) { @ Override public Number apply ( Number number ) { return value ; } } ; Shape . iterate ( to , new CoordinateFunction ( ) { @ Override public void process ( long [ ] ... coord ) { if ( condition . apply ( to . getDouble ( coord [ 0 ] ) ) ) to . putScalar ( coord [ 0 ] , dynamic . apply ( to . getDouble ( coord [ 0 ] ) ) . doubleValue ( ) ) ; } } ) ; } }
This method sets provided number to all elements which match specified condition

@param to
@param condition
@param number
This method sets provided number to all elements which match specified condition