Hi, in the context of a problem in the SVAR addon I've stumbled over
what might be a bug in msplitby:
Consider this:
<hansl>
clear
matrix M = {1,2}
matrices MM = msplitby(M, {2}) # gives invalid argument error
print MM
</hansl>
According to the doc, I would have instead expected a result equivalent to:
matrices MM = defarray(null, {1,2})
An example with a "taller" matrix works as expected:
<hansl>
clear
matrix M = {1,2; 3,4}
matrices MM = msplitby(M, {2,3}) # gives defarray(null, {1,2}, {3,4}), fine
print MM
</hansl>
So it looks to me as if the special case of a 1-element vector (matrix)
as the second argument to msplitby() isn't properly handled. Gretl seems
to treat it as a scalar then, and as per the documented behavior of
msplitby(), the meaning and desired result then changes.
In the real-world code that's affected, the length of the second matrix
argument can be 1 or more. Of course we can intercept the special case
of a single element and work around the problem; but shouldn't
msplitby() honor the user's input type also in the special 1-element case?
thanks
sven