You are supposed to be able to pad it out by throwing them all into
the constructor "pdl()", but there is currently a bug in the
constructor that sometimes crashes in that case.
Unfortunately, your best bet (other than fixing the constructor bug)
is to use several lines:
$dims = cat(pdl(map { $_->dims } @p))->mv(-1,0)->maximum;
$pdl = new_from_specification(0...@p, $dims);
for $i(0..$#p){
$pdl->(($i)) .= $p[$i]->range( 0 * $dims , $dims, 't');
}
That copies each element of @p into the original array, with
truncation as a boundary condition.
There's a slightly faster formulation using slice, but it is much
yuckier to read.
On Jun 21, 2010, at 3:47 PM, P Kishor wrote:
> I have a bunch of "identical" piddles in an array @p that I am cat-ing
> together and mv-ing their dimensions so I can extract values from them
> from a single loop. Each piddle has two dimensions, say 'x' and 'y' --
>
> 1> $pdl = cat(@p)->mv(-1, 0);
> 2> for my $i (1 .. $x) {
> 3> for my $j (1 .. $y) {
> 4> my $vals = $pdl(:,($i - 1),($j - 1));
> 5> }
> 6> }
>
> I have encountered a problem... one of my piddles has different
> dimension 'x' from other piddles. It is an error in the data, but I
> don't want it to stop my work. Say, the value of $x is supposed to be
> 1000, but for one of the piddles, the value of $x is 990. This causes
> line 1 above to blow up with
>
> PDL: PDL::Ops::assgn(a,b): Parameter 'b'
> PDL: Mismatched implicit thread dimension 1: should be 990, is 1000
>
> Is there are way I can pad that piddle with the difference, so things
> proceed on?
>
> --
> Puneet Kishor
>
> _______________________________________________
> 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