AccelerationVector.java

  1. package org.djunits.value.vdouble.vector;

  2. import java.util.List;
  3. import java.util.Map;

  4. import org.djunits.unit.AccelerationUnit;
  5. import org.djunits.unit.scale.IdentityScale;
  6. import org.djunits.value.storage.StorageType;
  7. import org.djunits.value.vdouble.scalar.Acceleration;
  8. import org.djunits.value.vdouble.vector.base.DoubleVectorRel;
  9. import org.djunits.value.vdouble.vector.data.DoubleVectorData;

  10. import jakarta.annotation.Generated;

  11. /**
  12.  * Double AccelerationVector, a vector of values with a AccelerationUnit.
  13.  * <p>
  14.  * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
  15.  * BSD-style license. See <a href="https://djunits.org/docs/license.html">DJUNITS License</a>.
  16.  * </p>
  17.  * @author <a href="https://www.tudelft.nl/averbraeck">Alexander Verbraeck</a>
  18.  * @author <a href="https://www.tudelft.nl/staff/p.knoppers/">Peter Knoppers</a>
  19.  */
  20. @Generated(value = "org.djunits.generator.GenerateDJUNIT", date = "2023-07-23T14:06:38.224104100Z")
  21. public class AccelerationVector extends DoubleVectorRel<AccelerationUnit, Acceleration, AccelerationVector>

  22. {
  23.     /** */
  24.     private static final long serialVersionUID = 20190905L;

  25.     /**
  26.      * Construct an AccelerationVector from an internal data object.
  27.      * @param data DoubleVectorData; the internal data object for the vector
  28.      * @param displayUnit AccelerationUnit; the display unit of the vector data
  29.      */
  30.     public AccelerationVector(final DoubleVectorData data, final AccelerationUnit displayUnit)
  31.     {
  32.         super(data, displayUnit);
  33.     }

  34.     /* CONSTRUCTORS WITH double[] */

  35.     /**
  36.      * Construct an AccelerationVector from a double[] object. The double values are expressed in the displayUnit, and will be
  37.      * printed using the displayUnit.
  38.      * @param data double[]; the data for the vector, expressed in the displayUnit
  39.      * @param displayUnit AccelerationUnit; the unit of the values in the data array, and display unit when printing
  40.      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
  41.      */
  42.     public AccelerationVector(final double[] data, final AccelerationUnit displayUnit, final StorageType storageType)
  43.     {
  44.         this(DoubleVectorData.instantiate(data, displayUnit.getScale(), storageType), displayUnit);
  45.     }

  46.     /**
  47.      * Construct an AccelerationVector from a double[] object. The double values are expressed in the displayUnit. Assume that
  48.      * the StorageType is DENSE since we offer the data as an array.
  49.      * @param data double[]; the data for the vector
  50.      * @param displayUnit AccelerationUnit; the unit of the values in the data array, and display unit when printing
  51.      */
  52.     public AccelerationVector(final double[] data, final AccelerationUnit displayUnit)
  53.     {
  54.         this(data, displayUnit, StorageType.DENSE);
  55.     }

  56.     /**
  57.      * Construct an AccelerationVector from a double[] object with SI-unit values.
  58.      * @param data double[]; the data for the vector, in SI units
  59.      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
  60.      */
  61.     public AccelerationVector(final double[] data, final StorageType storageType)
  62.     {
  63.         this(data, AccelerationUnit.SI, storageType);
  64.     }

  65.     /**
  66.      * Construct an AccelerationVector from a double[] object with SI-unit values. Assume that the StorageType is DENSE since we
  67.      * offer the data as an array.
  68.      * @param data double[]; the data for the vector, in SI units
  69.      */
  70.     public AccelerationVector(final double[] data)
  71.     {
  72.         this(data, StorageType.DENSE);
  73.     }

  74.     /* CONSTRUCTORS WITH Acceleration[] */

  75.     /**
  76.      * Construct an AccelerationVector from an array of Acceleration objects. The Acceleration values are each expressed in
  77.      * their own unit, but will be internally stored as SI values, all expressed in the displayUnit when printing.
  78.      * @param data Acceleration[]; the data for the vector
  79.      * @param displayUnit AccelerationUnit; the display unit of the values when printing
  80.      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
  81.      */
  82.     public AccelerationVector(final Acceleration[] data, final AccelerationUnit displayUnit, final StorageType storageType)
  83.     {
  84.         this(DoubleVectorData.instantiate(data, storageType), displayUnit);
  85.     }

  86.     /**
  87.      * Construct an AccelerationVector from an array of Acceleration objects. The Acceleration values are each expressed in
  88.      * their own unit, but will be internally stored as SI values, all expressed in the displayUnit when printing. Assume that
  89.      * the StorageType is DENSE since we offer the data as an array.
  90.      * @param data Acceleration[]; the data for the vector
  91.      * @param displayUnit AccelerationUnit; the display unit of the values when printing
  92.      */
  93.     public AccelerationVector(final Acceleration[] data, final AccelerationUnit displayUnit)
  94.     {
  95.         this(data, displayUnit, StorageType.DENSE);
  96.     }

  97.     /**
  98.      * Construct an AccelerationVector from an array of Acceleration objects. The Acceleration values are each expressed in
  99.      * their own unit, but will be internally stored as SI values, and expressed using SI units when printing. since we offer
  100.      * the data as an array.
  101.      * @param data Acceleration[]; the data for the vector
  102.      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
  103.      */
  104.     public AccelerationVector(final Acceleration[] data, final StorageType storageType)
  105.     {
  106.         this(data, AccelerationUnit.SI, storageType);
  107.     }

  108.     /**
  109.      * Construct an AccelerationVector from an array of Acceleration objects. The Acceleration values are each expressed in
  110.      * their own unit, but will be internally stored as SI values, and expressed using SI units when printing. Assume that the
  111.      * StorageType is DENSE since we offer the data as an array.
  112.      * @param data Acceleration[]; the data for the vector
  113.      */
  114.     public AccelerationVector(final Acceleration[] data)
  115.     {
  116.         this(data, StorageType.DENSE);
  117.     }

  118.     /* CONSTRUCTORS WITH List<Double> or List<Acceleration> */

  119.     /**
  120.      * Construct an AccelerationVector from a list of Number objects or a list of Acceleration objects. Note that the
  121.      * displayUnit has a different meaning depending on whether the list contains Number objects (e.g., Double objects) or
  122.      * Acceleration objects. In case the list contains Number objects, the displayUnit indicates the unit in which the values in
  123.      * the list are expressed, as well as the unit in which they will be printed. In case the list contains Acceleration
  124.      * objects, each Acceleration has its own unit, and the displayUnit is just used for printing. The values but will always be
  125.      * internally stored as SI values or base values, and expressed using the display unit or base unit when printing.
  126.      * @param data List&lt;Double&gt; or List&lt;Acceleration&gt;; the data for the vector
  127.      * @param displayUnit AccelerationUnit; the display unit of the vector data, and the unit of the data points when the data
  128.      *            is expressed as List&lt;Double&gt; or List&lt;Number&gt; in general
  129.      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
  130.      */
  131.     public AccelerationVector(final List<? extends Number> data, final AccelerationUnit displayUnit,
  132.             final StorageType storageType)
  133.     {
  134.         this(data.size() == 0 ? DoubleVectorData.instantiate(new double[] {}, IdentityScale.SCALE, storageType)
  135.                 : data.get(0) instanceof Acceleration ? DoubleVectorData.instantiate(data, IdentityScale.SCALE, storageType)
  136.                         : DoubleVectorData.instantiate(data, displayUnit.getScale(), storageType),
  137.                 displayUnit);
  138.     }

  139.     /**
  140.      * Construct an AccelerationVector from a list of Number objects or a list of Acceleration objects. Note that the
  141.      * displayUnit has a different meaning depending on whether the list contains Number objects (e.g., Double objects) or
  142.      * Acceleration objects. In case the list contains Number objects, the displayUnit indicates the unit in which the values in
  143.      * the list are expressed, as well as the unit in which they will be printed. In case the list contains Acceleration
  144.      * objects, each Acceleration has its own unit, and the displayUnit is just used for printing. The values but will always be
  145.      * internally stored as SI values or base values, and expressed using the display unit or base unit when printing. Assume
  146.      * the storage type is DENSE since we offer the data as a List.
  147.      * @param data List&lt;Double&gt; or List&lt;Acceleration&gt;; the data for the vector
  148.      * @param displayUnit AccelerationUnit; the display unit of the vector data, and the unit of the data points when the data
  149.      *            is expressed as List&lt;Double&gt; or List&lt;Number&gt; in general
  150.      */
  151.     public AccelerationVector(final List<? extends Number> data, final AccelerationUnit displayUnit)
  152.     {
  153.         this(data, displayUnit, StorageType.DENSE);
  154.     }

  155.     /**
  156.      * Construct an AccelerationVector from a list of Number objects or a list of Acceleration objects. When data contains
  157.      * numbers such as Double, assume that they are expressed using SI units. When the data consists of Acceleration objects,
  158.      * they each have their own unit, but will be printed using SI units or base units. The values but will always be internally
  159.      * stored as SI values or base values, and expressed using the display unit or base unit when printing.
  160.      * @param data List&lt;Double&gt; or List&lt;Acceleration&gt;; the data for the vector
  161.      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
  162.      */
  163.     public AccelerationVector(final List<? extends Number> data, final StorageType storageType)
  164.     {
  165.         this(data, AccelerationUnit.SI, storageType);
  166.     }

  167.     /**
  168.      * Construct an AccelerationVector from a list of Number objects or a list of Acceleration objects. When data contains
  169.      * numbers such as Double, assume that they are expressed using SI units. When the data consists of Acceleration objects,
  170.      * they each have their own unit, but will be printed using SI units or base units. The values but will always be internally
  171.      * stored as SI values or base values, and expressed using the display unit or base unit when printing. Assume the storage
  172.      * type is DENSE since we offer the data as a List.
  173.      * @param data List&lt;Double&gt; or List&lt;Acceleration&gt;; the data for the vector
  174.      */
  175.     public AccelerationVector(final List<? extends Number> data)
  176.     {
  177.         this(data, StorageType.DENSE);
  178.     }

  179.     /* CONSTRUCTORS WITH Map<Integer, Double> or Map<Integer, Acceleration> */

  180.     /**
  181.      * Construct an AccelerationVector from a (sparse) map of index values to Number objects or a (sparse) map of index values
  182.      * to of Acceleration objects. Using index values is particularly useful for sparse vectors. The size parameter indicates
  183.      * the size of the vector, since the largest index does not have to be part of the map. Note that the displayUnit has a
  184.      * different meaning depending on whether the map contains Number objects (e.g., Double objects) or Acceleration objects. In
  185.      * case the map contains Number objects, the displayUnit indicates the unit in which the values in the map are expressed, as
  186.      * well as the unit in which they will be printed. In case the map contains Acceleration objects, each Acceleration has its
  187.      * own unit, and the displayUnit is just used for printing. The values but will always be internally stored as SI values or
  188.      * base values, and expressed using the display unit or base unit when printing.
  189.      * @param data Map&lt;Integer, Double&gt; or Map&lt;Integer, Acceleration&gt;; the data for the vector
  190.      * @param size int; the size off the vector, i.e., the highest index
  191.      * @param displayUnit AccelerationUnit; the display unit of the vector data, and the unit of the data points when the data
  192.      *            is expressed as List&lt;Double&gt; or List&lt;Number&gt; in general
  193.      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
  194.      */
  195.     public AccelerationVector(final Map<Integer, ? extends Number> data, final int size, final AccelerationUnit displayUnit,
  196.             final StorageType storageType)
  197.     {
  198.         this(data.size() == 0 ? DoubleVectorData.instantiate(data, size, IdentityScale.SCALE, storageType)
  199.                 : data.values().iterator().next() instanceof Acceleration
  200.                         ? DoubleVectorData.instantiate(data, size, IdentityScale.SCALE, storageType)
  201.                         : DoubleVectorData.instantiate(data, size, displayUnit.getScale(), storageType),
  202.                 displayUnit);
  203.     }

  204.     /**
  205.      * Construct an AccelerationVector from a (sparse) map of index values to Number objects or a (sparse) map of index values
  206.      * to of Acceleration 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., Double objects) or Acceleration 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 Acceleration objects, each Acceleration has its
  211.      * own unit, and the displayUnit is just used for printing. The values but will always be internally stored as SI values or
  212.      * base values, and expressed using the display unit or base unit when printing. Assume the storage type is SPARSE since we
  213.      * offer the data as a Map.
  214.      * @param data Map&lt;Integer, Double&gt; or Map&lt;Integer, Acceleration&gt;; the data for the vector
  215.      * @param size int; the size off the vector, i.e., the highest index
  216.      * @param displayUnit AccelerationUnit; the display unit of the vector data, and the unit of the data points when the data
  217.      *            is expressed as List&lt;Double&gt; or List&lt;Number&gt; in general
  218.      */
  219.     public AccelerationVector(final Map<Integer, ? extends Number> data, final int size, final AccelerationUnit displayUnit)
  220.     {
  221.         this(data, size, displayUnit, StorageType.SPARSE);
  222.     }

  223.     /**
  224.      * Construct an AccelerationVector from a (sparse) map of index values to Number objects or a (sparse) map of index values
  225.      * to of Acceleration objects. Using index values is particularly useful for sparse vectors. The size parameter indicates
  226.      * the size of the vector, since the largest index does not have to be part of the map. When data contains numbers such as
  227.      * Double, assume that they are expressed using SI units. When the data consists of Acceleration objects, they each have
  228.      * their own unit, but will be printed using SI units or base units. The values but will always be internally stored as SI
  229.      * values or base values, and expressed using the display unit or base unit when printing.
  230.      * @param data Map&lt;Integer, Double&gt; or Map&lt;Integer, Acceleration&gt;; the data for the vector
  231.      * @param size int; the size off the vector, i.e., the highest index
  232.      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
  233.      */
  234.     public AccelerationVector(final Map<Integer, ? extends Number> data, final int size, final StorageType storageType)
  235.     {
  236.         this(data, size, AccelerationUnit.SI, storageType);
  237.     }

  238.     /**
  239.      * Construct an AccelerationVector from a (sparse) map of index values to Number objects or a (sparse) map of index values
  240.      * to of Acceleration objects. Using index values is particularly useful for sparse vectors. The size parameter indicates
  241.      * the size of the vector, since the largest index does not have to be part of the map. When data contains numbers such as
  242.      * Double, assume that they are expressed using SI units. When the data consists of Acceleration objects, they each have
  243.      * their own unit, but will be printed using SI units or base units. The values but will always be internally stored as SI
  244.      * values or base values, and expressed using the display unit or base unit when printing. Assume the storage type is SPARSE
  245.      * since we offer the data as a Map.
  246.      * @param data Map&lt;Integer, Double&gt; or Map&lt;Integer, Acceleration&gt;; the data for the vector
  247.      * @param size int; the size off the vector, i.e., the highest index
  248.      */
  249.     public AccelerationVector(final Map<Integer, ? extends Number> data, final int size)
  250.     {
  251.         this(data, size, StorageType.SPARSE);
  252.     }

  253.     /* ****************************** Other methods ****************************** */

  254.     @Override
  255.     public Class<Acceleration> getScalarClass()
  256.     {
  257.         return Acceleration.class;
  258.     }

  259.     @Override
  260.     public AccelerationVector instantiateVector(final DoubleVectorData dvd, final AccelerationUnit displayUnit)
  261.     {
  262.         return new AccelerationVector(dvd, displayUnit);
  263.     }

  264.     @Override
  265.     public Acceleration instantiateScalarSI(final double valueSI, final AccelerationUnit displayUnit)
  266.     {
  267.         Acceleration result = Acceleration.instantiateSI(valueSI);
  268.         result.setDisplayUnit(displayUnit);
  269.         return result;
  270.     }

  271. }