summaryrefslogtreecommitdiffstats
path: root/libdimension/dimension
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2010-11-10 01:11:22 -0500
committerTavian Barnes <tavianator@gmail.com>2010-11-10 01:11:22 -0500
commit516df38e8acff5d1f7022ae5492f814acea1df3c (patch)
treef5520848197c6e321db91c222ec83c48a5264aed /libdimension/dimension
parent97a9efe5091a5c483f8081d60dccf6029be7ecc4 (diff)
downloaddimension-516df38e8acff5d1f7022ae5492f814acea1df3c.tar.xz
Use Newton's method when the root bound is degenerate.
Diffstat (limited to 'libdimension/dimension')
-rw-r--r--libdimension/dimension/polynomial.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/libdimension/dimension/polynomial.h b/libdimension/dimension/polynomial.h
index e04861f..ffe3014 100644
--- a/libdimension/dimension/polynomial.h
+++ b/libdimension/dimension/polynomial.h
@@ -41,6 +41,18 @@ dmnsn_evaluate_polynomial(const double poly[], size_t degree, double x)
return ret;
}
+DMNSN_INLINE double
+dmnsn_evaluate_polynomial_derivative(const double poly[], size_t degree,
+ double x)
+{
+ double ret = poly[degree]*degree;
+ size_t i;
+ for (i = degree - 1; i >= 1; --i) {
+ ret = ret*x + poly[i]*i;
+ }
+ return ret;
+}
+
/* Stores the positive roots of poly[] in x[], and returns the number of such
roots that were stored */
size_t dmnsn_solve_polynomial(const double poly[], size_t degree, double x[]);