Am 11.08.2021 um 20:44 schrieb Allin Cottrell:
On Wed, 11 Aug 2021, Sven Schreiber wrote:
> Am 11.08.2021 um 17:29 schrieb Allin Cottrell:
>>
>> matrices msplitby (matrix M, <vector-or-scalar> by, bool alt)
>>
>> where @alt would switch to column-wise splitting and scalar @by would
>> give the chunk size, provided the relevant dimension is divisible by
>> @by.
> Yes, that's what I had in mind, too.
>>
>> BTW splitting a matrix by columns will be much faster then by rows;
>
> Right, that's one reason why I found the current status a bit surprising.
Maybe a feature request is not necessary. The signature given above is
now supported in git, available for testing.
Excellent, thanks Allin!
I tested a little bit, and mostly it works fine I think. Some minor
observations:
- If the rows (or cols) are not dividible by "by", I get an "invalid
arg" error. Perhaps "Matrix not conformable" would be a more informative
error?
- (Probably not new behavior:) A scalar in place of M does not seem to
be allowed, as in msplitby(2, {1}). Of course this operation does not
look very useful, but it could arise in a corner case in a function or
script. And my understanding is that gretl always tries to allow a
scalar where a 1x1 matrix is valid, and msplitby({2}, {1}) already works.
thanks
sven