mirror of
https://github.com/aportelli/LatAnalyze.git
synced 2025-06-19 07:47:05 +01:00
GSL integrator added - LatAnalyze now depends on GSL
This commit is contained in:
@ -17,6 +17,7 @@ endif
|
||||
noinst_PROGRAMS = \
|
||||
exCompiledDoubleFunction\
|
||||
exFit \
|
||||
exIntegrator \
|
||||
exMat \
|
||||
exMathInterpreter \
|
||||
exMin \
|
||||
@ -31,6 +32,10 @@ exFit_SOURCES = exFit.cpp
|
||||
exFit_CFLAGS = -g -O2
|
||||
exFit_LDFLAGS = -L../lib/.libs -lLatAnalyze
|
||||
|
||||
exIntegrator_SOURCES = exIntegrator.cpp
|
||||
exIntegrator_CFLAGS = -g -O2
|
||||
exIntegrator_LDFLAGS = -L../lib/.libs -lLatAnalyze
|
||||
|
||||
exMat_SOURCES = exMat.cpp
|
||||
exMat_CFLAGS = -g -O2
|
||||
exMat_LDFLAGS = -L../lib/.libs -lLatAnalyze
|
||||
|
32
examples/exIntegrator.cpp
Normal file
32
examples/exIntegrator.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
#include <iostream>
|
||||
#include <LatAnalyze/CompiledFunction.hpp>
|
||||
#include <LatAnalyze/GslQagsIntegrator.hpp>
|
||||
|
||||
using namespace std;
|
||||
using namespace Latan;
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
string source;
|
||||
double xMin, xMax;
|
||||
|
||||
if (argc != 4)
|
||||
{
|
||||
cerr << "usage: " << argv[0] << " <function> <xMin> <xMax>" << endl;
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
source = argv[1];
|
||||
xMin = strTo<double>(argv[2]);
|
||||
xMax = strTo<double>(argv[3]);
|
||||
|
||||
CompiledDoubleFunction f(1, source);
|
||||
GslQagsIntegrator integrator;
|
||||
double result;
|
||||
|
||||
result = integrator(f, xMin, xMax);
|
||||
cout << "function integral on [" << xMin << ", " << xMax << "] = ";
|
||||
cout << result << " +/- " << integrator.getLastError() <<endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
Reference in New Issue
Block a user