private double getNikRecursion double int int if if isEqualNull Math A

 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
private double getNikRecursion(double t, int i, int k)
{
if (k == 1)
{
if (isEqualNull(Math.Abs(knots[i] - t)) || (knots[i] < t && t < knots[i + 1]))
{
return 1;
}
else
{
return 0;
}
}
double numerator1 = (t - knots[i]) * getNikRecursion(t, i, k - 1),
znam1 = knots[i + k - 1] - knots[i];
double numerator2 = (knots[i + k] - t) * getNikRecursion(t, i + 1, k - 1),
znam2 = knots[i + k] - knots[i + 1];
double proportion1, proportion2;
if (isEqualNull(numerator1) || isEqualNull(znam1))
{
proportion1 = 0;
}
else
{
proportion1 = numerator1 / znam1;
}
if (isEqualNull(numerator2) || isEqualNull(znam2))
{
proportion2 = 0;
}
else
{
proportion2 = numerator2 / znam2;
}
double curN = proportion1 + proportion2;
return curN;
}