Diab Jerius
2015-01-06 17:41:04 UTC
I've run into a situation where I need to copy a piddle into an
existing piddle with different dimensions. (Yes, I unfortunately
really need to do this.)
If the dimensions were the same, then the .= (assgn function) would
suffice, but in this case it won't.
The approach I've found is to do something like this:
$pdl1->setdims( [ $pdl2->dims ] );
${ $pdl1->get_dataref} = ${ $pdl2->get_dataref };
$pdl1->upd_data;
The drawback is that $pdl1's storage isn't shrunk if $pdl2 is smaller
than $pdl1 (underneath, Perl's SvGROW() routine is called, and it
won't shrink an SV). What I'd like to do looks schematically like
this:
$pdl1 .= null();
$pdl1 .= $pdl2;
Is there a way of null'ing an existing piddle at the Perl level?
Thanks,
Diab
existing piddle with different dimensions. (Yes, I unfortunately
really need to do this.)
If the dimensions were the same, then the .= (assgn function) would
suffice, but in this case it won't.
The approach I've found is to do something like this:
$pdl1->setdims( [ $pdl2->dims ] );
${ $pdl1->get_dataref} = ${ $pdl2->get_dataref };
$pdl1->upd_data;
The drawback is that $pdl1's storage isn't shrunk if $pdl2 is smaller
than $pdl1 (underneath, Perl's SvGROW() routine is called, and it
won't shrink an SV). What I'd like to do looks schematically like
this:
$pdl1 .= null();
$pdl1 .= $pdl2;
Is there a way of null'ing an existing piddle at the Perl level?
Thanks,
Diab