Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create Array of same Size

Tags:

julia

I have an array

a = zeros(2,3)

2×3 Matrix{Float64}:
 0.0  0.0  0.0
 0.0  0.0  0.0

and I want to create a Bool array of same size with all values set to false.

like image 771
Georgery Avatar asked Dec 20 '25 21:12

Georgery


2 Answers

Another option is to use zeros with Bool as the type option:

julia> zeros(Bool, size(a))
2×3 Matrix{Bool}:
 0  0  0
 0  0  0
like image 94
Sundar R Avatar answered Dec 22 '25 11:12

Sundar R


One solution would be:

size(a) |> falses

2×3 BitMatrix:
 0  0  0
 0  0  0
like image 22
Georgery Avatar answered Dec 22 '25 10:12

Georgery



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!