1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.hipparchus.analysis.differentiation;
18
19 import java.util.HashMap;
20 import java.util.Map;
21
22 import org.hipparchus.CalculusFieldElement;
23 import org.hipparchus.Field;
24
25
26
27
28
29 public class FieldUnivariateDerivative1Field<T extends CalculusFieldElement<T>> implements Field<FieldUnivariateDerivative1<T>> {
30
31
32 private static final Map<Field<?>, FieldUnivariateDerivative1Field<?>> CACHE = new HashMap<>();
33
34
35 private final FieldUnivariateDerivative1<T> zero;
36
37
38 private final FieldUnivariateDerivative1<T> one;
39
40
41 private final FDSFactory<T> factory;
42
43
44
45
46 private FieldUnivariateDerivative1Field(final Field<T> valueField) {
47 zero = new FieldUnivariateDerivative1<>(valueField.getZero(), valueField.getZero());
48 one = new FieldUnivariateDerivative1<>(valueField.getOne(), valueField.getZero());
49 factory = new FDSFactory<>(valueField, 1, 1);
50 }
51
52
53
54
55
56
57 public static <T extends CalculusFieldElement<T>> FieldUnivariateDerivative1Field<T> getUnivariateDerivative1Field(final Field<T> valueField) {
58 synchronized (CACHE) {
59 FieldUnivariateDerivative1Field<?> cached = CACHE.get(valueField);
60 if (cached == null) {
61 cached = new FieldUnivariateDerivative1Field<>(valueField);
62 CACHE.put(valueField, cached);
63 }
64 @SuppressWarnings("unchecked")
65 final FieldUnivariateDerivative1Field<T> tCached = (FieldUnivariateDerivative1Field<T>) cached;
66 return tCached;
67 }
68 }
69
70
71 @Override
72 public FieldUnivariateDerivative1<T> getOne() {
73 return one;
74 }
75
76
77 @Override
78 public FieldUnivariateDerivative1<T> getZero() {
79 return zero;
80 }
81
82
83
84
85
86
87
88
89
90
91
92
93 FDSFactory<T> getConversionFactory() {
94 return factory;
95 }
96
97
98 @SuppressWarnings("unchecked")
99 @Override
100 public Class<FieldUnivariateDerivative1<T>> getRuntimeClass() {
101 return (Class<FieldUnivariateDerivative1<T>>) zero.getClass();
102 }
103
104
105 @Override
106 public boolean equals(final Object other) {
107 return this == other;
108 }
109
110
111 @Override
112 public int hashCode() {
113 return 0x712c0fc7;
114 }
115
116 }