Derek Lamb wrote:
> Gabor Szabo wrote:
>> Another thing I was surprised by and I am not
>> sure if I should reset my expectation or if this is a bug?
>>
>> perldl> p $x
>> [1 1]
>> perldl> p $x->append(2);
>> [1 1 2]
>> perldl> p $x
>> [1 1]                (first surprise)
>>
>> perldl> p $x->inplace->append(2)
>> [1 1 2]
>> perldl> p $x
>> [1 1]                 (bigger surprise)
>>
>>
>> Originally I thought ->append would work inplace automatically but if not
>> I hoped using inplace would convince it to change the underlying piddle.
>>
>> regards
>>     Gabor    using PDL 2.4.3 on this computer
>>   
> Inplace docs:  "However one can assume [that inplace will work] for all 
> elemental functions (i.e. those which just operate array element by 
> array element like "log10")."
> 
> You're running into the difference between perl lists and piddles.  You 
> can add/subtract from perl lists with pop, push, shift, unshift easily.  
> But piddles need to have a defined datatye (float, short, etc) and 
> size.  That's where the efficiency of piddles happens.  If you want to 
> append, glue, cat, etc, you generally need to create a new piddle, but 
> of course $x = $x->append(2) would have worked.
> 
> To understand why you need to create new piddles when using append, 
> think about what should happen to $x after the attempted inplace append 
> in the following scenario:
> 
> $x = sequence(10,3);
> $y = $x((3))
> $y->inplace->append(33); #bad
> $z = $y->append(33); #good
> 
> Other sensible operations on $y (multiply by 2) would flow back to $x, 
> but what happens to the 33?
> 
> Derek

Ideally the use of inplace would be flagged as an error when used 
incorrectly or in an unsupported routine. I haven't looked at the code 
recently enough to know if this is even possible.

Doug

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

Reply via email to