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