Re: reshape() (was Re: Fw: Wrapup time)

[email protected] (Christian Soeller) Thu, 14 Sep 2000 13:39:51 +1200
Newsgroups perl.perl6.language.data
Organization University of Auckland
Message-ID <[email protected]>
Jeremy Howard wrote:

> the maximum index of each dimension. A maximum index of '0' would mean that
> that dimension is 1 element wide. Therefore '0' can not be special in
> reshape(). Therefore we should use '-1'.

-1 is the maximum index for any size in the usual fashion of perl array
indexing. However, do you really want to give the args to reshape in the
@#array form? This in contrast to any other array language I know where
the actual shape of the target array is used which is related to @#array
via

  @shape = @#array+1;

I see a great source of confusion here. Similarly I would change the
bound(@#args) to shape(@shape) [or allow it as an alias]

  my @b : shape(3,3); # fixed shape -- corresponds to bounds(2,2)
  print @#b;
 2 2

That's how NumPy, PDL, IDL, MatLab, Yorick treat things (and any other
similar language I have come across). I hadn't noted this in the RFCs
before. Breaking these conventions will *not* help acceptance.

  Christian