Quantcast
Channel: First steps - JuliaLang
Viewing all articles
Browse latest Browse all 2795

Using BitArray to index into another Array

$
0
0

Hello, I am confused by the error I receive on a simple piece of code involving a BitArray. Here is a MWE:

a = [1 2 3];
B = [1 2 3; 4 5 6; 7 8 9];
ids = all(a. == B, dims=2);

Everything works as intended up to here and I obtain a BitArray that behaves as expected:

julia> all(a.==B,dims=2)
3×1 BitArray{2}:
 1
 0
 0

The problem is trying to use this BitArray to index any given array:

C = B[ids,:];

will throw an out of bounds error even though ids and B have the same maximum dimension. What am I doing wrong?

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 2795

Trending Articles