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