I fail to see why the following peace of code does not show the appropriate results. For every i-th iteration, the values of A B C D are correct, but the matrix FF sometimes contains the values that do not match the values of A B C D at the current iteration.
n1,n2 = (Int(2),Int(2))
a = rand(n1,n2)
b = rand(n1,n2)
c = rand(n1,n2)
d = rand(n1,n2)
function main(a,b,c,d)
n1 = size(a,1)
n2 = size(a,2)
FF = Array{Float32}(undef,2,2)
aa = vec(a)
bb = vec(b)
cc = vec(c)
dd = vec(d)
Threads.@threads for ii = 1:n1*n2
A = aa[ii]
B = bb[ii]
C = cc[ii]
D = dd[ii]
FF .= [A B; C D]
println("i=$ii |--> A=$A, B=$B, C=$C, D=$D")
println("i=$ii |--> FF = $FF")
end
end
For example, I get:
i=1 |--> A=0.24456115815578272, B=0.8907566253514738, C=0.8642909161063068,
D=0.42008839717317614
i=1 |--> FF = Float32[0.18490697 0.8512475; 0.00025189313 0.5059466]
i=2 |--> A=0.5474336567786457, B=0.07123365660482706, C=0.7875180836356128,
D=0.4656796174911506
i=2 |--> FF = Float32[0.5474337 0.07123366; 0.7875181 0.46567962]
i=3 |--> A=0.1849069789564115, B=0.8512474692616838, C=0.00025189313264162294,
D=0.5059465926785536
i=3 |--> FF = Float32[0.5474337 0.07123366; 0.7875181 0.46567962]
i=4 |--> A=0.22001676024179484, B=0.40712367021744145, C=0.21883641119645225,
D=0.5583455220203384
i=4 |--> FF = Float32[0.22001676 0.40712368; 0.21883641 0.5583455]
where the results at i =1,3 do not match.