Skip to content

Commit 27ea23c

Browse files
committed
Removing pointless operations in polysolve and Solve_Polynomial.
visible_roots() passed a couple integer pointers which it set prior to return but the values were never used in polysolve itself. When fourth order equations seen a test call to difficult_coeffs() was made which if true would set sturm true - even when sturm was already true.
1 parent a6efa00 commit 27ea23c

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

source/core/math/polynomialsolver.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ static int sbisect (int np, const polynomial *sseq, DBL min, DBL max, int atmin,
140140
static int numchanges (int np, const polynomial *sseq, DBL a);
141141
static DBL polyeval (DBL x, int n, const DBL *Coeffs);
142142
static int buildsturm (int ord, polynomial *sseq);
143-
static int visible_roots (int np, const polynomial *sseq, int *atneg, int *atpos);
143+
static int visible_roots (int np, const polynomial *sseq);
144144
static int difficult_coeffs (int n, const DBL *x);
145145

146146

@@ -318,7 +318,7 @@ static int buildsturm(int ord, polynomial *sseq)
318318
*
319319
******************************************************************************/
320320

321-
static int visible_roots(int np, const polynomial *sseq, int *atzer, int *atpos)
321+
static int visible_roots(int np, const polynomial *sseq)
322322
{
323323
int atposinf, atzero;
324324
const polynomial *s;
@@ -358,9 +358,6 @@ static int visible_roots(int np, const polynomial *sseq, int *atzer, int *atpos
358358
lf = f;
359359
}
360360

361-
*atzer = atzero;
362-
*atpos = atposinf;
363-
364361
return(atzero - atposinf);
365362
}
366363

@@ -1532,7 +1529,7 @@ static int polysolve(int order, const DBL *Coeffs, DBL *roots)
15321529
// going negative when the modp leading coef filter set lower.
15331530
// Similar change to the numchanges based test below.
15341531

1535-
if ((nroots = visible_roots(np, sseq, &atmin, &atmax)) <= 0)
1532+
if ((nroots = visible_roots(np, sseq)) <= 0)
15361533
{
15371534
return(0);
15381535
}
@@ -1753,7 +1750,7 @@ int Solve_Polynomial(int n, const DBL *c0, DBL *r, int sturm, DBL epsilon, Rende
17531750

17541751
/* Test for difficult coeffs. */
17551752

1756-
if (difficult_coeffs(4, c))
1753+
if ((!sturm) && (difficult_coeffs(4, c)))
17571754
{
17581755
sturm = true;
17591756
}

0 commit comments

Comments
 (0)