Can you give an example of what you need this for?
In particular, I don’t understand what so you mean by “index” being different than zero. In your example you don’t have a list of indices.
Could you use the findall function and check if the result is empty?
For example, I have a function like the below to check if a column data has at least real value, i.e., non-NaN and non -999 (missing value indicator).
f(A) = [idx for idx in CartesianIndices(A) if @inbounds (!isnan(A[idx]) && A[idx] != -999)];
If my column data is as below:
B = [1.0, 2.0, NaN, 5.0, -999.0, 8.0];
Ind2 = f(B) would give me these Cartesian indices: Ind2 = CartesianIndex{1}[CartesianIndex(1,), CartesianIndex(2,), CartesianIndex(4,), CartesianIndex(6,)]
C[Ind2] = [1.0, 2.0, 5.0, 8.0]
What I’m trying to learn is how to check if Ind2 contains at least one true values.
I think I found the answer: isempty(Ind2) = true. # when there are no true values.
This is also how you should be doing the linear index comparison in the beginning. Why? Because any short-circuits. If the first element of A is >0, only one comparison is needed to definitively say that there is at least one element >0. Compare