When looking at the example:
Code:
#include "stdafx.h"
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "integration.h"
using namespace alglib;
void int_function_1_func(double x, double xminusa, double bminusx, double &y, void *ptr)
{
// this callback calculates f(x)=exp(x)
y = exp(x);
}
int main(int argc, char **argv)
{
//
// This example demonstrates integration of f=exp(x) on [0,1]:
// * first, autogkstate is initialized
// * then we call integration function
// * and finally we obtain results with autogkresults() call
//
double a = 0;
double b = 1;
autogkstate s;
double v;
autogkreport rep;
autogksmooth(a, b, s);
alglib::autogkintegrate(s, int_function_1_func);
autogkresults(s, v, rep);
printf("%.2f\n", double(v)); // EXPECTED: 1.7182
return 0;
}
I know I can look up the varibles and especially methods in the cpp file, but perhaps someone can briefly tell me what I need to know.
May questions:
1.
Code:
int_function_1_func(double x, double xminusa, double bminusx, double &y, void *ptr)
Function "int_function_1_func(double x, double xminusa, double bminusx, double &y, void *ptr)" should get 5 input parameters -> where are they passed? and what is "xminusa" and "bminusx" for?
2.
Code:
autogksmooth(a, b, s);
What does this method do? Furthermore, what is autogkstate s for?
3.
Code:
alglib::autogkintegrate(s, int_function_1_func);
I guess here the integration takes place. Again: what is autogkstate s for?
4.
Code:
autogkresults(s, v, rep);
I guess here the results of the integration are returned, right? What is returned exactly? Is "v" the total result and is "rep" a total "report" about the integration?
Generally I just want to integrate a function over known integration limits and get the total result, e.g. as a double. Furthermore I need to pass one parameter/variable into the function at runtime - lets imagine a function like
Code:
y= exp(x + passed)
where passed is a variable/object that is passed at runtime.
I hope someone enlightens me here a little.
greetings
TerraG