in reply to Lagrange Polynomials in Perl
You cannot shift an array off the argument stack: my @x = shift;
Assuming you are calling this as: lagrange( \@vals, \@funcs );
What you are shifting of the argument stack is an array reference; and to do that properly you need to assign it to a scalar variable:
my $refX = shift;
And then indirect through that to get your values:
$den *= ( $refX->[$i] - $refX->[$j] );
Do that for both your parameter arrays -- athough you do not seem to ever use @f anywhere in that function?
Also, what do you think this does: my $point = @x;?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Lagrange Polynomials in Perl
by Mascasc (Novice) on Apr 28, 2015 at 19:56 UTC | |
by BrowserUk (Patriarch) on Apr 28, 2015 at 20:42 UTC | |
by Mascasc (Novice) on Apr 29, 2015 at 14:36 UTC | |
by BrowserUk (Patriarch) on Apr 29, 2015 at 15:08 UTC | |
by Mascasc (Novice) on Apr 29, 2015 at 15:42 UTC | |
by Laurent_R (Canon) on Apr 28, 2015 at 20:25 UTC |