Dear Monks,
I've been sitting here for an hour trying to figure out this debugging problem. So, in a last ditch effort I'm hoping someone can pick out what's going on here. Here is the relevant snippet (this is a PDL routine):
my ($matrix, $limits) = @_; # I get my data and limits from the argum
+ents of subroutine
my $j = 1;
my ($pdl1, $pdl2, $n1, $n2);
my ($angle, $dotproduct, $d, %angles);
$pdl1 = pdl (@{$matrix}[0]);
$n1 = norm $pdl1;
while ($j<=$#{$matrix}) {
$pdl2 = pdl (@{$matrix}[$j]);
$n2 = norm $pdl2;
$dotproduct = inner ($n1, $n2);
$d = $dotproduct->sclr();
$angle = (180/3.14159)*acos($d);
$angles{$j} = $angle;
$j++;
}
my @sorted = sort {$angles{$a} <=> $angles{$b}} keys %angles;
And at this point I can't sort! It tells me that it returns an un-numeric value. But I SWEAR that my values are all numeric: if I push all $angle values into an array directly, I can sort them. Can anyone help me figure what's going on here?
20030516 Edit by Corion - Changed empty CODE blocks to BR tags
Title by tye
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.