Skip to content

Commit

Permalink
Function: revert evaluate(const std::map&)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcrada committed Mar 8, 2024
1 parent dbcf314 commit 2c5a788
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
4 changes: 1 addition & 3 deletions fuzzylite/term/Function.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,7 @@ namespace fuzzylite {
@return a fl::scalar indicating the result of the evaluation of
the node
*/
virtual scalar
evaluate(const std::map<std::string, scalar>& variables = std::map<std::string, scalar>()) const;
virtual scalar evaluate(const std::map<std::string, scalar>* variables) const;
virtual scalar evaluate(const std::map<std::string, scalar>* variables = fl::null) const;

/**
Computes the size of the subtree under the given node. The complexity
Expand Down
7 changes: 2 additions & 5 deletions src/term/Function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,6 @@ namespace fuzzylite {
return ss.str();
}

scalar Function::Node::evaluate(const std::map<std::string, scalar>& variables) const {
return evaluate(&variables);
}

scalar Function::Node::evaluate(const std::map<std::string, scalar>* variables) const {
scalar result = fl::nan;
if (element.get()) {
Expand Down Expand Up @@ -403,7 +399,8 @@ namespace fuzzylite {
if (not _root.get())
throw Exception("[function error] function <" + _formula + "> not loaded.", FL_AT);
if (localVariables)
return _root->evaluate(localVariables);
for (auto it = localVariables->begin(); it != localVariables->end(); ++it)
variables[it->first] = it->second;
return _root->evaluate(&this->variables);
}

Expand Down

0 comments on commit 2c5a788

Please sign in to comment.