Hi,

I think the specific question was how to use the slicing syntax with all
but the selected elements, i.e. all elements except those indexed by $col.

If $col is a scalar, then something like cat( $x(:$c-1,),$x($c+1:, ) 
could work. Probably horribly inefficient and data flow is also lost, I
think.

I don't have a quick general answer, though.


On 08/25/2013 12:43 AM, Chris Marshall wrote:
>  If you are just starting with PDL, I recommend taking a look
> at the PDL Book (http://pdl.perl.org/?page=FirstSteps is the first
> chapter with a link to the PDF downloadable copy).
>
> In specific answer to your question, you can select parts of a
> piddle by indexes along a dimension using a piddle as the
> index in a PDL::NiceSlice expression or the direct dice() method
> call.  I PDL object (called/pronounced  a "piddle") has a fixed
> size on allocation.  If you wish to resize, that actually requires
> a memory copy of some sort.
>
> For large amounts of data, it is more efficient to use the slicing
> operations to select pieces of a larger piddle to work on.  If you
> wish to replace an existing piddle with the new subset, just
> assign it with = to the original piddle scalar.  E.g.:
>
>   $a = sequence(3,5);   # create original piddle
>   $cols = pdl(0,1);         # piddle of col indexes to keep
>   $a = $a($cols,:);         # selects those indices from dim(0)
>
> The final line results in a reallocated $a piddle.  If you do
> this instead:
>
>   $a_good = $a($cols,:);
>
> Then $a is still the same but $a_good is basically a piddle
> of the selected elements.  The cool things is that you can
> use the elementwise assign to change the $a_good values
> and those will be modified in the original $a:
>
>   $a_good .= -1;
>
> Now see what $a contains....  There are various examples in
> the PDL Book that go into more depth about threading and
> slicing....
>
> Happy PDL-ing!
> Chris
>
>
> On Sat, Aug 24, 2013 at 12:54 PM, VE <[email protected]> wrote:
>> Dear All,
>>
>> this is my first post so if I break some rules do not beat me too hard.
>>
>> I make my first steps with PDL and have the following problem.
>>
>> Given the script:
>>
>> #!/perl
>> use strict;
>> use warnings;
>> use PDL;
>> use PDL::NiceSlice;
>> my $a  = sequence  (3,5);
>> print $a;
>> my $col = 2;
>> my $t = $a( $col,);
>> print $t;
>> print $a;
>>
>> I get the following output:
>>
>> [
>>  [ 0  1  2]
>>  [ 3  4  5]
>>  [ 6  7  8]
>>  [ 9 10 11]
>>  [12 13 14]
>> ]
>> [
>>  [ 2]
>>  [ 5]
>>  [ 8]
>>  [11]
>>  [14]
>> ]
>> [
>>  [ 0  1  2]
>>  [ 3  4  5]
>>  [ 6  7  8]
>>  [ 9 10 11]
>>  [12 13 14]
>> ]
>>
>> How can I modify the parent ($a) so that it contains "everything except what
>> is in the slice", as follows:
>>
>> [
>>  [ 0  1  ]
>>  [ 3  4  ]
>>  [ 6  7  ]
>>  [ 9 10 ]
>>  [12 13]
>> ]
>>
>> Thank you very much in advance.
>>
>> VE
>> ---
>> [email protected]
>> 24.08.2013
>>
>> _______________________________________________
>> 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
>


_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to