In matlab, when we do A = B, A and B will point to the same matrix.
The copy is postponed to the moment when we modify the data.
Matlab does some 'reference counting' to reduce memory copy.
But if we do A = B + 0., A will be a different matrix than B.
This is really an issue when we do A=B and then pass A as a parameter
to mex function.
Another workaround is to save to mat and reload.
Also, it can be tricky to pass things like A(:, c) to mex-C, because
mex-C may not update
the column c of A as we want.
Thanks Pof. Wu at Stat. UCLA.
On Feb 9, 5:33 am, Hiho <
haifeng.g...@gmail.com> wrote:
> In matlab, when we do A = B, A and B will point to the same matrix.
> The copy is postponed to the moment when we modify the data.
> Matlab does some 'reference counting' to reduce memory copy.
> But if we do A = B + 0., I will be a different matrix than J.
>
> This is really a issue when we do A=B and then pass A as a parameter
> to mex function.
>
> Another workaround is to save to mat and reload.
>
> Also, it can be tricky to pass things like A(:, c) to mex-C, because
> mex-C may not update
> the column c of A as we want.