From 2385b7b5c1492fef33bf313cbab47af1b21e15eb Mon Sep 17 00:00:00 2001 From: Houtan Bastani Date: Fri, 14 Oct 2016 14:30:14 +0200 Subject: [PATCH] preprocessor: clean up writePowerDeriv code. it only writes C code, so no need for use_dll argument --- DataTree.cc | 6 +++--- DataTree.hh | 8 ++++---- DynamicModel.cc | 11 ++++------- StaticModel.cc | 2 +- 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/DataTree.cc b/DataTree.cc index 7c718c5e..ba949165 100644 --- a/DataTree.cc +++ b/DataTree.cc @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2015 Dynare Team + * Copyright (C) 2003-2016 Dynare Team * * This file is part of Dynare. * @@ -684,9 +684,9 @@ DataTree::writePowerDerivCHeader(ostream &output) const } void -DataTree::writePowerDeriv(ostream &output, bool use_dll) const +DataTree::writePowerDeriv(ostream &output) const { - if (use_dll && isBinaryOpUsed(oPowerDeriv)) + if (isBinaryOpUsed(oPowerDeriv)) output << "/*" << endl << " * The k-th derivative of x^p" << endl << " */" << endl diff --git a/DataTree.hh b/DataTree.hh index 4c740113..ce908408 100644 --- a/DataTree.hh +++ b/DataTree.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2015 Dynare Team + * Copyright (C) 2003-2016 Dynare Team * * This file is part of Dynare. * @@ -235,10 +235,10 @@ public: //! Returns the minimum lag (as a negative number) of the given symbol in the whole data tree (and not only in the equations !!) /*! Returns 0 if the symbol is not used */ int minLagForSymbol(int symb_id) const; - //! Write the Header for getPowerDeriv when use_dll is used + //! Write the C Header for getPowerDeriv when use_dll is used void writePowerDerivCHeader(ostream &output) const; - //! Write getPowerDeriv - void writePowerDeriv(ostream &output, bool use_dll) const; + //! Write getPowerDeriv in C + void writePowerDeriv(ostream &output) const; //! Thrown when trying to access an unknown variable by deriv_id class UnknownDerivIDException { diff --git a/DynamicModel.cc b/DynamicModel.cc index cf57bda7..b43583a4 100644 --- a/DynamicModel.cc +++ b/DynamicModel.cc @@ -1624,7 +1624,7 @@ DynamicModel::writeDynamicCFile(const string &dynamic_basename, const int order) // Writing the function body writeDynamicModel(mDynamicModelFile, true, false); - writePowerDeriv(mDynamicModelFile, true); + writePowerDeriv(mDynamicModelFile); mDynamicModelFile.close(); mDynamicMexFile.open(filename_mex.c_str(), ios::out | ios::binary); @@ -4823,7 +4823,7 @@ DynamicModel::writeResidualsC(const string &basename, bool cuda) const << model_output.str() << "}" << endl; - writePowerDeriv(mDynamicModelFile, true); + writePowerDeriv(mDynamicModelFile); mDynamicModelFile.close(); } @@ -4880,8 +4880,6 @@ DynamicModel::writeFirstDerivativesC(const string &basename, bool cuda) const mDynamicModelFile << "}" << endl; - // already written in writeResidualsC() - // writePowerDeriv(mDynamicModelFile, true); mDynamicModelFile.close(); } @@ -4984,7 +4982,6 @@ DynamicModel::writeFirstDerivativesC_csr(const string &basename, bool cuda) cons << "for (i=0; i < " << row_ptr.size() + 1 << "; i++) row_ptr[i] = row_ptr_data[i];" << endl; mDynamicModelFile << "}" << endl; - // writePowerDeriv(mDynamicModelFile, true); mDynamicModelFile.close(); } @@ -5077,7 +5074,7 @@ DynamicModel::writeSecondDerivativesC_csr(const string &basename, bool cuda) con mDynamicModelFile << "}" << endl; - writePowerDeriv(mDynamicModelFile, true); + writePowerDeriv(mDynamicModelFile); mDynamicModelFile.close(); } @@ -5203,7 +5200,7 @@ DynamicModel::writeThirdDerivativesC_csr(const string &basename, bool cuda) cons mDynamicModelFile << "}" << endl; - writePowerDeriv(mDynamicModelFile, true); + writePowerDeriv(mDynamicModelFile); mDynamicModelFile.close(); } diff --git a/StaticModel.cc b/StaticModel.cc index a2af970d..23e5e1f4 100644 --- a/StaticModel.cc +++ b/StaticModel.cc @@ -1616,7 +1616,7 @@ StaticModel::writeStaticCFile(const string &func_name) const writeStaticModel(output, true, false); output << "}" << endl << endl; - writePowerDeriv(output, true); + writePowerDeriv(output); output.close(); output.open(filename_mex.c_str(), ios::out | ios::binary);