2.1.17.4.2 ocmath_function_integral


Description

Perform integral on specified function in the given data range. It can be used for improper integral like infinite integral.

Syntax

double ocmath_function_integral( double a, double b, EVALUATFUNC func, LPVOID pPara, double precision = 10e-8 )

Parameters

a
[input] lower limit of the integral
b
[input] upper limit of the integral
func
[input] pointer to the function to be integrated
pPara
[input] pointer to the parameters list of the function
precision
[input] the precision of the integral, default is 1e-8

Return

Return the integral value

Examples

EX1

double sin_a(double x, LPVOID pa)
{
    return sin(*(double*)pa*x);
}
void ocmath_function_integral_ex1()
{
    double a = PI;
    double dd = ocmath_function_integral(0, 1, sin_a, (LPVOID)&a);
    printf ("%lf\n", dd);
}

Remark

See Also

Header to Include

origin.h

Reference