summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2010-11-01 22:19:57 -0400
committerTavian Barnes <tavianator@gmail.com>2010-11-01 22:19:57 -0400
commit2c7cb763dcb69e3c0464298e41e30cdc2b0f1cfb (patch)
tree37cfe9611259c5d14fd07d7bf3a2491addd16c27
parent9660ace0d566aea48656678dcc26d2af60f3bf49 (diff)
downloaddimension-2c7cb763dcb69e3c0464298e41e30cdc2b0f1cfb.tar.xz
Small polynomial.c cleanup.
-rw-r--r--libdimension/polynomial.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/libdimension/polynomial.c b/libdimension/polynomial.c
index c960c6f..af8d5df 100644
--- a/libdimension/polynomial.c
+++ b/libdimension/polynomial.c
@@ -248,8 +248,9 @@ dmnsn_bisect_root(const double poly[], size_t degree, double min, double max)
static inline void
dmnsn_eliminate_root(double poly[], size_t *degree, double r)
{
- double rem = poly[*degree];
- for (ssize_t i = *degree - 1; i >= 0; --i) {
+ size_t deg = *degree;
+ double rem = poly[deg];
+ for (ssize_t i = deg - 1; i >= 0; --i) {
double temp = poly[i];
poly[i] = rem;
rem = temp + r*rem;
@@ -324,10 +325,13 @@ dmnsn_solve_polynomial(const double poly[], size_t degree, double x[])
}
}
- if (degree == 1) {
+ switch (degree) {
+ case 1:
i += dmnsn_solve_linear(p, x + i);
- } else if (degree == 2) {
+ break;
+ case 2:
i += dmnsn_solve_quadratic(p, x + i);
+ break;
}
return i;