Evanovich has asked for the wisdom of the Perl Monks concerning the following question:
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?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;
20030516 Edit by Corion - Changed empty CODE blocks to BR tags
Title by tye
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Maybe I'm just dumb...
by pfaut (Priest) on May 16, 2003 at 03:15 UTC | |
Re: Maybe I'm just dumb...
by Zaxo (Archbishop) on May 16, 2003 at 06:02 UTC | |
Re: Maybe I'm just dumb...
by BrowserUk (Patriarch) on May 16, 2003 at 03:20 UTC | |
by Evanovich (Scribe) on May 16, 2003 at 04:23 UTC | |
Re: Maybe I'm just dumb...
by edoc (Chaplain) on May 16, 2003 at 03:19 UTC | |
Re: Maybe I'm just dumb...
by Evanovich (Scribe) on May 16, 2003 at 04:30 UTC | |
by Enlil (Parson) on May 16, 2003 at 05:25 UTC | |
by belg4mit (Prior) on May 16, 2003 at 05:26 UTC | |
by SparkeyG (Curate) on May 17, 2003 at 00:41 UTC | |
Re: Debugging a sort in PDL routine
by etj (Priest) on Jun 26, 2022 at 02:47 UTC |