develooper Front page | perl.perl6.language.data | Postings from September 2000

RFC 81 and broadcasting

Thread Next
From:
Christian Soeller
Date:
September 12, 2000 16:46
Subject:
RFC 81 and broadcasting
Message ID:
39BEB311.42797D9@auckland.ac.nz
Maybe that's already implicit in the broadcasting proposal but it
wouldn't hurt to spell it out:

  A dimension size of 1 should be broadcasted to match that of the
  other operand. So, for example, the following shapes (returned by 
  @#array) are compatible:

   @c     =         @a       *       @b   

  result shape     shape @a        shape @b

  [4,8,5]           [4,1,5]        [4,8,5]
  [5,3,2]           [1,3,2]        [5,1,2]

In that respect it would be nice to have a slicing syntax to introduce
'dummy' dimensions of size 1 (e.g. Yorick uses the concept of a
pseudo-index, [1]; similarly NumPy [2]; PDL has dummy dimensions via '*'
using C<slice>):

  @a = sin @x; # 1D array
  @b = cos @x;

  @twod = @a * @b[-;];

which would be the same as

  @twod[|i;|j] = @a[|i] * @b[|j];

 Christian


[1] ftp://ftp-icf.llnl.gov/pub/Yorick/ydoc/manual/Pseudo-Index.html
[2] http://numpy.sourceforge.net/numdoc/HTML/numdoc.html#pgfId-36371

-- 
Christian Soeller                c.soeller@auckland.ac.nz x2770
Dept. of Physiology              U. Auckland School of Medicine         
Auckland                         New Zealand

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About