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