ILLogical L = ILMath.rand(10, 12) > 0.5;
>L
Logical [10,12]
[0]: 0 0 0 1 1 1 0 0 0 0 1 1
[1]: 0 1 1 1 0 1 1 1 1 0 1 0
[2]: 0 1 1 1 1 1 0 1 1 0 1 1
[3]: 0 0 0 0 0 1 0 0 0 0 1 0
[4]: 0 0 0 0 0 0 1 0 1 1 0 0
[5]: 0 0 1 0 0 1 0 0 1 1 1 1
[6]: 1 0 1 0 1 1 0 1 0 1 0 1
[7]: 1 1 1 0 1 1 0 1 1 1 0 1
[8]: 1 0 0 1 1 1 0 0 1 0 0 0
[9]: 1 1 1 1 0 0 0 0 1 1 0 0
Write out column/row indices as pairs:
ILArray<int> C = 1;
ILArray<int> R = ILMath.find(L, 0, C);
// C now holds the column indices, R the row indices
for (int i = 0; i < C.Length; i++) {
System.Diagnostics.Debug.WriteLine("({0},{1})", R.GetValue(i), C.GetValue(i));
}
Which gives:
(6,0)
(7,0)
(8,0)
(9,0)
(1,1)
(2,1)
(7,1)
(9,1)
(1,2)
(2,2)
(5,2)
(6,2)
(7,2)
(9,2)
(0,3)
(1,3)
(2,3)
(8,3)
(9,3)
(0,4)
(2,4)
(6,4)
(7,4)
(8,4)
(0,5)
(1,5)
(2,5)
(3,5)
(5,5)
(6,5)
(7,5)
(8,5)
(1,6)
(4,6)
(1,7)
(2,7)
(6,7)
(7,7)
(1,8)
(2,8)
(4,8)
(5,8)
(7,8)
(8,8)
(9,8)
(4,9)
(5,9)
(6,9)
(7,9)
(9,9)
(0,10)
(1,10)
(2,10)
(3,10)
(5,10)
(0,11)
(2,11)
(5,11)
(6,11)
(7,11)