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

dg : add functionConstantByTag

parent e2def8ec
No related branches found
No related tags found
No related merge requests found
......@@ -50,14 +50,14 @@ functionConstant *function::_dtFunction = NULL;
functionConstant *function::getTime()
{
if (! _timeFunction)
_timeFunction = functionConstantNew(0.);
_timeFunction = new functionConstant(0.);
return _timeFunction;
}
functionConstant *function::getDT()
{
if (! _dtFunction)
_dtFunction = functionConstantNew(0.);
_dtFunction = new functionConstant(0.);
return _dtFunction;
}
......@@ -367,16 +367,24 @@ void functionConstant::set(double val)
_source(0,0) = val;
}
functionConstant *functionConstantNew(double v)
void functionConstant::call(dataCacheMap *m, fullMatrix<double> &val)
{
std::vector<double> vec(1);
vec[0]=v;
return new functionConstant(vec);
for (int i=0; i<val.size1(); i++)
for (int j=0; j<_source.size1(); j++)
val(i,j)=_source(j,0);
}
functionConstant::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];
}
functionConstant *functionConstantNew(const std::vector<double> &v)
functionConstant::functionConstant(double source) : function(1)
{
return new functionConstant(v);
_source.resize(1,1);
_source(0,0) = source;
}
// functionSum
......
......@@ -274,18 +274,9 @@ class dataCacheMap {
class functionConstant : public function {
public:
fullMatrix<double> _source;
void call(dataCacheMap *m, fullMatrix<double> &val)
{
for (int i=0; i<val.size1(); i++)
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 call(dataCacheMap *m, fullMatrix<double> &val);
functionConstant(std::vector<double> source);
functionConstant(double source);
void set(double val);
};
......@@ -300,9 +291,6 @@ class functionC : public function {
std::vector<const function *> dependencies);
};
functionConstant *functionConstantNew(const std::vector<double>&);
functionConstant *functionConstantNew(double);
function *functionSumNew (const function *f0, const function *f1);
function *functionProdNew (const function *f0, const function *f1);
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