Ok, I need an explanation why your first solution was ?Cheating? I
thought I understood the first solution fairly easily, the second one I
get lost in. I worked it through and it works, but I still get lost with
the last bit of the transforming. I see that you create a mask for
number of replications that you want as a replication of the dimensions.
I followed that multiplying the original by the mask created duplicates
through the dummy variable ($ou *= $in). But I have no idea how you
figured out the correct re-ordering and reshaping.
 
So two questions.
 
1) Karl, why was the first solution cheating and how was it using PDLpp?

 
2) Matt, how did you know which dimensions had to be clumped. The
reshaping I understand that you need to get back to the original
dimensions, but I don't follow how this is completed.
 
Thanks, 
 
Cliff Sobchuk esn 361-8169, 403-262-4010 ext: 361-8169
Fax: 403-262-4010 ext: 361-8170
Core RF Support Engineer 

        "The author works for Telefonaktiebolaget L M Ericsson
("Ericsson"), who is solely responsible for this email and its contents.
All inquiries regarding this email should be addressed to Ericsson.
Nortel has provided the use of the nortel.com domain to Ericsson in
connection with this email solely for the purpose of connectivity and
Nortel Networks has no liability for the email or its contents. The web
site for Ericsson is www.ericsson.com <http://www.ericsson.com/> ."

 

________________________________

From: Matthew Kenworthy [mailto:[email protected]] 
Sent: April 16, 2010 3:31 AM
To: Karl Glazebrook
Cc: perldl
Subject: Re: [Perldl] expanding a piddle


On Fri, Apr 16, 2010 at 10:14 AM, Karl Glazebrook
<[email protected]> wrote:


        There must be a fiendish solution involving dummy() and
reshape()? PDLpp is cheating!
        
        Karl
        



Sheesh! Some people are never satisfied....

Here you go :)


my $nx = 5; my $ny = 5;
my @out = dims($in);
my $ou = ones(@out, $nx, $ny);

# 0    1    2   3
# inx, iny, nx, ny
$ou *= $in;

# rearrange so that we clump nx and inx together, then ny and iny
# then reshape it to the output we want
my $ou2 = $ou->reorder(2,0,3,1)->reshape($out[0]*$nx, $out[1]*$ny);

print $ou2;


Cheers,

Matt

-- 
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

Reply via email to