blob: 23fdfeaa6b6cd468e8365d6930e2b20de02954da (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
#include <math.h>
/**
* @brief Calculates pochhammer
* @param (a+n-1)!
* @return Result
*/
static double pochhammer(const double x, double n)
{
double temp = x;
if (n > 0)
{
while (n > 1)
{
temp *= (x + n - 1);
--n;
}
return temp;
}
else
{
return 1;
}
}
/**
* @brief Calculates the Factorial
* @param n!
* @return Result
*/
static double fac(int n)
{
double temp = n;
if (n > 0)
{
while (n > 1)
{
--n;
temp *= n;
}
return temp;
}
else
{
return 1;
}
}
/**
* @brief Calculates the Hypergeometric Function 0F1(;b;z)
* @param c in 0F1(;c;z)
* @param z in 0F1(;c;z)
* @param n number of itertions (precision)
* @return Result
*/
static double powerseries(const double c, const double z, unsigned int n)
{
double temp = 0.0;
for (unsigned int k = 0; k < n; ++k)
{
temp += pow(z, k) / (factorial(k) * pochhammer(c, k));
}
return temp;
}
|