From 6caf8c6c59b0bf25a8154711c6db7817470b4f6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org> Date: Fri, 7 Apr 2023 15:12:47 +0200 Subject: [PATCH] use_dll: simplify definition of getPowerDeriv() function using C99 --- src/DataTree.cc | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/DataTree.cc b/src/DataTree.cc index 96f16214..074d31a1 100644 --- a/src/DataTree.cc +++ b/src/DataTree.cc @@ -893,18 +893,15 @@ void DataTree::writeCHelpersDefinition(ostream &output) const { if (isBinaryOpUsed(BinaryOpcode::powerDeriv)) - output << "/*" << endl - << " * The k-th derivative of x^p" << endl - << " */" << endl + output << "// The k-th derivative of x^p" << endl << "double getPowerDeriv(double x, double p, int k)" << endl << "{" << endl << " if (fabs(x) < " << power_deriv_near_zero << " && p > 0 && k > p && fabs(p-nearbyint(p)) < " << power_deriv_near_zero << ')' << endl << " return 0.0;" << endl << " else" << endl << " {" << endl - << " int i = 0;" << endl << " double dxp = pow(x, p-k);" << endl - << " for (; i<k; i++)" << endl + << " for (int i = 0; i<k; i++)" << endl << " dxp *= p--;" << endl << " return dxp;" << endl << " }" << endl -- GitLab