From e2def8ec3a671c156160201540f9a6e95670fee0 Mon Sep 17 00:00:00 2001 From: Jonathan Lambrechts <jonathan.lambrechts@uclouvain.be> Date: Wed, 8 Dec 2010 15:39:11 +0000 Subject: [PATCH] dg : one less bug ... --- Solver/function.cpp | 11 ++++++++--- Solver/function.h | 3 +++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Solver/function.cpp b/Solver/function.cpp index 9abe88f1df..ad0b803775 100644 --- a/Solver/function.cpp +++ b/Solver/function.cpp @@ -229,7 +229,7 @@ void dataCacheDouble::_eval() _valid = true; } -dataCacheDouble *dataCacheMap::get(const function *f, dataCacheDouble *caller, bool createIfNotPresent) +const function * dataCacheMap::_translate(const function *f) const { //special case if (f == function::getSolution()) { @@ -257,7 +257,12 @@ dataCacheDouble *dataCacheMap::get(const function *f, dataCacheDouble *caller, b Msg::Error ("solution function gradient has not been set"); } } + return f; +} +dataCacheDouble *dataCacheMap::get(const function *f, dataCacheDouble *caller, bool createIfNotPresent) +{ + f = _translate(f); // do I have a cache for this function ? dataCacheDouble *&r = _cacheDoubleMap[f]; // can I use the cache of my parent ? @@ -297,8 +302,8 @@ dataCacheDouble *dataCacheMap::get(const function *f, dataCacheDouble *caller, b for (std::vector<function::argument>::iterator it = replace->_toReplace.begin(); it!= replace->_toReplace.end(); it++ ) { dataCacheMap *m = rMap->getSecondaryCache(it->iMap); - dataCacheDouble *s = new dataCacheDouble(m, (function*)it->f); - m->_cacheDoubleMap[it->f] = s; + dataCacheDouble *s = new dataCacheDouble(m, (function*)_translate(it->f)); + m->_cacheDoubleMap[_translate(it->f)] = s; replaceCache.toReplace.push_back(s); } for (std::vector<function::argument>::iterator it = replace->_toCompute.begin(); diff --git a/Solver/function.h b/Solver/function.h index bff835b5e0..f6558a4277 100644 --- a/Solver/function.h +++ b/Solver/function.h @@ -202,6 +202,9 @@ class dataCacheDouble { class dataCacheMap { const function *_functionSolution, *_functionSolutionGradient; + //handle function solution and funciton solution gradient + //we should get rid of them + const function * _translate (const function *) const; public: dataCacheMap *_parent; std::list<dataCacheMap*> _children; -- GitLab