From bde0120212ce239b3b524f5bf525f5919dcdcfe5 Mon Sep 17 00:00:00 2001 From: Miguel Marco Date: Tue, 7 Mar 2017 12:09:54 +0100 Subject: [PATCH] Treat degree 1 polynomials as a separate case for derivative evaluation. --- include/polynomial.hpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/polynomial.hpp b/include/polynomial.hpp index 5d8194f..88d1299 100644 --- a/include/polynomial.hpp +++ b/include/polynomial.hpp @@ -239,6 +239,12 @@ T Polynomial::diffX (const T &x, const T &y) const { // sets output to 0+0i T rop; + + if (this->degree == 1){ + + rop = (this->coef)[1]; + return rop; + } // compute all powers of x and y // (from 0 to degree-1) (from 0 to degree) resp @@ -271,6 +277,12 @@ T Polynomial::evalPolYClassic (const T &x, const T &y) const { // sets output to 0+0i T rop; + + if (this->degree == 1){ + rop = (this->coef)[2]; + return rop; + + } // compute all powers of x and y // (from 0 to degree) (from 0 to degree-1) resp