Am 29.09.2015 um 18:48 schrieb Allin Cottrell:
Gretl is actually pretty clever at this (though no doubt the doc should
be made clearer).
First of all, it's right that you're not allowed to "take the address
of" an object inside a bundle; that's by design. However:
(1) When you reference a matrix inside a bundle, in the first instance
gretl simply records the matrix pointer (no full copy). If it then turns
out that you're assigning this matrix under a distinct name, then it
must be copied in full, but if it's just being used as intermediate
input it's not copied. For example
# case 1: 'm' is a full copy of bun.mat
matrix m = bun.mat
# case 2: 'm' is a new matrix but bun.mat is used as an argument
# without being copied.
matrix m = bun.mat'
(2) When a matrix is used as an argument to a user-defined function,
there are two ways to ensure it is "passed along" to the function rather
than being copied: give the argument in "pointer" form, or
mark the argument as "const".
So consider a modified version of your script:
function void hey(const matrix hu)
bbb.in = ones(2,2)
The matrix bbb.in will not be copied in this case. But if we removed the
const flag to the "hu" argument it would get copied on entry to the
Ok, very informative. Thanks!