develooper Front page | | Postings from September 2000

RFC 81 and broadcasting

Thread Next
Christian Soeller
September 12, 2000 16:46
RFC 81 and broadcasting
Message ID:
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 Soeller       x2770
Dept. of Physiology              U. Auckland School of Medicine         
Auckland                         New Zealand

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About