/* SOIntegral.h -- integration of functions on the root cell */ /* Last edited on 2003-05-07 16:31:25 by ra014852 */ #ifndef SOIntegral_H #define SOIntegral_H #include #include #include /* INTEGRANDS */ typedef void SOIntegral_Func(double *x, double *fx); /* A generic function to be integrated: given {x[0..m-1]}, computes {fx[0..n-1] = f(x)}. We assume that the function itself knows the dimension {m} of {x} and the dimension {n} of {fx}. */ /* SIMPLE INTEGRALS */ /* These procedures accumulate their result on the argument {sum[0..n-1]}, and in the correction term {corr[0..n-1]}, using Kahan's summation formula. The client must initialize both {sum} and {corr} with 0. */ extern int SOIntegral_GaussOrder; /* Number of knots to be used by {SOIntegral_Gauss} below, along each coordinate axis. */ extern double SOIntegral_MaxSize; /* Maximum size of an integral area size, considering that in general integrals are used to calculate dot products over the root cell, that measures 1 along each side. */ void SOIntegral_Gauss ( SOIntegral_Func f, SOGrid_Dim d, /* Dimension {m} of domain. */ SOGrid_Dim fd, /* Dimension {n} of the function's range. */ double *sum, double *corr ); /* Computes the integral of {f(x)} over the {d}-dimensional box with corners {(0,..)} and {(1,..)}, using Gaussian quadrature on a sample grid with {SOIntegral_GaussOrder} knots along each axis. Accumulates the integral in {sum[0..fd-1]} and {corr[0..fd-1]}. */ void SOIntegral_Gauss_Limits ( SOIntegral_Func f, SOGrid_Dim d, SOGrid_Dim fd, double *sum, double *corr, double *min, /* Lower coordinates of integration limits. */ double *max, /* Higher coordinates of integration limits. */ bool verbose ); void SOIntegral_OnRootCell ( SOIntegral_Func f, SOGrid_Dim d, /* Dimension {m} of domain. */ SOGrid_Dim fd, /* Dimension {n} of the function's range. */ SOGrid_Tree *tree, /* Finite cell grid to use. */ double *sum, double *corr ); /* Computes the integral of {f(x)} over the {d}-dimensional box with corners {(0,..)} and {(1,..)}, using {SOIntegral_Gauss} in each cell of the given {tree}. Accumulates the integral in {sum[0..fd-1]} and {corr[0..fd-1]}. */ #endif