70 std::map<std::string, T>
const& variable_values,
79 for (
auto const& named_value : variable_values)
82 for (
auto const& v : vars)
83 if (v->name() == named_value.first) { appears =
true;
break; }
85 throw std::runtime_error(
"value supplied for '" + named_value.first +
86 "', which is not a variable of the expression being evaluated");
90 Vec<T> point(
static_cast<Eigen::Index
>(vars.size()));
91 for (
size_t i = 0; i < vars.size(); ++i)
93 auto it = variable_values.find(vars[i]->name());
94 if (it == variable_values.end())
95 throw std::runtime_error(
"no value supplied for variable '" + vars[i]->name() +
96 "' when evaluating an expression");
97 point(
static_cast<Eigen::Index
>(i)) = it->second;
105 auto cached = std::static_pointer_cast<const StraightLineProgram>(expr->EvalProgram());
111 cached = std::make_shared<const StraightLineProgram>(sys);
112 expr->SetEvalProgram(cached);
119 if constexpr (!std::is_same<T, complex_dbl>::value)
124 return slp.template GetFuncVals<T>()(0);
An implementation of straight-line programs, implemented with strong inspiration from Bertini1's impl...
Definition straight_line_program.hpp:587
unsigned precision() const
Get the current precision of the SLP.
Definition straight_line_program.hpp:811
void Eval(Eigen::MatrixBase< Derived > const &variable_values) const
Evaluate the program at the given variable values (no path variable).
Definition straight_line_program.hpp:607
The fundamental polynomial system class for Bertini2.
Definition system.hpp:106
void AddFunction(Nd const &F)
Add a function to the system, as a bare expression.
void AddVariableGroup(VariableGroup const &v)
Add a variable group to the system.
Free functions for discovering the variables appearing in a function tree.
VariableGroup GatherVariables(std::shared_ptr< const Node > const &n)
Collect the distinct Variables appearing in a function-tree subtree.
Definition algorithm_builder.hpp:36
Eigen::Matrix< NumT, Eigen::Dynamic, 1 > Vec
A dynamically-sized column vector of NumT.
Definition eigen_extensions.hpp:296
T EvalExpression(std::shared_ptr< node::Node > const &expr, std::map< std::string, T > const &variable_values, bool strict=true)
Evaluate an expression tree at a point supplied as a variable-name -> value map.
Definition eval_expression.hpp:69
unsigned Precision(Eigen::MatrixBase< Derived > const &v)
Get the precision of an Eigen object.
Definition eigen_extensions.hpp:339
Provides the bertini::System class.