Skip to content

Commit

Permalink
Added missing support for evaluating functions with variable number o…
Browse files Browse the repository at this point in the history
…f parameters.
  • Loading branch information
SteveMaas1978 committed Aug 22, 2024
1 parent 39b9216 commit f2b0d61
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions FECore/MItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ class MFuncND : public MNary
MFuncND(FUNCNPTR pf, const std::string& s, const MSequence& l) : MNary(l, MFND), m_name(s), m_pf(pf) {}
MItem* copy() const override;
const std::string& Name() const { return m_name; }
FUNCNPTR funcptr() const { return m_pf; }

protected:
std::string m_name;
Expand Down
12 changes: 11 additions & 1 deletion FECore/MathObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,17 @@ double MSimpleExpression::value(const MItem* pi) const
case MSFNC:
{
return value(msfncnd(pi)->Value());
};
};
break;
case MFND:
{
const MFuncND* f = mfncnd(pi);
int n = f->Params();
vector<double> d(n, 0.0);
for (int i = 0; i < n; ++i) d[i] = value(f->Param(i));
return (f->funcptr())(d.data(), n);
}
break;
default:
assert(false);
return 0;
Expand Down

0 comments on commit f2b0d61

Please sign in to comment.