Skip to content
Snippets Groups Projects
Commit cf96ad06 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Add missing virtual destructor to ICFunctionEmbedder

Also check that given arguments list has the same size than the  C-function
arguments and revert to sin function for testing purpose
parent 4e45948f
No related branches found
No related tags found
1 merge request!37Feature/language
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
struct ICFunctionEmbedder struct ICFunctionEmbedder
{ {
virtual void apply(const std::vector<ASTNodeDataVariant>& x, double& f_x) = 0; virtual void apply(const std::vector<ASTNodeDataVariant>& x, double& f_x) = 0;
virtual ~ICFunctionEmbedder() = default;
}; };
template <typename FX, typename... Args> template <typename FX, typename... Args>
...@@ -41,6 +43,7 @@ class CFunctionEmbedder : public ICFunctionEmbedder ...@@ -41,6 +43,7 @@ class CFunctionEmbedder : public ICFunctionEmbedder
PUGS_INLINE void PUGS_INLINE void
_copy_from_vector(ArgsTuple& t, const std::vector<ASTNodeDataVariant>& v, std::index_sequence<I...>) const _copy_from_vector(ArgsTuple& t, const std::vector<ASTNodeDataVariant>& v, std::index_sequence<I...>) const
{ {
Assert(sizeof...(Args) == v.size());
(_copy_value<I>(t, v), ...); (_copy_value<I>(t, v), ...);
} }
......
...@@ -58,8 +58,8 @@ class CFunctionExpressionProcessor final : public INodeProcessor ...@@ -58,8 +58,8 @@ class CFunctionExpressionProcessor final : public INodeProcessor
CFunctionExpressionProcessor(ASTNode& node, std::vector<ASTNodeDataVariant>& argument_values) CFunctionExpressionProcessor(ASTNode& node, std::vector<ASTNodeDataVariant>& argument_values)
: m_node{node}, m_argument_values{argument_values} : m_node{node}, m_argument_values{argument_values}
{ {
m_embedded_function = std::make_unique<CFunctionEmbedder<double, double, double>>( m_embedded_function = std::make_unique<CFunctionEmbedder<double, double>>(
std::function{[](double x, double y) -> double { return std::sin(x) * std::cos(3 * x) + y; }}); std::function{[](double x) -> double { return std::sin(x); }});
} }
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment