Subject: | t/02bad_deriv.t fails on little-endian PPC: Can't call method "element" on an undefined value |
The t/02bad_deriv.t test fails for me on little-endian 64-bit PowerPC:
Can't call method "element" on an undefined value at /builddir/build/BUILD/Algorithm-CurveFit-1.05/blib/lib/Algorithm/CurveFit.pm line 217.
# Looks like your test exited with 255 before it could output anything.
t/02bad_deriv.t ..
Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 13/13 subtests
The CurveFit.pm code is:
# solve
my $LR = $matrix->decompose_LR();
my ( $dim, $x, $B ) = $LR->solve_LR($vector);
# extract parameter modifications and test for convergence
my $last = 1;
foreach my $pno ( 1 .. @parameters ) {
→ my $dlambda = $x->element( $pno, 1 );
It looks like $x matrix returned by solve_LR() is undef. Math::MatrixReal::solve_LR() documentation reads:
The method returns a list of three items if a solution exists or an
empty list otherwise (!).
Therefore, you should always use this method like this:
if ( ($dim,$x_vec,$base) = $LR->solve_LR($b_vec) )
{
# do something with the solution...
}
else
{
# do something with the fact that there is no solution...
}
The Algorightm::CurveFit code does not handle this case when the solution does not exist.
I don't understand the code good enough to say where the bug is, if it's possible to reach the unsolvable case or if this is some bug in underneath mathematical functions failing in the PowePC architecture.