A header-only, templated C++ library which allows the automatic solving of function-parameter systems.
This enables you to define and solve any system of equations, linear or not.
cppAutoSolve
is split into FunctionNode
s and ParameterNode
s.
ParameterNode
s define parameters and their names, such as:
ParameterNode<double> x("x");
FunctionNode
s are defined by a lambda expression, which reads parameters from a map and then returns a calculation result.
FunctionNode<double> fn([](std::map<std::string, ParameterNode<double>*> &inputs) {
return 18.0 * inputs["x"]->get();
});
After defining initial values for the ParameterNode
s and properly defining the dependencies, the system can be solved.
x = 7.5; //setting known value
AutoSolveController<double> controller;
controller.add(&fn1, &fn2, &fn3 , &x, &y, &z); //adding different nodes to the system
e = fn(&x); //e is calculated by fn which depends on x
controller.solve();
cppAutoSolve
currently requires that the system is defined at compile time. Also defining the dependencies and functions can be quite cumbersome.
Solver
tries to tackle those problems by interpreting the systems at runtime with basically no syntax overhead.