On Tuesday 01 February 2005 01:18 am, Markus Laire wrote:
> Luke Palmer writes:
> > Yeah, the sigils do get in the way for small placeholder variables like
> > these:
> >     Â @C[ $i; $j; $k; $l ] = @A[ $i; $j ] * @B[ $k; $l ] Â
>...
> Would placeholder variables be used often enough to varrant their own
> sigil?

Can't say for sure.  This style of explicit threading was tried in PDL but 
turned out to not be as important as robust implicit threading, and the 
explicit threading (handled by block-scoped "thread variables" that you would 
declare before using them) never got robust enough to be considered a 
production feature.

The current threading engine in PDL uses positional dimension slots to work 
out what is what:  active dimensions have to be at the start of the dimension 
list, and thread dimensions have to be at the end.   In principle, this is a 
Bad Thing since you sometimes have to transpose arrays just to get the dims 
in the right slots; but it turns out to be a Good Thing: it is  the right 
optimization for nearly all of the expressions that ever get written.

For example, with PDL-style threading, Luke's expression (written by someone 
paranoid) would be:
        $c = $a(:,:,*1,*1) * $b(*1,*1,:,:);  # perl5/PDL 4-D outer product
where the names have been replaced by dimensional positions.
That still turns out to be more concise than the named version.

Most of the threading ops I do in PDL turn out to have zero active dimensions 
(scalar op, being looped over).  A few of them are vector ops (e.g. lookup 
into a table), and a lot are just matrix multiplication.  I have only had a 
few opportunities to use 5-D constructs (e.g. a collection of i x j image 
tiles that are themselves arrayed in an n x m matrix, with 3 colors).  I 
suspect that these sorts of higher dimensional operations will turn out to be 
ignored by virtually everyone -- but that they will turn out to be devilishly 
useful for a handful of brilliant people.



Reply via email to