thanks it worked out ... here is my final code...

->range(@slices, [5, 0, 0] )->transpose->sumover;


On Thu, Sep 19, 2013 at 2:11 AM, mraptor <[email protected]> wrote:

> thanks I will experiment with what you are saying tomorrow...too late ;)
>
> I may have misled with the example the dice part..  what I want to achieve
> is from every one of the 3 layers I want to pick random lines/rows and
> sumover them..
> (by random I mean they are not sequential like row 1,2,3 ... but could be
> 1,4 or 1,2,5 )
>
> sorry for the long example but here goes, let say I have :
> [
>  [
>   [1 1 1 1 1]
>   [2 1 1 1 1]
>   [3 1 1 1 1]
>   [4 1 1 1 1]
>   [5 1 1 1 1]
>  ]
>  [
>   [1 2 2 2 2]
>   [2 2 2 2 2]
>   [3 2 2 2 2]
>   [4 2 2 2 2]
>   [5 2 2 2 2]
>  ]
>  [
>   [1 3 3 3 3]
>   [2 3 3 3 3]
>   [3 3 3 3 3]
>   [4 3 3 3 3]
>   [5 3 3 3 3]
>  ]
> ]
>
>
> I want to get back let say ( and sum over them):
>
> [
>  [
>   [1 1 1 1 1]
>   [3 1 1 1 1]
> ]
>  [
>   [2 2 2 2 2]
>   [4 2 2 2 2]
>  ]
>  [
>   [1 3 3 3 3]
>   [3 3 3 3 3]
>   [4 3 3 3 3]
>   [5 3 3 3 3]
>  ]
> ]
>
> thanks again...
>
>
>
> On Thu, Sep 19, 2013 at 1:51 AM, Craig DeForest <[email protected]
> > wrote:
>
>> I'm not sure exactly what you're asking here.
>>
>> Dicing your 3D PDL will select a collection of planes out of the PDL and
>> stack them along the same direction you're selecting in, extracting
>> hyperplanes.  It looks like your $p1, $p2, and $p3 are, respectively,
>> 5x2x1, 5x1x1, and 5x2x1.  I think you're asking if you can get all those
>> loci as a 5x5x1 PDL in one go.
>>
>> If that's the case, you're looking for range().
>>
>> Try this:
>>
>>         $corners = pdl( [
>>                 [0,2,0],  # $p1
>>                 [0,3,0],  # $p1
>>                 [0,4,1],  # $p2
>>                 [0,1,2],  # $p3
>>                 [0,5,2]   # $p3
>>                 ]);
>>         $foo = $z->range($corners, [5,0,1])->mv(0,1);
>> The $corners gives coordinates of the corners of the planes you want to
>> extract.  The second list ref (or PDL) in the range() call is the shape of
>> each plane.  The middle size is set to 0 to drop that dim, so each range
>> will be a 5x1 plane.  You get five ranges, and the 0 dim runs across the
>> ranges, so the output of range() will be a 5x5x1, running across
>> (selected-region, source-dim-0, source-dim-2).  Since the selected regions
>> take the place of the dicing in dim 1, I put a "mv(0,1)" there to make the
>> final output run across (source-dim-0, selected-region, source-dim-2) like
>> you probably wanted.
>>
>>
>>
>> On Sep 18, 2013, at 10:20 PM, mraptor <[email protected]> wrote:
>>
>> > hi,
>> > I have a nD pdl (in this case 3D), something like this :
>> >
>> > $z = zeros(5,5,3)
>> > $z(,,0) .= ones(5,5)
>> > $z(,,1) .= ones(5,5)+1
>> > $z(,,2) .= ones(5,5)+2
>> >
>> > $p1 = $z(,pdl(2,3),0)
>> > $p2 = $z(,pdl(4),1)
>> > $p3 = $z(,pdl(1,5),2)
>> >
>> > I remember I read somewhere I can extract all those elements in one go,
>> but forgot what was it and how to use it... I want to do something along
>> the lines :
>> >
>> > $sum = $z->dice( $p1,$p2,$p3)->transpose->sumover;
>> > my $idx = which($sum == 0);
>> > $sum->where($sum > 0) .= 1;
>> > .... etc...
>> >
>> > any idea... thanks
>> > _______________________________________________
>> > Perldl mailing list
>> > [email protected]
>> > http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
>>
>>
>
_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to