#include "geoslib_old_f.h"
#include "geoslib_define.h"
#include "Matrix/MatrixRectangular.hpp"
#include "Basic/MathFunc.hpp"
#include "Basic/Law.hpp"
#include "Basic/WarningMacro.hpp"
#include "Basic/VectorHelper.hpp"
#include <math.h>
#include <boost/math/special_functions/legendre.hpp>
#include <boost/math/special_functions/spherical_harmonic.hpp>
#include <Geometry/GeometryHelper.hpp>
Classes | |
struct | Reg_Coor |
Macros | |
#define | COORD(i, ip) (coord[3 * (ip) + (i)]) |
#define | RCOORD(i, ip) (R_coor->coor[3 * (ip) + (i)]) |
#define | w ((double *)&equiv_99) |
#define | x ((double *)&equiv_100) |
#define | X 0.525731112119133696 |
#define | Z 0.850650808352039932 |
Functions | |
void | mvndst (int n, double *lower, double *upper, int *infin, double *correl, int maxpts, double abseps, double releps, double *error, double *value, int *inform) |
void | mvndst4 (double *lower, double *upper, double *correl, int maxpts, double abseps, double releps, double *error, double *value, int *inform) |
void | mvndst2n (double *lower, double *upper, double *means, double *correl, int maxpts, double abseps, double releps, double *error, double *value, int *inform) |
int | mvndst_infin (double low, double sup) |
double | bessel_j (double x, int n) |
int | bessel_j_table (double x, double alpha, int nb, double *b) |
int | bessel_k (double x, double alpha, int nb, double *bk) |
double | loggamma (double parameter) |
double | ut_legendre (int n, double v, bool flagNorm) |
VectorDouble | ut_legendreVec (int n, const VectorDouble &vecin, bool flagNorm) |
MatrixRectangular | ut_legendreMatNorm (int n, const VectorDouble &v) |
MatrixRectangular | ut_legendreAssociatedMat (int l, const VectorDouble &v, bool flagNorm) |
double | ut_flegendre (int n, int k0, double theta, bool flagNorm) |
double | ut_sphericalHarmonic (int n, int k, double theta, double phi) |
VectorDouble | ut_sphericalHarmonicVec (int n, int k, VectorDouble theta, VectorDouble phi) |
double | golden_search (double(*func_evaluate)(double test, void *user_data), void *user_data, double tolstop, double a0, double c0, double *test_loc, double *niter) |
int | ut_chebychev_count (double(*func)(double, double, const VectorDouble &), Cheb_Elem *cheb_elem, double x, const VectorDouble &blin) |
int | ut_chebychev_coeffs (double(*func)(double, double, const VectorDouble &), Cheb_Elem *cheb_elem, const VectorDouble &blin) |
void | ut_vandercorput (int n, int flag_sym, int flag_rot, int *ntri_arg, double **coor_arg) |
void | st_subdivide (double v1[3], double v2[3], double v3[3], int depth, Reg_Coor *R_coor) |
int | ut_icosphere (int n, int flag_rot, int *ntri_arg, double **coor_arg) |
void | ut_log_factorial (int nbpoly, double *factor) |
double | ut_factorial (int k) |
DISABLE_WARNING_POP MatrixRectangular * | vanDerCorput (int n, int nd) |
MatrixRectangular | fillLegendreMatrix (const VectorDouble &r, int legendreOrder) |
#define COORD | ( | i, | |
ip | |||
) | (coord[3 * (ip) + (i)]) |
#define RCOORD | ( | i, | |
ip | |||
) | (R_coor->coor[3 * (ip) + (i)]) |
#define w ((double *)&equiv_99) |
#define x ((double *)&equiv_100) |
#define X 0.525731112119133696 |
#define Z 0.850650808352039932 |
double bessel_j | ( | double | x, |
int | n | ||
) |
int bessel_j_table | ( | double | x, |
double | alpha, | ||
int | nb, | ||
double * | b | ||
) |
This routine calculates Bessel functions J SUB(NB+ALPHA) (X) for non-negative argument X, and non-negative order NB+ALPHA.
[in] | x | Working precision non-negative real argument for which J's are to be calculated. |
[in] | alpha | Working precision fractional part of order for which J's are to be calculated. 0 <= ALPHA < 1.0. |
[in] | nb | Integer number of functions to be calculated, NB > 0 The first function calculated is of order ALPHA, and the last is of order (NB - 1 + ALPHA). |
[out] | b | Working precision output vector of length NB. If the routine terminates normally (NCALC=NB), the vector b[] contains the functions Y(ALPHA,X), ... ,Y(NB-1+ALPHA,X), |
int bessel_k | ( | double | x, |
double | alpha, | ||
int | nb, | ||
double * | bk | ||
) |
This routine calculates modified Bessel functions of the second kind, K SUB(N+ALPHA) (X), for non-negative argument X and non-negative order N+ALPHA
[in] | x | Working precision non-negative real argument for which K's are to calculated. If K's are to be calculated, X must not be greater than XMAX. |
[in] | alpha | Working precision fractional part of order for which K's are to be calculated. 0 <= ALPHA <1.0. |
[in] | nb | Integer number of functions to be calculated, NB > 0. The first function calculated is of order ALPHA, and the last is of order (NB - 1 + ALPHA). |
[out] | bk | Working precision output vector of length NB. If the routine terminates normally (NCALC=NB), the vector BK contains the functions : K(ALPHA,X), ... , K(NB-1+ALPHA,X), |
MatrixRectangular fillLegendreMatrix | ( | const VectorDouble & | r, |
int | legendreOrder | ||
) |
double golden_search | ( | double(*)(double test, void *user_data) | func_evaluate, |
void * | user_data, | ||
double | tolstop, | ||
double | a0, | ||
double | c0, | ||
double * | test_loc, | ||
double * | niter | ||
) |
Golden Search algorithm
[in] | func_evaluate | Evaluating function |
[in] | user_data | User Data |
[in] | tolstop | Tolerance parameter |
[in] | a0 | Initial value for lower bound of interval |
[in] | c0 | Initial value for upper bound of interval |
[out] | test_loc | Final value of the evaluating function |
[out] | niter | Number of iterations |
double loggamma | ( | double | parameter | ) |
Calculation of the logarithm of the gamma function
[in] | parameter | raw value |
void mvndst | ( | int | n, |
double * | lower, | ||
double * | upper, | ||
int * | infin, | ||
double * | correl, | ||
int | maxpts, | ||
double | abseps, | ||
double | releps, | ||
double * | error, | ||
double * | value, | ||
int * | inform | ||
) |
Multivariate Normal Probability
[in] | n | Number of variables |
[in] | lower | Array of lower integration limits |
[in] | upper | Array of upper integration limits |
[in] | infin | Array of integration limit flags
|
[in] | correl | Array of correlation coefficients |
[in] | maxpts | Maximum number of function values allowed |
[in] | abseps | Absolute error tolerance |
[in] | releps | Relative error tolerance |
[out] | error | Estimated absolute error with 90% confidence level |
[out] | value | Estimated value for the integral |
[out] | inform | Returned code |
void mvndst2n | ( | double * | lower, |
double * | upper, | ||
double * | means, | ||
double * | correl, | ||
int | maxpts, | ||
double | abseps, | ||
double | releps, | ||
double * | error, | ||
double * | value, | ||
int * | inform | ||
) |
Calculate the multigaussian integral (non-normalized)
[in] | lower | Array of lower bounds (Dimension: nvar) |
[in] | upper | Array of upper bounds (Dimension: nvar) |
[in] | means | Array of means (Dimension: 2) |
[in] | correl | Correlation matrix (Dimension: 2*2) |
[in] | maxpts | Maximum number of function values allowed |
[in] | abseps | Absolute error tolerance |
[in] | releps | Relative error tolerance |
[out] | error | Estimated absolute error with 90% confidence level |
[out] | value | Estimated value for the integral |
[out] | inform | Returned code |
void mvndst4 | ( | double * | lower, |
double * | upper, | ||
double * | correl, | ||
int | maxpts, | ||
double | abseps, | ||
double | releps, | ||
double * | error, | ||
double * | value, | ||
int * | inform | ||
) |
Calculate the quadri-variable gaussian integral
[in] | lower | Array of lower bounds |
[in] | upper | Array of upper bounds |
[in] | correl | Correlation matrix (Dimension: 4*4) |
[in] | maxpts | Maximum number of function values allowed |
[in] | abseps | Absolute error tolerance |
[in] | releps | Relative error tolerance |
[out] | error | Estimated absolute error with 90% confidence level |
[out] | value | Estimated value for the integral |
[out] | inform | Returned code |
int mvndst_infin | ( | double | low, |
double | sup | ||
) |
Set the flags for the bound of numerical integration
[in] | low | Lower integration bound |
[in] | sup | Upper integration bound |
void st_subdivide | ( | double | v1[3], |
double | v2[3], | ||
double | v3[3], | ||
int | depth, | ||
Reg_Coor * | R_coor | ||
) |
int ut_chebychev_coeffs | ( | double(*)(double, double, const VectorDouble &) | func, |
Cheb_Elem * | cheb_elem, | ||
const VectorDouble & | blin | ||
) |
int ut_chebychev_count | ( | double(*)(double, double, const VectorDouble &) | func, |
Cheb_Elem * | cheb_elem, | ||
double | x, | ||
const VectorDouble & | blin | ||
) |
Evaluate the number of coefficients necessary to evaluate a function (at a sample location) at a given approximation
double ut_factorial | ( | int | k | ) |
Calculates the factorial coefficient
[in] | k | Value |
double ut_flegendre | ( | int | n, |
int | k0, | ||
double | theta, | ||
bool | flagNorm | ||
) |
Returns the Spherical Legendre normalized function. According to boost Library documentation, this returns
Y_n^m(theta, phi) = sqrt{{(2n+1)(n-m)!} / {4pi(n+m)!}} P_n^m(cos(theta))e{imphi}
with phi=0 and m = |k0|
If flagNorm is switched ON, the previous result is multiplied by:
sqrt(2 * pi)
[in] | n | Degree |
[in] | k0 | Order (ABS(k0) <= n) |
[in] | theta | Theta angle in radian |
[in] | flagNorm | for normalized and 0 otherwise |
int ut_icosphere | ( | int | n, |
int | flag_rot, | ||
int * | ntri_arg, | ||
double ** | coor_arg | ||
) |
Generate regular Icosahedron discretization
[in] | n | Number of discretization steps |
[in] | flag_rot | Perform a random rotation |
[out] | ntri_arg | Number of points |
[out] | coor_arg | Array of point coordinates (Dimension: 3*ntri) |
double ut_legendre | ( | int | n, |
double | v, | ||
bool | flagNorm | ||
) |
Returns the Legendre Function described as follows:
legendre_p(n,v) = 1/{2^n n!) d^n/dx^n [x^2-1)^n with |x|<=1
If flagNorm is switched ON, the Boost library cannot be used anymore. We have to rely on the ode provided by X; Freulon.
[in] | n | Degree of the Legendre Polynomial to be computed (n >= 0) |
[in] | v | Value for which the polynomial is evaluated (-1 <= v <= 1) |
[in] | flagNorm | True for normalized and 0 otherwise |
MatrixRectangular ut_legendreAssociatedMat | ( | int | l, |
const VectorDouble & | v, | ||
bool | flagNorm | ||
) |
Returns the Associated Legendre Function described as follows:
In the case flagNorm=true
Using the relations: P_0^0 (x) = 1 P_{l+1}^{l+1} (x) = - sqrt((2l+3)/(2l+2)) * (1-x^2)^{1/2} * P_{l}^{l}(x) P_{l+1}^{m} (x) = sqrt((2l+3)(2l+1)/((l-m+1)(l+m+1))) * x * P_{l}^{m}(x) - sqrt((2l+3)/(2l-1)*(l+m)/(l+m+1)*(l-m)/(l-m+1)) P_{l-1}^m(x) Changing l to l-1, P_{l}^{l} (x) = - a0 * (1-x^2)^{1/2} * P_{l-1}^{l-1}(x) with a0 = sqrt((2l+1)/(2l)) P_{l}^{m} (x) = a * x * P_{l-1}^{m}(x) - b P_{l-2}^m(x) with a = sqrt((2l+1)(2l-1)/(l-m)/(l+m)) and b = sqrt((2l+1)/(2l-3)*(l+m-1)/(l+m)*(l-m-1)/(l-m))
In the case flagNorm=false
Using the relations: P_0^0 (x) = 1 P_{l+1}^{l+1} (x) = - sqrt((2l+3)/(2l+2)) * (1-x^2)^{1/2} * P_{l}^{l}(x) P_{l+1}^{m} (x) = sqrt((2l+3)(2l+1)/((l-m+1)(l+m+1))) * x * P_{l}^{m}(x) - sqrt((2l+3)/(2l-1)*(l+m)/(l+m+1)*(l-m)/(l-m+1)) P_{l-1}^m(x) Changing l to l-1, P_{l}^{l} (x) = - a0 * (1-x^2)^{1/2} * P_{l-1}^{l-1}(x) with a0 = sqrt((2l+1)/(2l)) P_{l}^{m} (x) = a * x * P_{l-1}^{m}(x) - b P_{l-2}^m(x) with a = sqrt((2l+1)(2l-1)/(l-m)/(l+m)) and b = sqrt((2l+1)/(2l-3)*(l+m-1)/(l+m)*(l-m-1)/(l-m))
[in] | l | Degree of the Legendre Polynomial to be computed (n >= 0) |
[in] | v | Value for which the polynomial is evaluated (-1 <= v <= 1) |
[in] | flagNorm | Normalized when True |
MatrixRectangular ut_legendreMatNorm | ( | int | n, |
const VectorDouble & | v | ||
) |
VectorDouble ut_legendreVec | ( | int | n, |
const VectorDouble & | vecin, | ||
bool | flagNorm | ||
) |
void ut_log_factorial | ( | int | nbpoly, |
double * | factor | ||
) |
Calculates the nbpoly log-factorial coefficients
[in] | nbpoly | Number of terms |
[out] | factor | logarithm of factorials |
double ut_sphericalHarmonic | ( | int | n, |
int | k, | ||
double | theta, | ||
double | phi | ||
) |
Returns the Spherical harmonic
[in] | n | Degree of HS (n >= 0) |
[in] | k | Order of the HS (-n <= k <= n) |
[in] | theta | Colatitude angle in radian (0 <= theta <= pi |
[in] | phi | Longitude angle in radian (0 <= phi <= 2* pi) |
VectorDouble ut_sphericalHarmonicVec | ( | int | n, |
int | k, | ||
VectorDouble | theta, | ||
VectorDouble | phi | ||
) |
void ut_vandercorput | ( | int | n, |
int | flag_sym, | ||
int | flag_rot, | ||
int * | ntri_arg, | ||
double ** | coor_arg | ||
) |
Generate a Van Der Corput list of points in R^3
[in] | n | Number of points |
[in] | flag_sym | Duplicate the samples by symmetry |
[in] | flag_rot | Perform a random rotation |
[out] | ntri_arg | Number of points |
[out] | coor_arg | Array of point coordinates (Dimension: 3*ntri) |
DISABLE_WARNING_POP MatrixRectangular* vanDerCorput | ( | int | n, |
int | nd | ||
) |
Function to compute the vector Van der Corput sequence or the Halton sequence
n | The number of values to be computed |
nd | The dimension of output sequence |