rescale2d is what you're looking for:
use PDL; use PDL::Image2D; my $in = pdl ( [1,0,8], [6,3,5], [3,0,5], [2,4,2]); print $in; my $nx = 5; my $ny = 5; my @out = dims($in); my $ou = zeroes($out[0]*$nx, $out[1]*$ny); rescale2d ($in, $ou); print $ou; Cheers, Matt On Fri, Apr 16, 2010 at 9:07 AM, P Kishor <[email protected]> wrote: > Imagine I have a data structure like so > > [ > [1 0 8] > [6 3 5] > [3 0 5] > [2 4 2] > ] > > I want to convert it into the following piddle > > [ > [1 1 1 1 1 0 0 0 0 0 8 8 8 8 8] > [1 1 1 1 1 0 0 0 0 0 8 8 8 8 8] > [1 1 1 1 1 0 0 0 0 0 8 8 8 8 8] > [1 1 1 1 1 0 0 0 0 0 8 8 8 8 8] > [1 1 1 1 1 0 0 0 0 0 8 8 8 8 8] > [6 6 6 6 6 3 3 3 3 3 5 5 5 5 5] > [6 6 6 6 6 3 3 3 3 3 5 5 5 5 5] > [6 6 6 6 6 3 3 3 3 3 5 5 5 5 5] > [6 6 6 6 6 3 3 3 3 3 5 5 5 5 5] > [6 6 6 6 6 3 3 3 3 3 5 5 5 5 5] > [3 3 3 3 3 0 0 0 0 0 5 5 5 5 5] > [3 3 3 3 3 0 0 0 0 0 5 5 5 5 5] > [3 3 3 3 3 0 0 0 0 0 5 5 5 5 5] > [3 3 3 3 3 0 0 0 0 0 5 5 5 5 5] > [3 3 3 3 3 0 0 0 0 0 5 5 5 5 5] > [2 2 2 2 2 4 4 4 4 4 2 2 2 2 2] > [2 2 2 2 2 4 4 4 4 4 2 2 2 2 2] > [2 2 2 2 2 4 4 4 4 4 2 2 2 2 2] > [2 2 2 2 2 4 4 4 4 4 2 2 2 2 2] > [2 2 2 2 2 4 4 4 4 4 2 2 2 2 2] > ] > > more generically, given a 2d array and 'n', I want each element in > each array to repeat 'n' times, both in rows and in columns. So, 'n' > in the example shown above is 5. How can I accomplish the above? For > now, I am doing a traditional loop within loop kinda thing. It works, > but it feels to be very un-pdl like. > > -- > Puneet Kishor > > _______________________________________________ > Perldl mailing list > [email protected] > http://mailman.jach.hawaii.edu/mailman/listinfo/perldl > > -- Matthew Kenworthy / Assistant Professor / Leiden Observatory Niels Bohrweg 2 (#463) / P.O. Box 9513 / 2300 RA Leiden / NL
_______________________________________________ Perldl mailing list [email protected] http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
