Class DoubleVector

java.lang.Object
org.djunits.value.vdouble.vector.base.DoubleVector

public final class DoubleVector
extends Object
DoubleVector utility methods, e.g., for creating DoubleVectors from different types of data.

Copyright (c) 2015-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See DJUNITS License.

Author:
Alexander Verbraeck, Peter Knoppers
  • Method Details

    • instantiate

      public static <U extends Unit<U>,​ S extends DoubleScalarInterface<U,​ S>,​ V extends DoubleVectorInterface<U,​ S,​ V>> V instantiate​(double[] valuesInUnit, U unit, StorageType storageType)
      Instantiate the DoubleVector based on its unit. Rigid check on types for the compiler.
      Type Parameters:
      U - the unit type
      S - the corresponding scalar type
      V - the corresponding vector type
      Parameters:
      valuesInUnit - double[]; the values in the given unit
      unit - U; the unit in which the values are expressed and displayed
      storageType - StorageType; whether the vector is SPARSE or DENSE
      Returns:
      V; an instantiated DoubleVector with the values expressed in their unit
    • instantiate

      public static <U extends Unit<U>,​ S extends DoubleScalarInterface<U,​ S>,​ V extends DoubleVectorInterface<U,​ S,​ V>> V instantiate​(double[] valuesInUnit, U unit, StorageType storageType, Class<V> vectorClass)
      Instantiate the DoubleVector based on its unit. Rigid check on types for the compiler. The class for the vector is explicitly provided, e.g., for user-defined vector classes.
      Type Parameters:
      U - the unit type
      S - the corresponding scalar type
      V - the corresponding vector type
      Parameters:
      valuesInUnit - double[]; the values in the given unit
      unit - U; the unit in which the values are expressed and displayed
      storageType - StorageType; whether the vector is SPARSE or DENSE
      vectorClass - Class<V>; the class of the vector to instantiate
      Returns:
      V; an instantiated DoubleVector with the values expressed in their unit
    • instantiateSI

      public static <U extends Unit<U>,​ S extends DoubleScalarInterface<U,​ S>,​ V extends DoubleVectorInterface<U,​ S,​ V>> V instantiateSI​(double[] valuesSI, U displayUnit, StorageType storageType)
      Instantiate the DoubleVector based on its unit. Rigid check on types for the compiler.
      Type Parameters:
      U - the unit type
      S - the corresponding scalar type
      V - the corresponding vector type
      Parameters:
      valuesSI - double[]; the values in the SI unit
      displayUnit - U; the unit in which the values will be displayed
      storageType - StorageType; whether the vector is SPARSE or DENSE
      Returns:
      V; an instantiated DoubleVector with the values expressed in their unit
    • instantiateSI

      public static <U extends Unit<U>,​ S extends DoubleScalarInterface<U,​ S>,​ V extends DoubleVectorInterface<U,​ S,​ V>> V instantiateSI​(double[] valuesSI, U displayUnit, StorageType storageType, Class<V> vectorClass)
      Instantiate the DoubleVector based on its unit. Rigid check on types for the compiler. The class for the vector is explicitly provided, e.g., for user-defined vector classes.
      Type Parameters:
      U - the unit type
      S - the corresponding scalar type
      V - the corresponding vector type
      Parameters:
      valuesSI - double[]; the values in the SI unit
      displayUnit - U; the unit in which the values will be displayed
      storageType - StorageType; whether the vector is SPARSE or DENSE
      vectorClass - Class<V>; the class of the vector to instantiate
      Returns:
      V; an instantiated DoubleVector with the values expressed in their unit
    • instantiate

      public static <U extends Unit<U>,​ S extends DoubleScalarInterface<U,​ S>,​ V extends DoubleVectorInterface<U,​ S,​ V>> V instantiate​(S[] values, U displayUnit, StorageType storageType)
      Instantiate the DoubleVector based on its unit. Rigid check on types for the compiler.
      Type Parameters:
      U - the unit type
      S - the corresponding scalar type
      V - the corresponding vector type
      Parameters:
      values - S[]; the values
      displayUnit - U; the unit in which the values will be displayed
      storageType - StorageType; whether the vector is SPARSE or DENSE
      Returns:
      V; an instantiated DoubleVector with the values expressed in their unit
    • instantiate

      public static <U extends Unit<U>,​ S extends DoubleScalarInterface<U,​ S>,​ V extends DoubleVectorInterface<U,​ S,​ V>> V instantiate​(S[] values, U displayUnit, StorageType storageType, Class<V> vectorClass)
      Instantiate the DoubleVector based on its unit. Rigid check on types for the compiler. The class for the vector is explicitly provided, e.g., for user-defined vector classes.
      Type Parameters:
      U - the unit type
      S - the corresponding scalar type
      V - the corresponding vector type
      Parameters:
      values - S[]; the values
      displayUnit - U; the unit in which the values will be displayed
      storageType - StorageType; whether the vector is SPARSE or DENSE
      vectorClass - Class<V>; the class of the vector to instantiate
      Returns:
      V; an instantiated DoubleVector with the values expressed in their unit
    • instantiate

      public static <U extends Unit<U>,​ S extends DoubleScalarInterface<U,​ S>,​ V extends DoubleVectorInterface<U,​ S,​ V>> V instantiate​(List<Double> valueListInUnit, U unit, StorageType storageType) throws ValueRuntimeException
      Instantiate the DoubleVector based on its unit. Rigid check on types for the compiler.
      Type Parameters:
      U - the unit type
      S - the corresponding scalar type
      V - the corresponding vector type
      Parameters:
      valueListInUnit - List<Double>; the values in the given unit
      unit - U; the unit in which the values are expressed and displayed
      storageType - StorageType; whether the vector is SPARSE or DENSE
      Returns:
      V; an instantiated DoubleVector with the values expressed in their unit
      Throws:
      ValueRuntimeException - on vector init error
    • instantiate

      public static <U extends Unit<U>,​ S extends DoubleScalarInterface<U,​ S>,​ V extends DoubleVectorInterface<U,​ S,​ V>> V instantiate​(List<Double> valueListInUnit, U unit, StorageType storageType, Class<V> vectorClass) throws ValueRuntimeException
      Instantiate the DoubleVector based on its unit. Rigid check on types for the compiler. The class for the vector is explicitly provided, e.g., for user-defined vector classes.
      Type Parameters:
      U - the unit type
      S - the corresponding scalar type
      V - the corresponding vector type
      Parameters:
      valueListInUnit - List<Double>; the values in the given unit
      unit - U; the unit in which the values are expressed and displayed
      storageType - StorageType; whether the vector is SPARSE or DENSE
      vectorClass - Class<V>; the class of the vector to instantiate
      Returns:
      V; an instantiated DoubleVector with the values expressed in their unit
      Throws:
      ValueRuntimeException - on vector init error
    • instantiateSI

      public static <U extends Unit<U>,​ S extends DoubleScalarInterface<U,​ S>,​ V extends DoubleVectorInterface<U,​ S,​ V>> V instantiateSI​(List<Double> valueListSI, U displayUnit, StorageType storageType) throws ValueRuntimeException
      Instantiate the DoubleVector based on its unit. Rigid check on types for the compiler.
      Type Parameters:
      U - the unit type
      S - the corresponding scalar type
      V - the corresponding vector type
      Parameters:
      valueListSI - List<Double>; the values in the SI unit
      displayUnit - U; the unit in which the values will be displayed
      storageType - StorageType; whether the vector is SPARSE or DENSE
      Returns:
      V; an instantiated DoubleVector with the values expressed in their unit
      Throws:
      ValueRuntimeException - on vector init error
    • instantiateSI

      public static <U extends Unit<U>,​ S extends DoubleScalarInterface<U,​ S>,​ V extends DoubleVectorInterface<U,​ S,​ V>> V instantiateSI​(List<Double> valueListSI, U displayUnit, StorageType storageType, Class<V> vectorClass) throws ValueRuntimeException
      Instantiate the DoubleVector based on its unit. Rigid check on types for the compiler. The class for the vector is explicitly provided, e.g., for user-defined vector classes.
      Type Parameters:
      U - the unit type
      S - the corresponding scalar type
      V - the corresponding vector type
      Parameters:
      valueListSI - List<Double>; the values in the SI unit
      displayUnit - U; the unit in which the values will be displayed
      storageType - StorageType; whether the vector is SPARSE or DENSE
      vectorClass - Class<V>; the class of the vector to instantiate
      Returns:
      V; an instantiated DoubleVector with the values expressed in their unit
      Throws:
      ValueRuntimeException - on vector init error
    • instantiateList

      public static <U extends Unit<U>,​ S extends DoubleScalarInterface<U,​ S>,​ V extends DoubleVectorInterface<U,​ S,​ V>> V instantiateList​(List<S> valueList, U displayUnit, StorageType storageType)
      Instantiate the DoubleVector based on its unit. Rigid check on types for the compiler.
      Type Parameters:
      U - the unit type
      S - the corresponding scalar type
      V - the corresponding vector type
      Parameters:
      valueList - List<S>; the value list
      displayUnit - U; the unit in which the values will be displayed
      storageType - StorageType; whether the vector is SPARSE or DENSE
      Returns:
      V; an instantiated DoubleVector with the values expressed in their unit
    • instantiateList

      public static <U extends Unit<U>,​ S extends DoubleScalarInterface<U,​ S>,​ V extends DoubleVectorInterface<U,​ S,​ V>> V instantiateList​(List<S> valueList, U displayUnit, StorageType storageType, Class<V> vectorClass)
      Instantiate the DoubleVector based on its unit. Rigid check on types for the compiler. The class for the vector is explicitly provided, e.g., for user-defined vector classes.
      Type Parameters:
      U - the unit type
      S - the corresponding scalar type
      V - the corresponding vector type
      Parameters:
      valueList - List<S>; the value list
      displayUnit - U; the unit in which the values will be displayed
      storageType - StorageType; whether the vector is SPARSE or DENSE
      vectorClass - Class<V>; the class of the vector to instantiate
      Returns:
      V; an instantiated DoubleVector with the values expressed in their unit
    • instantiate

      public static <U extends Unit<U>,​ S extends DoubleScalarInterface<U,​ S>,​ V extends DoubleVectorInterface<U,​ S,​ V>> V instantiate​(SortedMap<Integer,​Double> valueMapInUnit, int length, U unit, StorageType storageType)
      Instantiate the DoubleVector based on its unit. Rigid check on types for the compiler.
      Type Parameters:
      U - the unit type
      S - the corresponding scalar type
      V - the corresponding vector type
      Parameters:
      valueMapInUnit - SortedMap<Integer, Double>; the values in the given unit
      length - int; the size of the vector
      unit - U; the unit in which the values are expressed and displayed
      storageType - StorageType; whether the vector is SPARSE or DENSE
      Returns:
      V; an instantiated DoubleVector with the values expressed in their unit
    • instantiate

      public static <U extends Unit<U>,​ S extends DoubleScalarInterface<U,​ S>,​ V extends DoubleVectorInterface<U,​ S,​ V>> V instantiate​(SortedMap<Integer,​Double> valueMapInUnit, int length, U unit, StorageType storageType, Class<V> vectorClass)
      Instantiate the DoubleVector based on its unit. Rigid check on types for the compiler. The class for the vector is explicitly provided, e.g., for user-defined vector classes.
      Type Parameters:
      U - the unit type
      S - the corresponding scalar type
      V - the corresponding vector type
      Parameters:
      valueMapInUnit - SortedMap<Integer, Double>; the values in the given unit
      length - int; the size of the vector
      unit - U; the unit in which the values are expressed and displayed
      storageType - StorageType; whether the vector is SPARSE or DENSE
      vectorClass - Class<V>; the class of the vector to instantiate
      Returns:
      V; an instantiated DoubleVector with the values expressed in their unit
    • instantiateSI

      public static <U extends Unit<U>,​ S extends DoubleScalarInterface<U,​ S>,​ V extends DoubleVectorInterface<U,​ S,​ V>> V instantiateSI​(SortedMap<Integer,​Double> valueMapSI, int length, U displayUnit, StorageType storageType)
      Instantiate the DoubleVector based on its unit. Rigid check on types for the compiler.
      Type Parameters:
      U - the unit type
      S - the corresponding scalar type
      V - the corresponding vector type
      Parameters:
      valueMapSI - SortedMap<Integer, Double>; the values in the SI unit
      length - int; the size of the vector
      displayUnit - U; the unit in which the values are displayed
      storageType - StorageType; whether the vector is SPARSE or DENSE
      Returns:
      V; an instantiated DoubleVector with the values expressed in their unit
    • instantiateSI

      public static <U extends Unit<U>,​ S extends DoubleScalarInterface<U,​ S>,​ V extends DoubleVectorInterface<U,​ S,​ V>> V instantiateSI​(SortedMap<Integer,​Double> valueMapSI, int length, U displayUnit, StorageType storageType, Class<V> vectorClass)
      Instantiate the DoubleVector based on its unit. Rigid check on types for the compiler. The class for the vector is explicitly provided, e.g., for user-defined vector classes.
      Type Parameters:
      U - the unit type
      S - the corresponding scalar type
      V - the corresponding vector type
      Parameters:
      valueMapSI - SortedMap<Integer, Double>; the values in the SI unit
      length - int; the size of the vector
      displayUnit - U; the unit in which the values are displayed
      storageType - StorageType; whether the vector is SPARSE or DENSE
      vectorClass - Class<V>; the class of the vector to instantiate
      Returns:
      V; an instantiated DoubleVector with the values expressed in their unit
    • instantiateMap

      public static <U extends Unit<U>,​ S extends DoubleScalarInterface<U,​ S>,​ V extends DoubleVectorInterface<U,​ S,​ V>> V instantiateMap​(SortedMap<Integer,​S> valueMap, int length, U displayUnit, StorageType storageType)
      Instantiate the DoubleVector based on its unit. Rigid check on types for the compiler.
      Type Parameters:
      U - the unit type
      S - the corresponding scalar type
      V - the corresponding vector type
      Parameters:
      valueMap - Map<Integer, S>; the value map
      displayUnit - U; the unit in which the values will be displayed
      length - int; the size of the vector
      storageType - StorageType; whether the vector is SPARSE or DENSE
      Returns:
      V; an instantiated DoubleVector with the values expressed in their unit
    • instantiateMap

      public static <U extends Unit<U>,​ S extends DoubleScalarInterface<U,​ S>,​ V extends DoubleVectorInterface<U,​ S,​ V>> V instantiateMap​(SortedMap<Integer,​S> valueMap, int length, U displayUnit, StorageType storageType, Class<V> vectorClass)
      Instantiate the DoubleVector based on its unit. Rigid check on types for the compiler. The class for the vector is explicitly provided, e.g., for user-defined vector classes.
      Type Parameters:
      U - the unit type
      S - the corresponding scalar type
      V - the corresponding vector type
      Parameters:
      valueMap - Map<Integer, S>; the value map
      displayUnit - U; the unit in which the values will be displayed
      length - int; the size of the vector
      storageType - StorageType; whether the vector is SPARSE or DENSE
      vectorClass - Class<V>; the class of the vector to instantiate
      Returns:
      V; an instantiated DoubleVector with the values expressed in their unit
    • instantiate

      public static <U extends Unit<U>,​ S extends DoubleScalarInterface<U,​ S>,​ V extends DoubleVectorInterface<U,​ S,​ V>> V instantiate​(DoubleVectorData values, U unit)
      Instantiate the Mutable DoubleVector based on its unit. Rigid check on types for the compiler.
      Type Parameters:
      U - the unit type
      S - the corresponding scalar type
      V - the corresponding vector type
      Parameters:
      values - DoubleVectorData; the values
      unit - U; the unit in which the values are expressed
      Returns:
      V; an instantiated mutable DoubleVector with the values expressed in their unit
    • instantiate

      public static <U extends Unit<U>,​ S extends DoubleScalarInterface<U,​ S>,​ V extends DoubleVectorInterface<U,​ S,​ V>> V instantiate​(DoubleVectorData values, U unit, Class<V> vectorClass)
      Instantiate the Mutable DoubleVector based on its unit. Rigid check on types for the compiler. The class for the vector is explicitly provided, e.g., for user-defined vector classes.
      Type Parameters:
      U - the unit type
      S - the corresponding scalar type
      V - the corresponding vector type
      Parameters:
      values - DoubleVectorData; the values
      unit - U; the unit in which the values are expressed
      vectorClass - Class<V>; the class of the vector to instantiate
      Returns:
      V; an instantiated mutable DoubleVector with the values expressed in their unit
    • instantiateAnonymous

      public static <U extends Unit<U>,​ S extends DoubleScalarInterface<U,​ S>,​ V extends DoubleVectorInterface<U,​ S,​ V>> V instantiateAnonymous​(DoubleVectorData values, Unit<?> unit)
      Instantiate the Immutable DoubleVector based on its unit. Loose check for types on the compiler. This allows the unit to be specified as a Unit<?> type.
      Note that it is possible to make mistakes with anonymous units.
      Type Parameters:
      U - the unit type
      S - the corresponding scalar type
      V - the corresponding vector type
      Parameters:
      values - DoubleVectorData; the values
      unit - Unit<?>; the unit in which the values are expressed
      Returns:
      V; an instantiated DoubleVector with the values expressed in their unit
    • instantiateAnonymous

      public static <U extends Unit<U>,​ S extends DoubleScalarInterface<U,​ S>,​ V extends DoubleVectorInterface<U,​ S,​ V>> V instantiateAnonymous​(DoubleVectorData values, Unit<?> unit, Class<V> vectorClass)
      Instantiate the Immutable DoubleVector based on its unit. Loose check for types on the compiler. This allows the unit to be specified as a Unit<?> type. The class for the vector is explicitly provided, e.g., for user-defined vector classes.
      Note that it is possible to make mistakes with anonymous units.
      Type Parameters:
      U - the unit type
      S - the corresponding scalar type
      V - the corresponding vector type
      Parameters:
      values - DoubleVectorData; the values
      unit - Unit<?>; the unit in which the values are expressed
      vectorClass - Class<V>; the class of the vector to instantiate
      Returns:
      V; an instantiated DoubleVector with the values expressed in their unit