View Javadoc
1   package org.djunits.value.vfloat.vector;
2   
3   import java.util.List;
4   import java.util.Map;
5   
6   import org.djunits.unit.AbsoluteTemperatureUnit;
7   import org.djunits.unit.TemperatureUnit;
8   import org.djunits.unit.scale.IdentityScale;
9   import org.djunits.value.storage.StorageType;
10  import org.djunits.value.vfloat.scalar.FloatAbsoluteTemperature;
11  import org.djunits.value.vfloat.scalar.FloatTemperature;
12  import org.djunits.value.vfloat.vector.base.FloatVectorRelWithAbs;
13  import org.djunits.value.vfloat.vector.data.FloatVectorData;
14  
15  import jakarta.annotation.Generated;
16  
17  /**
18   * Relative FloatTemperature Vector.
19   * <p>
20   * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
21   * BSD-style license. See <a href="https://djunits.org/docs/license.html">DJUNITS License</a>.
22   * </p>
23   * @author <a href="https://www.tudelft.nl/averbraeck">Alexander Verbraeck</a>
24   * @author <a href="https://www.tudelft.nl/staff/p.knoppers/">Peter Knoppers</a>
25   */
26  @Generated(value = "org.djunits.generator.GenerateDJUNIT", date = "2023-07-23T14:06:38.224104100Z")
27  public class FloatTemperatureVector extends FloatVectorRelWithAbs<AbsoluteTemperatureUnit, FloatAbsoluteTemperature,
28          FloatAbsoluteTemperatureVector, TemperatureUnit, FloatTemperature, FloatTemperatureVector>
29  {
30      /** */
31      private static final long serialVersionUID = 20151006L;
32  
33      /**
34       * Construct a FloatTemperatureVector from an internal data object.
35       * @param data FloatVectorData; the internal data object for the vector
36       * @param displayUnit TemperatureUnit; the display unit of the vector data
37       */
38      public FloatTemperatureVector(final FloatVectorData data, final TemperatureUnit displayUnit)
39      {
40          super(data, displayUnit);
41      }
42  
43      /* CONSTRUCTORS WITH float[] */
44  
45      /**
46       * Construct a FloatTemperatureVector from a float[] object. The Float values are expressed in the displayUnit, and will be
47       * printed using the displayUnit.
48       * @param data float[]; the data for the vector, expressed in the displayUnit
49       * @param displayUnit TemperatureUnit; the unit of the values in the data array, and display unit when printing
50       * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
51       */
52      public FloatTemperatureVector(final float[] data, final TemperatureUnit displayUnit, final StorageType storageType)
53      {
54          this(FloatVectorData.instantiate(data, displayUnit.getScale(), storageType), displayUnit);
55      }
56  
57      /**
58       * Construct a FloatTemperatureVector from a float[] object. The Float values are expressed in the displayUnit. Assume that
59       * the StorageType is DENSE since we offer the data as an array.
60       * @param data float[]; the data for the vector
61       * @param displayUnit TemperatureUnit; the unit of the values in the data array, and display unit when printing
62       */
63      public FloatTemperatureVector(final float[] data, final TemperatureUnit displayUnit)
64      {
65          this(data, displayUnit, StorageType.DENSE);
66      }
67  
68      /**
69       * Construct a FloatTemperatureVector from a float[] object with SI-unit values.
70       * @param data float[]; the data for the vector, in SI units
71       * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
72       */
73      public FloatTemperatureVector(final float[] data, final StorageType storageType)
74      {
75          this(data, TemperatureUnit.SI, storageType);
76      }
77  
78      /**
79       * Construct a FloatTemperatureVector from a float[] object with SI-unit values. Assume that the StorageType is DENSE since
80       * we offer the data as an array.
81       * @param data float[]; the data for the vector, in SI units
82       */
83      public FloatTemperatureVector(final float[] data)
84      {
85          this(data, StorageType.DENSE);
86      }
87  
88      /* CONSTRUCTORS WITH FloatTemperature[] */
89  
90      /**
91       * Construct a FloatTemperatureVector from an array of FloatTemperature objects. The FloatTemperature values are each
92       * expressed in their own unit, but will be internally stored as SI values, all expressed in the displayUnit when printing.
93       * @param data FloatTemperature[]; the data for the vector
94       * @param displayUnit TemperatureUnit; the display unit of the values when printing
95       * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
96       */
97      public FloatTemperatureVector(final FloatTemperature[] data, final TemperatureUnit displayUnit,
98              final StorageType storageType)
99      {
100         this(FloatVectorData.instantiate(data, storageType), displayUnit);
101     }
102 
103     /**
104      * Construct a FloatTemperatureVector from an array of FloatTemperature objects. The FloatTemperature values are each
105      * expressed in their own unit, but will be internally stored as SI values, all expressed in the displayUnit when printing.
106      * Assume that the StorageType is DENSE since we offer the data as an array.
107      * @param data FloatTemperature[]; the data for the vector
108      * @param displayUnit TemperatureUnit; the display unit of the values when printing
109      */
110     public FloatTemperatureVector(final FloatTemperature[] data, final TemperatureUnit displayUnit)
111     {
112         this(data, displayUnit, StorageType.DENSE);
113     }
114 
115     /**
116      * Construct a FloatTemperatureVector from an array of FloatTemperature objects. The FloatTemperature values are each
117      * expressed in their own unit, but will be internally stored as SI values, and expressed using SI units when printing.
118      * since we offer the data as an array.
119      * @param data FloatTemperature[]; the data for the vector
120      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
121      */
122     public FloatTemperatureVector(final FloatTemperature[] data, final StorageType storageType)
123     {
124         this(data, TemperatureUnit.SI, storageType);
125     }
126 
127     /**
128      * Construct a FloatTemperatureVector from an array of FloatTemperature objects. The FloatTemperature values are each
129      * expressed in their own unit, but will be internally stored as SI values, and expressed using SI units when printing.
130      * Assume that the StorageType is DENSE since we offer the data as an array.
131      * @param data FloatTemperature[]; the data for the vector
132      */
133     public FloatTemperatureVector(final FloatTemperature[] data)
134     {
135         this(data, StorageType.DENSE);
136     }
137 
138     /* CONSTRUCTORS WITH List<Float> or List<Temperature> */
139 
140     /**
141      * Construct a FloatTemperatureVector from a list of Number objects or a list of FloatTemperature objects. Note that the
142      * displayUnit has a different meaning depending on whether the list contains Number objects (e.g., Float objects) or
143      * FloatTemperature objects. In case the list contains Number objects, the displayUnit indicates the unit in which the
144      * values in the list are expressed, as well as the unit in which they will be printed. In case the list contains
145      * FloatTemperature objects, each FloatTemperature has its own unit, and the displayUnit is just used for printing. The
146      * values but will always be internally stored as SI values or base values, and expressed using the display unit or base
147      * unit when printing.
148      * @param data List&lt;Float&gt; or List&lt;Temperature&gt;; the data for the vector
149      * @param displayUnit TemperatureUnit; the display unit of the vector data, and the unit of the data points when the data is
150      *            expressed as List&lt;Float&gt; or List&lt;Number&gt; in general
151      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
152      */
153     public FloatTemperatureVector(final List<? extends Number> data, final TemperatureUnit displayUnit,
154             final StorageType storageType)
155     {
156         this(data.size() == 0 ? FloatVectorData.instantiate(new float[] {}, IdentityScale.SCALE, storageType)
157                 : data.get(0) instanceof FloatTemperature ? FloatVectorData.instantiate(data, IdentityScale.SCALE, storageType)
158                         : FloatVectorData.instantiate(data, displayUnit.getScale(), storageType),
159                 displayUnit);
160     }
161 
162     /**
163      * Construct a FloatTemperatureVector from a list of Number objects or a list of FloatTemperature objects. Note that the
164      * displayUnit has a different meaning depending on whether the list contains Number objects (e.g., Float objects) or
165      * FloatTemperature objects. In case the list contains Number objects, the displayUnit indicates the unit in which the
166      * values in the list are expressed, as well as the unit in which they will be printed. In case the list contains
167      * FloatTemperature objects, each FloatTemperature has its own unit, and the displayUnit is just used for printing. The
168      * values but will always be internally stored as SI values or base values, and expressed using the display unit or base
169      * unit when printing. Assume the storage type is DENSE since we offer the data as a List.
170      * @param data List&lt;Float&gt; or List&lt;Temperature&gt;; the data for the vector
171      * @param displayUnit TemperatureUnit; the display unit of the vector data, and the unit of the data points when the data is
172      *            expressed as List&lt;Float&gt; or List&lt;Number&gt; in general
173      */
174     public FloatTemperatureVector(final List<? extends Number> data, final TemperatureUnit displayUnit)
175     {
176         this(data, displayUnit, StorageType.DENSE);
177     }
178 
179     /**
180      * Construct a FloatTemperatureVector from a list of Number objects or a list of FloatTemperature objects. When data
181      * contains numbers such as Float, assume that they are expressed using SI units. When the data consists of FloatTemperature
182      * objects, they each have their own unit, but will be printed using SI units or base units. The values but will always be
183      * internally stored as SI values or base values, and expressed using the display unit or base unit when printing.
184      * @param data List&lt;Float&gt; or List&lt;Temperature&gt;; the data for the vector
185      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
186      */
187     public FloatTemperatureVector(final List<? extends Number> data, final StorageType storageType)
188     {
189         this(data, TemperatureUnit.SI, storageType);
190     }
191 
192     /**
193      * Construct a FloatTemperatureVector from a list of Number objects or a list of FloatTemperature objects. When data
194      * contains numbers such as Float, assume that they are expressed using SI units. When the data consists of FloatTemperature
195      * objects, they each have their own unit, but will be printed using SI units or base units. The values but will always be
196      * internally stored as SI values or base values, and expressed using the display unit or base unit when printing. Assume
197      * the storage type is DENSE since we offer the data as a List.
198      * @param data List&lt;Float&gt; or List&lt;Temperature&gt;; the data for the vector
199      */
200     public FloatTemperatureVector(final List<? extends Number> data)
201     {
202         this(data, StorageType.DENSE);
203     }
204 
205     /* CONSTRUCTORS WITH Map<Integer, Float> or Map<Integer, FloatTemperature> */
206 
207     /**
208      * Construct a FloatTemperatureVector from a (sparse) map of index values to Number objects or a (sparse) map of index
209      * values to of FloatTemperature objects. Using index values is particularly useful for sparse vectors. The size parameter
210      * indicates the size of the vector, since the largest index does not have to be part of the map. Note that the displayUnit
211      * has a different meaning depending on whether the map contains Number objects (e.g., Float objects) or FloatTemperature
212      * objects. In case the map contains Number objects, the displayUnit indicates the unit in which the values in the map are
213      * expressed, as well as the unit in which they will be printed. In case the map contains FloatTemperature objects, each
214      * FloatTemperature has its own unit, and the displayUnit is just used for printing. The values but will always be
215      * internally stored as SI values or base values, and expressed using the display unit or base unit when printing.
216      * @param data Map&lt;Integer, Float&gt; or Map&lt;Integer, FloatTemperature&gt;; the data for the vector
217      * @param size int; the size off the vector, i.e., the highest index
218      * @param displayUnit TemperatureUnit; the display unit of the vector data, and the unit of the data points when the data is
219      *            expressed as List&lt;Float&gt; or List&lt;Number&gt; in general
220      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
221      */
222     public FloatTemperatureVector(final Map<Integer, ? extends Number> data, final int size, final TemperatureUnit displayUnit,
223             final StorageType storageType)
224     {
225         this(data.size() == 0 ? FloatVectorData.instantiate(data, size, IdentityScale.SCALE, storageType)
226                 : data.values().iterator().next() instanceof FloatTemperature
227                         ? FloatVectorData.instantiate(data, size, IdentityScale.SCALE, storageType)
228                         : FloatVectorData.instantiate(data, size, displayUnit.getScale(), storageType),
229                 displayUnit);
230     }
231 
232     /**
233      * Construct a FloatTemperatureVector from a (sparse) map of index values to Number objects or a (sparse) map of index
234      * values to of FloatTemperature objects. Using index values is particularly useful for sparse vectors. The size parameter
235      * indicates the size of the vector, since the largest index does not have to be part of the map. Note that the displayUnit
236      * has a different meaning depending on whether the map contains Number objects (e.g., Float objects) or FloatTemperature
237      * objects. In case the map contains Number objects, the displayUnit indicates the unit in which the values in the map are
238      * expressed, as well as the unit in which they will be printed. In case the map contains FloatTemperature objects, each
239      * FloatTemperature has its own unit, and the displayUnit is just used for printing. The values but will always be
240      * internally stored as SI values or base values, and expressed using the display unit or base unit when printing. Assume
241      * the storage type is SPARSE since we offer the data as a Map.
242      * @param data Map&lt;Integer, Float&gt; or Map&lt;Integer, FloatTemperature&gt;; the data for the vector
243      * @param size int; the size off the vector, i.e., the highest index
244      * @param displayUnit TemperatureUnit; the display unit of the vector data, and the unit of the data points when the data is
245      *            expressed as List&lt;Float&gt; or List&lt;Number&gt; in general
246      */
247     public FloatTemperatureVector(final Map<Integer, ? extends Number> data, final int size, final TemperatureUnit displayUnit)
248     {
249         this(data, size, displayUnit, StorageType.SPARSE);
250     }
251 
252     /**
253      * Construct a FloatTemperatureVector from a (sparse) map of index values to Number objects or a (sparse) map of index
254      * values to of FloatTemperature objects. Using index values is particularly useful for sparse vectors. The size parameter
255      * indicates the size of the vector, since the largest index does not have to be part of the map. When data contains numbers
256      * such as Float, assume that they are expressed using SI units. When the data consists of FloatTemperature objects, they
257      * each have their own unit, but will be printed using SI units or base units. The values but will always be internally
258      * stored as SI values or base values, and expressed using the display unit or base unit when printing.
259      * @param data Map&lt;Integer, Float&gt; or Map&lt;Integer, FloatTemperature&gt;; the data for the vector
260      * @param size int; the size off the vector, i.e., the highest index
261      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
262      */
263     public FloatTemperatureVector(final Map<Integer, ? extends Number> data, final int size, final StorageType storageType)
264     {
265         this(data, size, TemperatureUnit.SI, storageType);
266     }
267 
268     /**
269      * Construct a FloatTemperatureVector from a (sparse) map of index values to Number objects or a (sparse) map of index
270      * values to of FloatTemperature objects. Using index values is particularly useful for sparse vectors. The size parameter
271      * indicates the size of the vector, since the largest index does not have to be part of the map. When data contains numbers
272      * such as Float, assume that they are expressed using SI units. When the data consists of FloatTemperature objects, they
273      * each have their own unit, but will be printed using SI units or base units. The values but will always be internally
274      * stored as SI values or base values, and expressed using the display unit or base unit when printing. Assume the storage
275      * type is SPARSE since we offer the data as a Map.
276      * @param data Map&lt;Integer, Float&gt; or Map&lt;Integer, FloatTemperature&gt;; the data for the vector
277      * @param size int; the size off the vector, i.e., the highest index
278      */
279     public FloatTemperatureVector(final Map<Integer, ? extends Number> data, final int size)
280     {
281         this(data, size, StorageType.SPARSE);
282     }
283 
284     /* ****************************** Other methods ****************************** */
285 
286     @Override
287     public Class<FloatTemperature> getScalarClass()
288     {
289         return FloatTemperature.class;
290     }
291 
292     @Override
293     public FloatTemperatureVector instantiateVector(final FloatVectorData fvd, final TemperatureUnit displayUnit)
294     {
295         return new FloatTemperatureVector(fvd, displayUnit);
296     }
297 
298     @Override
299     public FloatTemperature instantiateScalarSI(final float valueSI, final TemperatureUnit displayUnit)
300     {
301         FloatTemperature result = FloatTemperature.instantiateSI(valueSI);
302         result.setDisplayUnit(displayUnit);
303         return result;
304     }
305 
306     @Override
307     public FloatAbsoluteTemperatureVector instantiateVectorAbs(final FloatVectorData fvd,
308             final AbsoluteTemperatureUnit displayUnit)
309     {
310         return new FloatAbsoluteTemperatureVector(fvd, displayUnit);
311     }
312 
313     @Override
314     public FloatAbsoluteTemperature instantiateScalarAbsSI(final float valueSI, final AbsoluteTemperatureUnit displayUnit)
315     {
316         FloatAbsoluteTemperature result = FloatAbsoluteTemperature.instantiateSI(valueSI);
317         result.setDisplayUnit(displayUnit);
318         return result;
319     }
320 
321 }