You can also use:

bitbroadcast(&, inside_R_box, inside_Z_box)

to explicitly ask for a broadcasting operation which returns a BitArray. 
This is exactly what is being done under the hood by inside_R_box .* 
inside_Z_box, but the bitbroadcast version allows you to be more explicit, 
and to use other logical operators if needed.


On Wednesday, May 21, 2014 1:56:09 PM UTC+2, Tomas Lycken wrote:
>
> I have a few `BitArray`s representing various conditions, that I'd like to 
> assemble to a mask matrix. Basically, I want to achieve something like this:
>
> Rs = linspace(4,8,65)
> Zs = linspace(-3,3,136)' # yes, transposed
>
> inside_R_box = minR .< Rs .< maxR
> inside_Z_box = minZ .< Zs .< maxZ
>
> So far so good. Now, I want to combine the two in a broadcasting manner, 
> so that I get a full matrix with the entire mask. Neither of these work, 
> however:
>
> inside_box = inside_R_box && inside_Z_box # ERROR: type: non-boolean 
> (BitArray{1}) used in boolean context
> inside_box = inside_R_box .&& inside_Z_box # ERROR: syntax: invalid 
> identifier name "&&"
> inside_box = inside_R_box & inside_Z_box # ERROR: dimensions must match / 
> in promote_shape at operators.jl:186
> inside_box = inside_R_box .& inside_Z_box # ERROR: syntax: extra token 
> "inside_Z_box" after end of expression
>
> After I have the inside_box mask I want to `and` it with another mask of 
> the same dimensions, i.e.
>
> mask = inside_box & other_mask
>
> which I guess would work if I had some way to broadcast the R/Z comparison 
> to full matrix size. Is this missing functionality (and if so, is it 
> intentionally left out or just forgotten?) or a bug somewhere?
>
> I did try to search for a few different things in the documentation. 
> Unfortunately "and" is not a very good word to enter in search engines, and 
> I haven't been able to come up with any alternatives that render any hits...
>
> // Tomas
>

Reply via email to