I'm not sure what you want that to do...
Zeroes and simialr constructors act differently depending on whether
the first argument is a PDL or not:
perldl> $p = pdl(5);
perldl> $a = zeroes($p,2,2); print $a;
perldl> $b = zeroes($p->list,2,2); print $b;
[
[
[0 0 0 0 0]
[0 0 0 0 0]
]
[
[0 0 0 0 0]
[0 0 0 0 0]
]
]
perldl> $c = zeroes(pdl($p,2,2)); print $c;
[0 0 0]
If the first argument is a PDL, then the dimension list of the PDL
gets used instead. That makes it easy to make a PDL with the exact
same size as one you already have, but it's confusing if you're not
used to the difference. The first case has a single PDL as the first
arg, so the ",2,2" is ignored. The second case has a scalar as the
first arg, so the argument list is (5,2,2), and you get a 5x2x2-PDL
out. The third case has a single PDL (with values [5 2 2]), so you
get a 3-PDL out.
Cheers,
Craig
On Sep 20, 2006, at 7:03 AM, Kåre Edvardsen wrote:
This one has annoyed me a long time...
Why don't this work???
$a = floor($b(0)) # $b is from a 'rcols' call
$c = zeroes $a, 2, 2;
Here $c turns out to be just [0], and I'd really like to be able to
create $c based on the value of $a.
All the best,
Kare
_______________________________________________
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