Hi all,
I stumbled across something recently that I wanted to mention. It relates to the copy behavior of dmatrix objects.
If you declare a matrix explicitly and then set it equal, it will copy the values of the original object (deep copy). Like this:
dmatrix mat1(1,2,1,2);
mat1=mat0;
Instead if you declare and assign in one step, it creates a shallow copy so that if the original object changes so does the new one.
dmatrix mat2=mat0;
I naively assumed these would be the same and was perplexed by the behavior until I had some help to track it down (HT Matt Supernaw). The attached model demonstrates the behavior.
I wonder if it is worth putting this in the documentation somewhere? I doubt many users would expect this. But at the same time it's not a common thing to do when building a model, so maybe it is not that important. I didn't check with other data types either.
I just wanted to flag this for consideration and get thoughts.
Thanks,
Cole