FloatAngleVector.java

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

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

  4. import org.djunits.unit.AngleUnit;
  5. import org.djunits.unit.DirectionUnit;
  6. import org.djunits.unit.scale.IdentityScale;
  7. import org.djunits.value.storage.StorageType;
  8. import org.djunits.value.vfloat.scalar.FloatAngle;
  9. import org.djunits.value.vfloat.scalar.FloatDirection;
  10. import org.djunits.value.vfloat.vector.base.FloatVectorRelWithAbs;
  11. import org.djunits.value.vfloat.vector.data.FloatVectorData;

  12. import jakarta.annotation.Generated;

  13. /**
  14.  * Relative FloatAngle Vector.
  15.  * <p>
  16.  * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
  17.  * BSD-style license. See <a href="https://djunits.org/docs/license.html">DJUNITS License</a>.
  18.  * </p>
  19.  * @author <a href="https://www.tudelft.nl/averbraeck">Alexander Verbraeck</a>
  20.  * @author <a href="https://www.tudelft.nl/staff/p.knoppers/">Peter Knoppers</a>
  21.  */
  22. @Generated(value = "org.djunits.generator.GenerateDJUNIT", date = "2023-07-23T14:06:38.224104100Z")
  23. public class FloatAngleVector extends
  24.         FloatVectorRelWithAbs<DirectionUnit, FloatDirection, FloatDirectionVector, AngleUnit, FloatAngle, FloatAngleVector>
  25. {
  26.     /** */
  27.     private static final long serialVersionUID = 20151006L;

  28.     /**
  29.      * Construct a FloatAngleVector from an internal data object.
  30.      * @param data FloatVectorData; the internal data object for the vector
  31.      * @param displayUnit AngleUnit; the display unit of the vector data
  32.      */
  33.     public FloatAngleVector(final FloatVectorData data, final AngleUnit displayUnit)
  34.     {
  35.         super(data, displayUnit);
  36.     }

  37.     /* CONSTRUCTORS WITH float[] */

  38.     /**
  39.      * Construct a FloatAngleVector from a float[] object. The Float values are expressed in the displayUnit, and will be
  40.      * printed using the displayUnit.
  41.      * @param data float[]; the data for the vector, expressed in the displayUnit
  42.      * @param displayUnit AngleUnit; the unit of the values in the data array, and display unit when printing
  43.      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
  44.      */
  45.     public FloatAngleVector(final float[] data, final AngleUnit displayUnit, final StorageType storageType)
  46.     {
  47.         this(FloatVectorData.instantiate(data, displayUnit.getScale(), storageType), displayUnit);
  48.     }

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

  59.     /**
  60.      * Construct a FloatAngleVector from a float[] object with SI-unit values.
  61.      * @param data float[]; the data for the vector, in SI units
  62.      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
  63.      */
  64.     public FloatAngleVector(final float[] data, final StorageType storageType)
  65.     {
  66.         this(data, AngleUnit.SI, storageType);
  67.     }

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

  77.     /* CONSTRUCTORS WITH FloatAngle[] */

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

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

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

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

  121.     /* CONSTRUCTORS WITH List<Float> or List<Angle> */

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

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

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

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

  181.     /* CONSTRUCTORS WITH Map<Integer, Float> or Map<Integer, FloatAngle> */

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

  206.     /**
  207.      * Construct a FloatAngleVector from a (sparse) map of index values to Number objects or a (sparse) map of index values to
  208.      * of FloatAngle objects. Using index values is particularly useful for sparse vectors. The size parameter indicates the
  209.      * size of the vector, since the largest index does not have to be part of the map. Note that the displayUnit has a
  210.      * different meaning depending on whether the map contains Number objects (e.g., Float objects) or FloatAngle objects. In
  211.      * case the map contains Number objects, the displayUnit indicates the unit in which the values in the map are expressed, as
  212.      * well as the unit in which they will be printed. In case the map contains FloatAngle objects, each FloatAngle has its own
  213.      * unit, and the displayUnit is just used for printing. The values but will always be internally stored as SI values or base
  214.      * values, and expressed using the display unit or base unit when printing. Assume the storage type is SPARSE since we offer
  215.      * the data as a Map.
  216.      * @param data Map&lt;Integer, Float&gt; or Map&lt;Integer, FloatAngle&gt;; the data for the vector
  217.      * @param size int; the size off the vector, i.e., the highest index
  218.      * @param displayUnit AngleUnit; the display unit of the vector data, and the unit of the data points when the data is
  219.      *            expressed as List&lt;Float&gt; or List&lt;Number&gt; in general
  220.      */
  221.     public FloatAngleVector(final Map<Integer, ? extends Number> data, final int size, final AngleUnit displayUnit)
  222.     {
  223.         this(data, size, displayUnit, StorageType.SPARSE);
  224.     }

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

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

  255.     /* ****************************** Other methods ****************************** */

  256.     @Override
  257.     public Class<FloatAngle> getScalarClass()
  258.     {
  259.         return FloatAngle.class;
  260.     }

  261.     @Override
  262.     public FloatAngleVector instantiateVector(final FloatVectorData fvd, final AngleUnit displayUnit)
  263.     {
  264.         return new FloatAngleVector(fvd, displayUnit);
  265.     }

  266.     @Override
  267.     public FloatAngle instantiateScalarSI(final float valueSI, final AngleUnit displayUnit)
  268.     {
  269.         FloatAngle result = FloatAngle.instantiateSI(valueSI);
  270.         result.setDisplayUnit(displayUnit);
  271.         return result;
  272.     }

  273.     @Override
  274.     public FloatDirectionVector instantiateVectorAbs(final FloatVectorData fvd, final DirectionUnit displayUnit)
  275.     {
  276.         return new FloatDirectionVector(fvd, displayUnit);
  277.     }

  278.     @Override
  279.     public FloatDirection instantiateScalarAbsSI(final float valueSI, final DirectionUnit displayUnit)
  280.     {
  281.         FloatDirection result = FloatDirection.instantiateSI(valueSI);
  282.         result.setDisplayUnit(displayUnit);
  283.         return result;
  284.     }

  285. }