Puneet, by enclosing the niceslice terms in quotes, you are forcing
them to be evaluated as strings rather than as Perl variables. Leave
off the quotes.
On Nov 24, 2010, at 7:06 AM, Puneet Kishor wrote:
Clifford Sobchuk wrote:
Hi Folks,
I am struggling to understand the slice indexing syntax for $a-
>slice( a:b:c ). I did this in perldl shell:
pdl> $a=sequence (3,10);p $a
[
[ 0 1 2]
[ 3 4 5]
[ 6 7 8]
[ 9 10 11]
[12 13 14]
[15 16 17]
[18 19 20]
[21 22 23]
[24 25 26]
[27 28 29]
]
pdl> p $a(1,0:9:2)
[
[ 1]
[ 7]
[13]
[19]
[25]
]
and it worked like I expected it to.
I then put it in to my script
foreach (0..5) {
print $pic;
$iob4 = $pic('0','$_:$picSize-1:6');
print "iob4 is $iob4 of size ",nelem($iob4),"\n";
and i only get a single value - the first one:
[
[5.7863319e+008 5.5061404e+008]
[5.7863344e+008 5.5635026e+008]
[ 5.790996e+008 5.3051317e+008]
[5.7875504e+008 5.3033015e+008]
[5.7936432e+008 5.277951e+008]
[5.7675125e+008 5.6184104e+008]
[5.7871172e+008 5.5064908e+008]
[ 5.786631e+008 5.5618585e+008]
[5.7911588e+008 5.3037927e+008]
...
[5.7905481e+008 5.2330437e+008]
[5.7738847e+008 5.607879e+008]
[5.7844745e+008 5.5221171e+008]
[5.7900191e+008 5.5709251e+008]
[5.7942135e+008 5.2928743e+008]
[5.7908425e+008 5.286075e+008]
[5.7902203e+008 5.2338163e+008]
[ 5.774559e+008 5.6077705e+008]
]
iob4 is
[
[5.7863319e+008]
]
of size 1
Where I expected to get the first column with every 6th entry
starting from the first element in the column.
What am I doing wrong.
Also I have
use PDL::NiceSlice ;
in the script, I still need to use ' ' around the values when
running the script in Windows (win32 ActiveState Perl 5.10). I am
debugging it in Eclipse with the EPIC plugin, and have also tried
it at the command line with the same results.
The single quotes are screwing up here. They are being evaluated as
0, so, in effect, your niceslice expression is becoming $pic(0,0)
Consider
my $pdl = sequence (3,10);
print "pdl: " . $pdl(1,0:9:2) . "\n";
my $c = $pdl('0','0:9:2');
my $d = $pdl(0,0);
print "c is $c of size ", nelem($c), "\n";
print "d is $d of size ", nelem($d), "\n";
I get
pdl:
[
[ 1]
[ 7]
[13]
[19]
[25]
]
c is
[
[0]
]
of size 1
d is
[
[0]
]
of size 1
Thanks,
CLIFF SOBCHUK
Ericsson
Core RF Engineering
Calgary, AB, Canada
Phone 613-667-1974 ECN 8109 x71974
Mobile 403-819-9233
[email protected]
yahoo: sobchuk
www.ericsson.com
“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. The web site for Ericsson is www.ericsson.com.”
This Communication is Confidential. We only send and receive email
on the basis of the terms set out at www.ericsson.com/email_disclaimer
_______________________________________________
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
_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl