1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.orekit.propagation.semianalytical.dsst.utilities;
18
19 import java.util.Map;
20 import java.util.TreeMap;
21
22 import org.apache.commons.math3.util.FastMath;
23 import org.orekit.propagation.semianalytical.dsst.utilities.CoefficientsFactory.MNSKey;
24
25
26
27
28
29 public class GammaMnsFunction {
30
31
32 private final Map<MNSKey, Double> map;
33
34
35 private final double[] fact;
36
37
38 private final double opIg;
39
40
41 private final int I;
42
43
44
45
46
47
48 public GammaMnsFunction(final double[] fact, final double gamma, final int I) {
49 this.fact = fact.clone();
50 this.opIg = 1. + I * gamma;
51 this.I = I;
52 this.map = new TreeMap<MNSKey, Double>();
53 }
54
55
56
57
58
59
60
61 public double getValue(final int m, final int n, final int s) {
62 double res = 0.;
63 final MNSKey key = new MNSKey(m, n, s);
64 if (map.containsKey(key)) {
65 res = map.get(key);
66 } else {
67 if (s <= -m) {
68 res = FastMath.pow(-1, m - s) * FastMath.pow(2, s) * FastMath.pow(opIg, -I * m);
69 } else if (s >= m) {
70 res = FastMath.pow(2, -s) * FastMath.pow(opIg, I * m);
71 } else {
72 res = FastMath.pow(-1, m - s) * FastMath.pow(2, -m) * FastMath.pow(opIg, I * s);
73 res *= fact[n + m] * fact[n - m];
74 res /= fact[n + s] * fact[n - s];
75 }
76 map.put(key, res);
77 }
78 return res;
79 }
80
81
82
83
84
85
86
87 public double getDerivative(final int m, final int n, final int s) {
88 double res = 0.;
89 if (s <= -m) {
90 res = -m * I * getValue(m, n, s) / opIg;
91 } else if (s >= m) {
92 res = m * I * getValue(m, n, s) / opIg;
93 } else {
94 res = s * I * getValue(m, n, s) / opIg;
95 }
96 return res;
97 }
98
99 }