Skip to content
Snippets Groups Projects
Commit 260d0871 authored by Jonathan Lambrechts's avatar Jonathan Lambrechts
Browse files

function : do not invalidate constant function on setElement

parent a2739f4c
Branches
Tags
No related merge requests found
...@@ -325,17 +325,19 @@ dataCacheMap::~dataCacheMap() ...@@ -325,17 +325,19 @@ dataCacheMap::~dataCacheMap()
void dataCacheMap::setNbEvaluationPoints(int nbEvaluationPoints) void dataCacheMap::setNbEvaluationPoints(int nbEvaluationPoints)
{ {
if (_nbEvaluationPoints == nbEvaluationPoints) for(std::list<dataCacheMap*>::iterator it = _children.begin(); it != _children.end(); it++) {
(*it)->setNbEvaluationPoints(nbEvaluationPoints);
}
if (_nbEvaluationPoints == nbEvaluationPoints) {
for(std::set<dataCacheDouble*>::iterator it = _allDataCaches.begin(); it != _allDataCaches.end(); it++)
(*it)->_valid = false;
return; return;
}
_nbEvaluationPoints = nbEvaluationPoints; _nbEvaluationPoints = nbEvaluationPoints;
for(std::set<dataCacheDouble*>::iterator it = _allDataCaches.begin(); for(std::set<dataCacheDouble*>::iterator it = _allDataCaches.begin();
it != _allDataCaches.end(); it++){ it != _allDataCaches.end(); it++){
(*it)->resize(nbEvaluationPoints); (*it)->resize(nbEvaluationPoints);
} }
for(std::list<dataCacheMap*>::iterator it = _children.begin();
it != _children.end(); it++) {
(*it)->setNbEvaluationPoints(nbEvaluationPoints);
}
} }
// Some examples of functions // Some examples of functions
...@@ -356,14 +358,14 @@ void functionConstant::call(dataCacheMap *m, fullMatrix<double> &val) ...@@ -356,14 +358,14 @@ void functionConstant::call(dataCacheMap *m, fullMatrix<double> &val)
val(i, j)=_source(j, 0); val(i, j)=_source(j, 0);
} }
functionConstant::functionConstant(std::vector<double> source) : function(source.size()) functionConstant::functionConstant(std::vector<double> source) : function(source.size(), false)
{ {
_source = fullMatrix<double>(source.size(), 1); _source = fullMatrix<double>(source.size(), 1);
for (size_t i = 0; i < source.size(); i++) for (size_t i = 0; i < source.size(); i++)
_source(i, 0) = source[i]; _source(i, 0) = source[i];
} }
functionConstant::functionConstant(double source) : function(1) functionConstant::functionConstant(double source) : function(1, false)
{ {
_source.resize(1, 1); _source.resize(1, 1);
_source(0, 0) = source; _source(0, 0) = source;
......
...@@ -164,6 +164,7 @@ class dataCacheDouble { ...@@ -164,6 +164,7 @@ class dataCacheDouble {
void _eval(); void _eval();
void resize(int nrow); void resize(int nrow);
public: public:
inline function * getFunction() {return _function;}
//set the value (without computing it by _eval) and invalidate the //set the value (without computing it by _eval) and invalidate the
// dependencies this function is needed to be able to pass the // dependencies this function is needed to be able to pass the
// _value to functions like gemm or mult but you cannot keep the // _value to functions like gemm or mult but you cannot keep the
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment