1
0
mirror of https://github.com/aportelli/LatAnalyze.git synced 2025-08-01 14:17:05 +01:00

first root finder class implementation

This commit is contained in:
2014-09-22 15:19:30 +01:00
parent 8188a5541f
commit 4d19c23400
12 changed files with 499 additions and 76 deletions

View File

@@ -22,7 +22,8 @@ noinst_PROGRAMS = \
exMathInterpreter \
exMin \
exPlot \
exRand
exRand \
exRootFinder
exCompiledDoubleFunction_SOURCES = exCompiledDoubleFunction.cpp
exCompiledDoubleFunction_CFLAGS = -g -O2
@@ -56,4 +57,8 @@ exRand_SOURCES = exRand.cpp
exRand_CFLAGS = -g -O2
exRand_LDFLAGS = -L../lib/.libs -lLatAnalyze
exRootFinder_SOURCES = exRootFinder.cpp
exRootFinder_CFLAGS = -g -O2
exRootFinder_LDFLAGS = -L../lib/.libs -lLatAnalyze
ACLOCAL_AMFLAGS = -I .buildutils/m4

24
examples/exRootFinder.cpp Normal file
View File

@@ -0,0 +1,24 @@
#include <iostream>
#include <LatAnalyze/Function.hpp>
#include <LatAnalyze/GslHybridRootFinder.hpp>
using namespace std;
using namespace Latan;
int main(void)
{
constexpr double a = 1., b = 10.;
DoubleFunction f1(2, [a](const double *x){return a*(1.-x[0]);});
DoubleFunction f2(2, [b](const double *x){return b*(x[1]-x[0]*x[0]);});
vector<DoubleFunction *> system = {&f1, &f2};
GslHybridRootFinder solve;
DVec init(2), x;
solve.setVerbosity(Solver::Verbosity::Debug);
init(0) = -10.; init(1) = -5.;
solve.setInit(init);
x = solve(system);
cout << "solution: " << x.transpose() << endl;
return 0;
}