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