On Sat, 13 Oct 2012, Logan Kelly wrote:
I am using GRETL 1.9.9 on a Win 7 64bit machine. I found a quirk
that may be a bug. I found that
bundle BundleOfMatrixs
matrix BundleOfMatrixs["test"] = {}
matrix test = {1,2,3,4}
BundleOfMatrixs["test"] |= test
yields the following error message
'|=' : only defined for matrices
Error executing script: halting
> BundleOfMatrixs["test"] |= test
but that
bundle BundleOfMatrixs
matrix BundleOfMatrixs["test"] = {}
matrix test = {1,2,3,4}
BundleOfMatrixs["test"] = BundleOfMatrixs["test"]|test
works just fine.
Hmm, not sure this is a bug. This basic idea with bundles is that if
you want to do anything with a matrix (or any other sort of object)
from inside the bundle you have to extract it first (which makes a
copy of the object).
At first I was a little surprised that even your second formulation
worked, but on reflection it's OK: on the right hand side,
BundleOfMatrixs["test"] produces an anonymous matrix which is a copy
of the one in the bundle, to which you concatenate another matrix;
then the "=" operation replaces the bundle content under the key
"test" with the new right-hand side matrix. That is, your second
version is an acceptable variant of the canonical form
matrix m = BundleOfMatrixs["test"] # extract
m |= {1,2,3,4} # modify
BundleOfMatrixs["test"] = m # re-assign
I guess one could argue that your first formulation should be taken
as shorthand for your second, but I have to say it doesn't "look
right" to me; I would not have expected it to work -- though I admit
I'd have had difficulty predicting the error message.
Allin Cottrell