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