Am 08.07.2019 um 08:12 schrieb Riccardo (Jack) Lucchetti:
On Sun, 7 Jul 2019, Allin Cottrell wrote:
>> Do you guys like the idea?
>
> Yes. It's now in git.
Thanks; besides, we could extend Sven's idea to mshape() and make the
third argument optional (defaulting to 1, of course). Is this a good idea?
Not sure I like the default 1. If X has exactly r elements,
mshape(X,r,1) can be easily achieved by vec(X), right? And it seems to
me it is not a very standard case to use mshape(X,r,1) for r != nelem(X).
What might be nice is to make mshape more clever, to automatically
determine the necessary number of columns c. Example:
matrix X = ones(3,2)
m1 = mshape(X,2,3) # old explicit syntax
m2 = mshape(X,2) # proposed
That is, if the 3rd arg is omitted, mshape would try to calculate c =
nelem(X) / r. (It would throw an error if the result is not an integer.)
cheers
sven