Handles Calculation of the Modified Bessel Function of the First Kind
More...
|
static float | Bessi (int order, float argument, BesselCache cache=null) |
| Returns the modified Bessel function I_(x) for integer order >= 0 and real argument Caches all return values for the last argument used. Flushes cache when a new argument is used. More...
|
|
static double | Bessi (int order, double argument, DoubleBesselCache cache=null) |
| Returns the modified Bessel function I_(x) for integer order >= 0 and real argument Caches all return values for the last argument used. Flushes cache when a new argument is used. More...
|
|
Handles Calculation of the Modified Bessel Function of the First Kind
Definition at line 9 of file Bessel.cs.
◆ Bessi() [1/2]
static float BGC.Mathematics.Bessel.Bessi |
( |
int |
order, |
|
|
float |
argument, |
|
|
BesselCache |
cache = null |
|
) |
| |
|
inlinestatic |
Returns the modified Bessel function I_(x) for integer order >= 0 and real argument Caches all return values for the last argument used. Flushes cache when a new argument is used.
Adapted from: "Numerical Recipes in C", Second Edition, Press, WH et al., Cambridge University Press, page 237
- Parameters
-
order | non-negative integer order |
argument | real-valued argument |
- Returns
Definition at line 69 of file Bessel.cs.
Referenced by BGC.Audio.Synthesis.STMAudioClip.GetExpBandAmplitude().
76 if (argument != cache.LastArgument)
78 cache.ClearCache(argument);
79 cache[0] =
Bessi0(argument);
82 if (cache.Contains(order))
84 return (
float)cache[order];
90 throw new ArgumentOutOfRangeException($
"Bessel order must be greater than or equal to 0. Received: {order}");
112 const double ACC = 40.0;
113 const double BIGNO = 1.0e10;
114 const double BIGNI = 1.0e-10;
118 double tox = 2.0 / Math.Abs(x);
122 for (
int j = 2 * (order + (
int)Math.Sqrt(ACC * order)); j > 0; j--)
124 bim = bip + j * tox * bi;
127 if (Math.Abs(bi) > BIGNO)
143 ans *= cache[0] / bi;
147 ans *=
Bessi0(argument) / bi;
149 besselValue = x < 0.0 && order % 2 == 1 ? -ans : ans;
154 cache[order] = besselValue;
157 return (
float)besselValue;
static double Bessi1(double x)
Evaluate modified Bessel function In(x) and order n=1.
static double Bessi0(double x)
Evaluate modified Bessel function In(x) and order n=0.
◆ Bessi() [2/2]
static double BGC.Mathematics.Bessel.Bessi |
( |
int |
order, |
|
|
double |
argument, |
|
|
DoubleBesselCache |
cache = null |
|
) |
| |
|
inlinestatic |
Returns the modified Bessel function I_(x) for integer order >= 0 and real argument Caches all return values for the last argument used. Flushes cache when a new argument is used.
Adapted from: "Numerical Recipes in C", Second Edition, Press, WH et al., Cambridge University Press, page 237
- Parameters
-
order | non-negative integer order |
argument | real-valued argument |
- Returns
Definition at line 172 of file Bessel.cs.
179 if (argument != cache.LastArgument)
181 cache.ClearCache(argument);
182 cache[0] =
Bessi0(argument);
185 if (cache.Contains(order))
193 throw new ArgumentOutOfRangeException($
"Bessel order must be greater than or equal to 0. Received: {order}");
215 const double ACC = 40.0;
216 const double BIGNO = 1.0e10;
217 const double BIGNI = 1.0e-10;
221 double tox = 2.0 / Math.Abs(x);
225 for (
int j = 2 * (order + (
int)Math.Sqrt(ACC * order)); j > 0; j--)
227 bim = bip + j * tox * bi;
230 if (Math.Abs(bi) > BIGNO)
246 ans *= cache[0] / bi;
250 ans *=
Bessi0(argument) / bi;
252 besselValue = x < 0.0 && order % 2 == 1 ? -ans : ans;
257 cache[order] = besselValue;
static double Bessi1(double x)
Evaluate modified Bessel function In(x) and order n=1.
static double Bessi0(double x)
Evaluate modified Bessel function In(x) and order n=0.
◆ Bessi0()
static double BGC.Mathematics.Bessel.Bessi0 |
( |
double |
x | ) |
|
|
inlinestaticprivate |
Evaluate modified Bessel function In(x) and order n=0.
Adapted from: "Numerical Recipes in C", Second Edition, Press, WH et al., Cambridge University Press, page 237
- Parameters
-
x | Modified Bessel Function Argument |
- Returns
- Modified Bessel Function of order n=0 at Argument
Definition at line 272 of file Bessel.cs.
277 if ((ax = Math.Abs(x)) < 3.75)
281 ans = 1.0 + y * (3.5156229 + y * (3.0899424 + y * (1.2067492
282 + y * (0.2659732 + y * (0.360768e-1 + y * 0.45813e-2)))));
287 ans = (Math.Exp(ax) / Math.Sqrt(ax)) * (0.39894228 + y * (0.1328592e-1
288 + y * (0.225319e-2 + y * (-0.157565e-2 + y * (0.916281e-2
289 + y * (-0.2057706e-1 + y * (0.2635537e-1 + y * (-0.1647633e-1
290 + y * 0.392377e-2))))))));
◆ Bessi1()
static double BGC.Mathematics.Bessel.Bessi1 |
( |
double |
x | ) |
|
|
inlinestaticprivate |
Evaluate modified Bessel function In(x) and order n=1.
Adapted from: "Numerical Recipes in C", Second Edition, Press, WH et al., Cambridge University Press, page 237
- Parameters
-
x | Modified Bessel Function Argument |
- Returns
- Modified Bessel Function of order n=1 at Argument
Definition at line 305 of file Bessel.cs.
310 if ((ax = Math.Abs(x)) < 3.75)
314 ans = ax * (0.5 + y * (0.87890594 + y * (0.51498869 + y * (0.15084934
315 + y * (0.2658733e-1 + y * (0.301532e-2 + y * 0.32411e-3))))));
320 ans = 0.2282967e-1 + y * (-0.2895312e-1 + y * (0.1787654e-1
322 ans = 0.39894228 + y * (-0.3988024e-1 + y * (-0.362018e-2
323 + y * (0.163801e-2 + y * (-0.1031555e-1 + y * ans))));
324 ans *= (Math.Exp(ax) / Math.Sqrt(ax));
327 return x < 0.0 ? -ans : ans;
The documentation for this class was generated from the following file: