From 873ea0f0df31e7b3a1a4839af448e8195048cf12 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Mon, 18 Dec 2017 12:02:47 -0800 Subject: [PATCH] [muparser] Remove OnDetectVar and Diff These are unused and useless. --- muparser-2.2.5/include/muParser.h | 3 -- muparser-2.2.5/include/muParserBase.h | 2 - muparser-2.2.5/src/muParser.cpp | 61 ---------------------- muparser-2.2.5/src/muParserBase.cpp | 3 -- muparser-2.2.5/src/muParserTokenReader.cpp | 2 - 5 files changed, 71 deletions(-) diff --git a/muparser-2.2.5/include/muParser.h b/muparser-2.2.5/include/muParser.h index af2ce2ca9..a4a6135f7 100644 --- a/muparser-2.2.5/include/muParser.h +++ b/muparser-2.2.5/include/muParser.h @@ -54,9 +54,6 @@ namespace mu { virtual void InitFun(); virtual void InitConst(); virtual void InitOprt(); - virtual void OnDetectVar(string_type *pExpr, int &nStart, int &nEnd); - - ValueOrError Diff(value_type *a_Var, value_type a_fPos, value_type a_fEpsilon = 0) const; protected: // Trigonometric functions diff --git a/muparser-2.2.5/include/muParserBase.h b/muparser-2.2.5/include/muParserBase.h index b65d92a83..31cde1abc 100644 --- a/muparser-2.2.5/include/muParserBase.h +++ b/muparser-2.2.5/include/muParserBase.h @@ -155,8 +155,6 @@ class ParserBase { virtual void InitConst() = 0; virtual void InitOprt() = 0; - virtual void OnDetectVar(string_type *pExpr, int &nStart, int &nEnd); - static const char_type *c_DefaultOprt[]; static std::locale s_locale; ///< The locale used by the parser static bool g_DbgDumpCmdCode; diff --git a/muparser-2.2.5/src/muParser.cpp b/muparser-2.2.5/src/muParser.cpp index 3f74324f7..b0b845e3f 100644 --- a/muparser-2.2.5/src/muParser.cpp +++ b/muparser-2.2.5/src/muParser.cpp @@ -302,65 +302,4 @@ void Parser::InitOprt() { assertNoError(DefineInfixOprt(_T("+"), UnaryPlus)); } -//--------------------------------------------------------------------------- -void Parser::OnDetectVar(string_type * /*pExpr*/, int & /*nStart*/, int & /*nEnd*/) { - // this is just sample code to illustrate modifying variable names on the fly. - // I'm not sure anyone really needs such a feature... - /* - - - string sVar(pExpr->begin()+nStart, pExpr->begin()+nEnd); - string sRepl = std::string("_") + sVar + "_"; - - int nOrigVarEnd = nEnd; - cout << "variable detected!\n"; - cout << " Expr: " << *pExpr << "\n"; - cout << " Start: " << nStart << "\n"; - cout << " End: " << nEnd << "\n"; - cout << " Var: \"" << sVar << "\"\n"; - cout << " Repl: \"" << sRepl << "\"\n"; - nEnd = nStart + sRepl.length(); - cout << " End: " << nEnd << "\n"; - pExpr->replace(pExpr->begin()+nStart, pExpr->begin()+nOrigVarEnd, sRepl); - cout << " New expr: " << *pExpr << "\n"; - */ -} - -//--------------------------------------------------------------------------- -/** \brief Numerically differentiate with regard to a variable. - \param [in] a_Var Pointer to the differentiation variable. - \param [in] a_fPos Position at which the differentiation should take place. - \param [in] a_fEpsilon Epsilon used for the numerical differentiation. - - Numerical differentiation uses a 5 point operator yielding a 4th order - formula. The default value for epsilon is 0.00074 which is - numeric_limits::epsilon() ^ (1/5) as suggested in the muparser - forum: - - http://sourceforge.net/forum/forum.php?thread_id=1994611&forum_id=462843 -*/ -ValueOrError Parser::Diff(value_type *a_Var, value_type a_fPos, value_type a_fEpsilon) const { - value_type fRes(0), fBuf(*a_Var), fEpsilon(a_fEpsilon); - ValueOrError f[4] = {0, 0, 0, 0}; - - // Backwards compatible calculation of epsilon in case the user doesn't provide - // his own epsilon - if (fEpsilon == 0) fEpsilon = (a_fPos == 0) ? (value_type)1e-10 : (value_type)1e-7 * a_fPos; - - *a_Var = a_fPos + 2 * fEpsilon; - f[0] = Eval(); - *a_Var = a_fPos + 1 * fEpsilon; - f[1] = Eval(); - *a_Var = a_fPos - 1 * fEpsilon; - f[2] = Eval(); - *a_Var = a_fPos - 2 * fEpsilon; - f[3] = Eval(); - *a_Var = fBuf; // restore variable - - for (ValueOrError &v : f) { - if (!v) return std::move(v); - } - fRes = (-*f[0] + 8 * *f[1] - 8 * *f[2] + *f[3]) / (12 * fEpsilon); - return fRes; -} } // namespace mu diff --git a/muparser-2.2.5/src/muParserBase.cpp b/muparser-2.2.5/src/muParserBase.cpp index 6d02c6f3c..69857e9d9 100644 --- a/muparser-2.2.5/src/muParserBase.cpp +++ b/muparser-2.2.5/src/muParserBase.cpp @@ -116,9 +116,6 @@ void ParserBase::ReInit() const { m_pTokenReader->ReInit(); } -//--------------------------------------------------------------------------- -void ParserBase::OnDetectVar(string_type * /*pExpr*/, int & /*nStart*/, int & /*nEnd*/) {} - //--------------------------------------------------------------------------- /** \brief Add a value parsing function. diff --git a/muparser-2.2.5/src/muParserTokenReader.cpp b/muparser-2.2.5/src/muParserTokenReader.cpp index 2dff4aed2..13090e5fc 100644 --- a/muparser-2.2.5/src/muParserTokenReader.cpp +++ b/muparser-2.2.5/src/muParserTokenReader.cpp @@ -615,8 +615,6 @@ bool ParserTokenReader::IsVarTok(token_type &a_Tok) { if (m_iSynFlags & noVAR) return Error(ecUNEXPECTED_VAR, m_iPos, strTok); - m_pParser->OnDetectVar(&m_strFormula, m_iPos, iEnd); - m_iPos = iEnd; a_Tok.SetVar(item->second, strTok); m_UsedVar[item->first] = item->second; // Add variable to used-var-list