LuminousIntensityVector.java

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

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

  4. import org.djunits.unit.LuminousIntensityUnit;
  5. import org.djunits.unit.scale.IdentityScale;
  6. import org.djunits.value.storage.StorageType;
  7. import org.djunits.value.vdouble.scalar.LuminousIntensity;
  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 LuminousIntensityVector, a vector of values with a LuminousIntensityUnit.
  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 LuminousIntensityVector extends DoubleVectorRel<LuminousIntensityUnit, LuminousIntensity, LuminousIntensityVector>

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

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

  34.     /* CONSTRUCTORS WITH double[] */

  35.     /**
  36.      * Construct an LuminousIntensityVector from a double[] object. The double values are expressed in the displayUnit, and will
  37.      * be printed using the displayUnit.
  38.      * @param data double[]; the data for the vector, expressed in the displayUnit
  39.      * @param displayUnit LuminousIntensityUnit; 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 LuminousIntensityVector(final double[] data, final LuminousIntensityUnit displayUnit, final StorageType storageType)
  43.     {
  44.         this(DoubleVectorData.instantiate(data, displayUnit.getScale(), storageType), displayUnit);
  45.     }

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

  56.     /**
  57.      * Construct an LuminousIntensityVector 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 LuminousIntensityVector(final double[] data, final StorageType storageType)
  62.     {
  63.         this(data, LuminousIntensityUnit.SI, storageType);
  64.     }

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

  74.     /* CONSTRUCTORS WITH LuminousIntensity[] */

  75.     /**
  76.      * Construct an LuminousIntensityVector from an array of LuminousIntensity objects. The LuminousIntensity values are each
  77.      * expressed in their own unit, but will be internally stored as SI values, all expressed in the displayUnit when printing.
  78.      * @param data LuminousIntensity[]; the data for the vector
  79.      * @param displayUnit LuminousIntensityUnit; 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 LuminousIntensityVector(final LuminousIntensity[] data, final LuminousIntensityUnit displayUnit,
  83.             final StorageType storageType)
  84.     {
  85.         this(DoubleVectorData.instantiate(data, storageType), displayUnit);
  86.     }

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

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

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

  119.     /* CONSTRUCTORS WITH List<Double> or List<LuminousIntensity> */

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

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

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

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

  183.     /* CONSTRUCTORS WITH Map<Integer, Double> or Map<Integer, LuminousIntensity> */

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

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

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

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

  258.     /* ****************************** Other methods ****************************** */

  259.     @Override
  260.     public Class<LuminousIntensity> getScalarClass()
  261.     {
  262.         return LuminousIntensity.class;
  263.     }

  264.     @Override
  265.     public LuminousIntensityVector instantiateVector(final DoubleVectorData dvd, final LuminousIntensityUnit displayUnit)
  266.     {
  267.         return new LuminousIntensityVector(dvd, displayUnit);
  268.     }

  269.     @Override
  270.     public LuminousIntensity instantiateScalarSI(final double valueSI, final LuminousIntensityUnit displayUnit)
  271.     {
  272.         LuminousIntensity result = LuminousIntensity.instantiateSI(valueSI);
  273.         result.setDisplayUnit(displayUnit);
  274.         return result;
  275.     }

  276. }