I have the following code:
function generateinputdistributions! (jointA, jointB)
rand! (jointA)
rand! (jointB)
println (sum (jointB))
jointA *= (1.0/sum (jointA))
jointB *= (1.0/sum (jointB))
println (sum(jointB))
end
And I have a few lines of code calling it in another file:
generateinputdistributions! (jointA, jointB)
println (sum (jointB))
where jointA and jointB have been preallocated. I expected that the third print statement should give an answer of 1 (the second one does). However, it does not, and instead gives the value of the first print statement. Thus, it looks like the jointA in jointA *= (1.0/sum (jointA)) is a local object that is destroyed. Can someone please explain what exactly is going on?
What I want to do is modify jointA and jointB in place (for performance reasons). rand! seems to do its job correctly. I don't understand this behavior of *=.