besselpoly.c
Go to the documentation of this file.
1 #include "mconf.h"
2 
3 #define EPS 1.0e-17
4 
5 double besselpoly(double a, double lambda, double nu) {
6 
7  int m, factor=0;
8  double Sm, relerr, Sol;
9  double sum=0.0;
10 
11  /* Special handling for a = 0.0 */
12  if (a == 0.0) {
13  if (nu == 0.0) return 1.0/(lambda + 1);
14  else return 0.0;
15  }
16  /* Special handling for negative and integer nu */
17  if ((nu < 0) && (floor(nu)==nu)) {
18  nu = -nu;
19  factor = ((int) nu) % 2;
20  }
21  Sm = exp(nu*log(a))/(Gamma(nu+1)*(lambda+nu+1));
22  m = 0;
23  do {
24  sum += Sm;
25  Sol = Sm;
26  Sm *= -a*a*(lambda+nu+1+2*m)/((nu+m+1)*(m+1)*(lambda+nu+1+2*m+2));
27  m++;
28  relerr = fabs((Sm-Sol)/Sm);
29  } while (relerr > EPS && m < 1000);
30  if (!factor)
31  return sum;
32  else
33  return -sum;
34 }
gtsam.examples.DogLegOptimizerExample.int
int
Definition: DogLegOptimizerExample.py:111
EPS
#define EPS
Definition: besselpoly.c:3
Gamma
double Gamma(double x)
Definition: gamma.c:160
log
const EIGEN_DEVICE_FUNC LogReturnType log() const
Definition: ArrayCwiseUnaryOps.h:128
exp
const EIGEN_DEVICE_FUNC ExpReturnType exp() const
Definition: ArrayCwiseUnaryOps.h:97
boost::multiprecision::fabs
Real fabs(const Real &a)
Definition: boostmultiprec.cpp:119
besselpoly
double besselpoly(double a, double lambda, double nu)
Definition: besselpoly.c:5
relerr
Derived::RealScalar relerr(const MatrixBase< Derived > &A, const MatrixBase< OtherDerived > &B)
Definition: matrix_functions.h:64
m
Matrix3f m
Definition: AngleAxis_mimic_euler.cpp:1
lambda
static double lambda[]
Definition: jv.c:524
a
ArrayXXi a
Definition: Array_initializer_list_23_cxx11.cpp:1
mconf.h
floor
const EIGEN_DEVICE_FUNC FloorReturnType floor() const
Definition: ArrayCwiseUnaryOps.h:481


gtsam
Author(s):
autogenerated on Fri Nov 1 2024 03:32:01