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

dg : add functionConstantByTag

parent e2def8ec
Branches
Tags
No related merge requests found
...@@ -50,14 +50,14 @@ functionConstant *function::_dtFunction = NULL; ...@@ -50,14 +50,14 @@ functionConstant *function::_dtFunction = NULL;
functionConstant *function::getTime() functionConstant *function::getTime()
{ {
if (! _timeFunction) if (! _timeFunction)
_timeFunction = functionConstantNew(0.); _timeFunction = new functionConstant(0.);
return _timeFunction; return _timeFunction;
} }
functionConstant *function::getDT() functionConstant *function::getDT()
{ {
if (! _dtFunction) if (! _dtFunction)
_dtFunction = functionConstantNew(0.); _dtFunction = new functionConstant(0.);
return _dtFunction; return _dtFunction;
} }
...@@ -367,16 +367,24 @@ void functionConstant::set(double val) ...@@ -367,16 +367,24 @@ void functionConstant::set(double val)
_source(0,0) = val; _source(0,0) = val;
} }
functionConstant *functionConstantNew(double v) void functionConstant::call(dataCacheMap *m, fullMatrix<double> &val)
{ {
std::vector<double> vec(1); for (int i=0; i<val.size1(); i++)
vec[0]=v; for (int j=0; j<_source.size1(); j++)
return new functionConstant(vec); val(i,j)=_source(j,0);
} }
functionConstant *functionConstantNew(const std::vector<double> &v) functionConstant::functionConstant(std::vector<double> source) : function(source.size())
{ {
return new functionConstant(v); _source = fullMatrix<double>(source.size(),1);
for (size_t i=0; i<source.size(); i++)
_source(i,0) = source[i];
}
functionConstant::functionConstant(double source) : function(1)
{
_source.resize(1,1);
_source(0,0) = source;
} }
// functionSum // functionSum
......
...@@ -274,18 +274,9 @@ class dataCacheMap { ...@@ -274,18 +274,9 @@ class dataCacheMap {
class functionConstant : public function { class functionConstant : public function {
public: public:
fullMatrix<double> _source; fullMatrix<double> _source;
void call(dataCacheMap *m, fullMatrix<double> &val) void call(dataCacheMap *m, fullMatrix<double> &val);
{ functionConstant(std::vector<double> source);
for (int i=0; i<val.size1(); i++) functionConstant(double source);
for (int j=0; j<_source.size1(); j++)
val(i,j)=_source(j,0);
}
functionConstant(std::vector<double> source) : function(source.size())
{
_source = fullMatrix<double>(source.size(),1);
for (size_t i=0; i<source.size(); i++)
_source(i,0) = source[i];
}
void set(double val); void set(double val);
}; };
...@@ -300,9 +291,6 @@ class functionC : public function { ...@@ -300,9 +291,6 @@ class functionC : public function {
std::vector<const function *> dependencies); std::vector<const function *> dependencies);
}; };
functionConstant *functionConstantNew(const std::vector<double>&);
functionConstant *functionConstantNew(double);
function *functionSumNew (const function *f0, const function *f1); function *functionSumNew (const function *f0, const function *f1);
function *functionProdNew (const function *f0, const function *f1); function *functionProdNew (const function *f0, const function *f1);
function *functionScaleNew (const function *f0, const double s); function *functionScaleNew (const function *f0, const double s);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment