1
0
mirror of https://github.com/aportelli/LatAnalyze.git synced 2024-09-19 21:25:36 +01:00

function sampling method

This commit is contained in:
Antonin Portelli 2019-03-21 17:40:02 +00:00
parent 61c18b7f2d
commit 3918d3a9b8
2 changed files with 22 additions and 0 deletions

View File

@ -179,6 +179,26 @@ DoubleFunction DoubleFunction::bind(const Index argIndex,
return bindFunc;
}
// sample //////////////////////////////////////////////////////////////////////
DVec DoubleFunction::sample(const DMat &x)
{
if (x.cols() != getNArg())
{
LATAN_ERROR(Size, "sampling point matrix and number of arguments "
"mismatch (matrix has " + strFrom(x.cols())
+ ", number of arguments is " + strFrom(getNArg()) + ")");
}
DVec res(x.rows());
for (Index i = 0; i < res.size(); ++i)
{
res(i) = (*this)(x.row(i));
}
return res;
}
// arithmetic operators ////////////////////////////////////////////////////////
DoubleFunction DoubleFunction::operator-(void) const
{

View File

@ -56,6 +56,8 @@ public:
// bind
DoubleFunction bind(const Index argIndex, const double val) const;
DoubleFunction bind(const Index argIndex, const DVec &x) const;
// sample
DVec sample(const DMat &x);
// arithmetic operators
DoubleFunction operator-(void) const;
DoubleFunction & operator+=(const DoubleFunction &f);