How do i get index where condition is matched.

for ex -

INDArray test = Nd4j.create(new double{2,3,5,6,7,8,9,5,6,2,3,2,2});

if from test array i want index where number is equal to 2 , How will i get that ??

@Akshay591 could you reword your question a bit? Are you hoping to just get the index of elements matching a condition or using a numpy like where function where you return elements of 1 array or another? Eg: https://numpy.org/doc/stable/reference/generated/numpy.where.html

@agibsonccc I want the Indexes of matching element , So according to the above example if the

Condition = Conditions.equal(2) the Returned Array should Contain indexes which is [0,9,11,12] .

In Numpy we use to get the Indexes like this

test = np.array([2, 3, 5, 6, 7, 8, 9, 5, 6, 2, 3, 2, 2])

idx = np.where(test == 2)[0]

@Akshay591 ah I see.

This is what you want:

```
INDArray test = Nd4j.create(new double[] {2,3,5,6,7,8,9,5,6,2,3,2,2});
INDArray falseArr = Nd4j.zeros(test.shape());
INDArray other = Nd4j.ones(test.shape());
INDArray[] result = Nd4j.where(test.eq(2),null,null);
System.out.println(result[0]);
```

This invokes a numpy mode of Nd4j.where(…). You need to create a mask array. That’s what test.eq(2) does in this case.