Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a 1x1 Julia array

Tags:

arrays

julia

I would like to create a 1×1 array (say an Array{Float64,2}) and initialize it to some value. Of course this works:

M=zeros(1,1)
M[1,1]=0.1234

Is there a more concise way to create M and initialize it at the same time?

like image 812
Arrigo Avatar asked Dec 11 '25 19:12

Arrigo


1 Answers

Since [1.1234] will give you a Vector in Julia the simplest way I could come up with is:

julia> fill(1.234,1,1)
1x1 Array{Float64,2}:
 1.234
like image 92
vchuravy Avatar answered Dec 14 '25 08:12

vchuravy



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!