





 
 




 
 


I was just looking at the source code for POVRay 3.7 for solving polynomials. In
the default case for Solve_Polynomial it looks to me like it solves the
polynomial twice for orders higher than four when a root is eliminated. I am
trying to understand the code for my own use. Could there be a break statement
missing ? Otherwise why does it solve for order n1 and then n ?
The code looks like:
default:
if (epsilon > 0.0)
{
if ((c[n1] != 0.0) && (fabs(c[n]/c[n1]) < epsilon))
{
Thread>Stats()[Roots_Eliminated]++;
roots = polysolve(n1, c, r);
}
}
/* Solve nth order polynomial. */
roots = polysolve(n, c, r);
break;
Post a reply to this message


 
 




 
 


Le 20/10/2016 à 09:39, robfi680 a écrit :
> I was just looking at the source code for POVRay 3.7 for solving polynomials. In
> the default case for Solve_Polynomial it looks to me like it solves the
> polynomial twice for orders higher than four when a root is eliminated. I am
> trying to understand the code for my own use. Could there be a break statement
> missing ? Otherwise why does it solve for order n1 and then n ?
>
> The code looks like:
> default:
>
> if (epsilon > 0.0)
> {
> if ((c[n1] != 0.0) && (fabs(c[n]/c[n1]) < epsilon))
> {
> Thread>Stats()[Roots_Eliminated]++;
>
> roots = polysolve(n1, c, r);
> }
> }
>
> /* Solve nth order polynomial. */
>
> roots = polysolve(n, c, r);
>
> break;
>
>
>
The interesting part is that master branch is already corrected : yes, a
break is/was missing.
Now, it only occurs for 5th and more order polynomial, something that is
rarely seen.
The correction was done on 8th September 2016, found by static code
analysis.
Post a reply to this message


 
 




 
 


Le 20/10/2016 à 20:02, Le_Forgeron a écrit :
> Le 20/10/2016 à 09:39, robfi680 a écrit :
>> I was just looking at the source code for POVRay 3.7 for solving polynomials. In
>> the default case for Solve_Polynomial it looks to me like it solves the
>> polynomial twice for orders higher than four when a root is eliminated. I am
>> trying to understand the code for my own use. Could there be a break statement
>> missing ? Otherwise why does it solve for order n1 and then n ?
>>
>> The code looks like:
>> default:
>>
>> if (epsilon > 0.0)
>> {
>> if ((c[n1] != 0.0) && (fabs(c[n]/c[n1]) < epsilon))
>> {
>> Thread>Stats()[Roots_Eliminated]++;
>>
>> roots = polysolve(n1, c, r);
>> }
>> }
>>
>> /* Solve nth order polynomial. */
>>
>> roots = polysolve(n, c, r);
>>
>> break;
>>
>>
>>
>
> The interesting part is that master branch is already corrected : yes, a
> break is/was missing.
>
> Now, it only occurs for 5th and more order polynomial, something that is
> rarely seen.
>
> The correction was done on 8th September 2016, found by static code
> analysis.
>
On second look, I'm not even sure the break is at the right place...
Christoph ?
if (epsilon > 0.0)
{
if ((c[n1] != 0.0) && (fabs(c[n]/c[n1]) < epsilon))
{
stats[Roots_Eliminated]++;
roots = polysolve(n1, c, r);
}
break;
}
/* Solve nth order polynomial. */
roots = polysolve(n, c, r);
break;
Post a reply to this message


 
 




 
 


Am 20.10.2016 um 20:13 schrieb Le_Forgeron:
> On second look, I'm not even sure the break is at the right place...
> Christoph ?
Dang. I think it indeed isn't.
Post a reply to this message


 
 




 
 


Le_Forgeron <jgr### [at] freefr> wrote:
> Now, it only occurs for 5th and more order polynomial, something that is
> rarely seen.
I've used 8th order in the past, and there's a significant chance that I will
again in the future.
Post a reply to this message


 
 




 

