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-2020 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 Summary
Modifier and Type Method Description static <U extends Unit<U>, S extends DoubleScalarInterface<U, S>, V extends DoubleVectorInterface<U, S, V>>
Vinstantiate(double[] valuesInUnit, U unit, StorageType storageType)
Instantiate the DoubleVector based on its unit.static <U extends Unit<U>, S extends DoubleScalarInterface<U, S>, V extends DoubleVectorInterface<U, S, V>>
Vinstantiate(double[] valuesInUnit, U unit, StorageType storageType, Class<V> vectorClass)
Instantiate the DoubleVector based on its unit.static <U extends Unit<U>, S extends DoubleScalarInterface<U, S>, V extends DoubleVectorInterface<U, S, V>>
Vinstantiate(List<Double> valueListInUnit, U unit, StorageType storageType)
Instantiate the DoubleVector based on its unit.static <U extends Unit<U>, S extends DoubleScalarInterface<U, S>, V extends DoubleVectorInterface<U, S, V>>
Vinstantiate(List<Double> valueListInUnit, U unit, StorageType storageType, Class<V> vectorClass)
Instantiate the DoubleVector based on its unit.static <U extends Unit<U>, S extends DoubleScalarInterface<U, S>, V extends DoubleVectorInterface<U, S, V>>
Vinstantiate(SortedMap<Integer,Double> valueMapInUnit, int length, U unit, StorageType storageType)
Instantiate the DoubleVector based on its unit.static <U extends Unit<U>, S extends DoubleScalarInterface<U, S>, V extends DoubleVectorInterface<U, S, V>>
Vinstantiate(SortedMap<Integer,Double> valueMapInUnit, int length, U unit, StorageType storageType, Class<V> vectorClass)
Instantiate the DoubleVector based on its unit.static <U extends Unit<U>, S extends DoubleScalarInterface<U, S>, V extends DoubleVectorInterface<U, S, V>>
Vinstantiate(DoubleVectorData values, U unit)
Instantiate the Mutable DoubleVector based on its unit.static <U extends Unit<U>, S extends DoubleScalarInterface<U, S>, V extends DoubleVectorInterface<U, S, V>>
Vinstantiate(DoubleVectorData values, U unit, Class<V> vectorClass)
Instantiate the Mutable DoubleVector based on its unit.static <U extends Unit<U>, S extends DoubleScalarInterface<U, S>, V extends DoubleVectorInterface<U, S, V>>
Vinstantiate(S[] values, U displayUnit, StorageType storageType)
Instantiate the DoubleVector based on its unit.static <U extends Unit<U>, S extends DoubleScalarInterface<U, S>, V extends DoubleVectorInterface<U, S, V>>
Vinstantiate(S[] values, U displayUnit, StorageType storageType, Class<V> vectorClass)
Instantiate the DoubleVector based on its unit.static <U extends Unit<U>, S extends DoubleScalarInterface<U, S>, V extends DoubleVectorInterface<U, S, V>>
VinstantiateAnonymous(DoubleVectorData values, Unit<?> unit)
Instantiate the Immutable DoubleVector based on its unit.static <U extends Unit<U>, S extends DoubleScalarInterface<U, S>, V extends DoubleVectorInterface<U, S, V>>
VinstantiateAnonymous(DoubleVectorData values, Unit<?> unit, Class<V> vectorClass)
Instantiate the Immutable DoubleVector based on its unit.static <U extends Unit<U>, S extends DoubleScalarInterface<U, S>, V extends DoubleVectorInterface<U, S, V>>
VinstantiateList(List<S> valueList, U displayUnit, StorageType storageType)
Instantiate the DoubleVector based on its unit.static <U extends Unit<U>, S extends DoubleScalarInterface<U, S>, V extends DoubleVectorInterface<U, S, V>>
VinstantiateList(List<S> valueList, U displayUnit, StorageType storageType, Class<V> vectorClass)
Instantiate the DoubleVector based on its unit.static <U extends Unit<U>, S extends DoubleScalarInterface<U, S>, V extends DoubleVectorInterface<U, S, V>>
VinstantiateMap(SortedMap<Integer,S> valueMap, int length, U displayUnit, StorageType storageType)
Instantiate the DoubleVector based on its unit.static <U extends Unit<U>, S extends DoubleScalarInterface<U, S>, V extends DoubleVectorInterface<U, S, V>>
VinstantiateMap(SortedMap<Integer,S> valueMap, int length, U displayUnit, StorageType storageType, Class<V> vectorClass)
Instantiate the DoubleVector based on its unit.static <U extends Unit<U>, S extends DoubleScalarInterface<U, S>, V extends DoubleVectorInterface<U, S, V>>
VinstantiateSI(double[] valuesSI, U displayUnit, StorageType storageType)
Instantiate the DoubleVector based on its unit.static <U extends Unit<U>, S extends DoubleScalarInterface<U, S>, V extends DoubleVectorInterface<U, S, V>>
VinstantiateSI(double[] valuesSI, U displayUnit, StorageType storageType, Class<V> vectorClass)
Instantiate the DoubleVector based on its unit.static <U extends Unit<U>, S extends DoubleScalarInterface<U, S>, V extends DoubleVectorInterface<U, S, V>>
VinstantiateSI(List<Double> valueListSI, U displayUnit, StorageType storageType)
Instantiate the DoubleVector based on its unit.static <U extends Unit<U>, S extends DoubleScalarInterface<U, S>, V extends DoubleVectorInterface<U, S, V>>
VinstantiateSI(List<Double> valueListSI, U displayUnit, StorageType storageType, Class<V> vectorClass)
Instantiate the DoubleVector based on its unit.static <U extends Unit<U>, S extends DoubleScalarInterface<U, S>, V extends DoubleVectorInterface<U, S, V>>
VinstantiateSI(SortedMap<Integer,Double> valueMapSI, int length, U displayUnit, StorageType storageType)
Instantiate the DoubleVector based on its unit.static <U extends Unit<U>, S extends DoubleScalarInterface<U, S>, V extends DoubleVectorInterface<U, S, V>>
VinstantiateSI(SortedMap<Integer,Double> valueMapSI, int length, U displayUnit, StorageType storageType, Class<V> vectorClass)
Instantiate the DoubleVector based on its unit.
-
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 typeS
- the corresponding scalar typeV
- the corresponding vector type- Parameters:
valuesInUnit
- double[]; the values in the given unitunit
- U; the unit in which the values are expressed and displayedstorageType
- 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 typeS
- the corresponding scalar typeV
- the corresponding vector type- Parameters:
valuesInUnit
- double[]; the values in the given unitunit
- U; the unit in which the values are expressed and displayedstorageType
- StorageType; whether the vector is SPARSE or DENSEvectorClass
- 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 typeS
- the corresponding scalar typeV
- the corresponding vector type- Parameters:
valuesSI
- double[]; the values in the SI unitdisplayUnit
- U; the unit in which the values will be displayedstorageType
- 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 typeS
- the corresponding scalar typeV
- the corresponding vector type- Parameters:
valuesSI
- double[]; the values in the SI unitdisplayUnit
- U; the unit in which the values will be displayedstorageType
- StorageType; whether the vector is SPARSE or DENSEvectorClass
- 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 typeS
- the corresponding scalar typeV
- the corresponding vector type- Parameters:
values
- S[]; the valuesdisplayUnit
- U; the unit in which the values will be displayedstorageType
- 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 typeS
- the corresponding scalar typeV
- the corresponding vector type- Parameters:
values
- S[]; the valuesdisplayUnit
- U; the unit in which the values will be displayedstorageType
- StorageType; whether the vector is SPARSE or DENSEvectorClass
- 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 ValueRuntimeExceptionInstantiate the DoubleVector based on its unit. Rigid check on types for the compiler.- Type Parameters:
U
- the unit typeS
- the corresponding scalar typeV
- the corresponding vector type- Parameters:
valueListInUnit
- List<Double>; the values in the given unitunit
- U; the unit in which the values are expressed and displayedstorageType
- 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 ValueRuntimeExceptionInstantiate 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 typeS
- the corresponding scalar typeV
- the corresponding vector type- Parameters:
valueListInUnit
- List<Double>; the values in the given unitunit
- U; the unit in which the values are expressed and displayedstorageType
- StorageType; whether the vector is SPARSE or DENSEvectorClass
- 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 ValueRuntimeExceptionInstantiate the DoubleVector based on its unit. Rigid check on types for the compiler.- Type Parameters:
U
- the unit typeS
- the corresponding scalar typeV
- the corresponding vector type- Parameters:
valueListSI
- List<Double>; the values in the SI unitdisplayUnit
- U; the unit in which the values will be displayedstorageType
- 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 ValueRuntimeExceptionInstantiate 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 typeS
- the corresponding scalar typeV
- the corresponding vector type- Parameters:
valueListSI
- List<Double>; the values in the SI unitdisplayUnit
- U; the unit in which the values will be displayedstorageType
- StorageType; whether the vector is SPARSE or DENSEvectorClass
- 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 typeS
- the corresponding scalar typeV
- the corresponding vector type- Parameters:
valueList
- List<S>; the value listdisplayUnit
- U; the unit in which the values will be displayedstorageType
- 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 typeS
- the corresponding scalar typeV
- the corresponding vector type- Parameters:
valueList
- List<S>; the value listdisplayUnit
- U; the unit in which the values will be displayedstorageType
- StorageType; whether the vector is SPARSE or DENSEvectorClass
- 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 typeS
- the corresponding scalar typeV
- the corresponding vector type- Parameters:
valueMapInUnit
- SortedMap<Integer, Double>; the values in the given unitlength
- int; the size of the vectorunit
- U; the unit in which the values are expressed and displayedstorageType
- 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 typeS
- the corresponding scalar typeV
- the corresponding vector type- Parameters:
valueMapInUnit
- SortedMap<Integer, Double>; the values in the given unitlength
- int; the size of the vectorunit
- U; the unit in which the values are expressed and displayedstorageType
- StorageType; whether the vector is SPARSE or DENSEvectorClass
- 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 typeS
- the corresponding scalar typeV
- the corresponding vector type- Parameters:
valueMapSI
- SortedMap<Integer, Double>; the values in the SI unitlength
- int; the size of the vectordisplayUnit
- U; the unit in which the values are displayedstorageType
- 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 typeS
- the corresponding scalar typeV
- the corresponding vector type- Parameters:
valueMapSI
- SortedMap<Integer, Double>; the values in the SI unitlength
- int; the size of the vectordisplayUnit
- U; the unit in which the values are displayedstorageType
- StorageType; whether the vector is SPARSE or DENSEvectorClass
- 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 typeS
- the corresponding scalar typeV
- the corresponding vector type- Parameters:
valueMap
- SortedMap<Integer, S>; the value mapdisplayUnit
- U; the unit in which the values will be displayedlength
- int; the size of the vectorstorageType
- 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 typeS
- the corresponding scalar typeV
- the corresponding vector type- Parameters:
valueMap
- SortedMap<Integer, S>; the value mapdisplayUnit
- U; the unit in which the values will be displayedlength
- int; the size of the vectorstorageType
- StorageType; whether the vector is SPARSE or DENSEvectorClass
- 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 typeS
- the corresponding scalar typeV
- the corresponding vector type- Parameters:
values
- DoubleVectorData; the valuesunit
- 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 typeS
- the corresponding scalar typeV
- the corresponding vector type- Parameters:
values
- DoubleVectorData; the valuesunit
- U; the unit in which the values are expressedvectorClass
- 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 typeS
- the corresponding scalar typeV
- the corresponding vector type- Parameters:
values
- DoubleVectorData; the valuesunit
- 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 typeS
- the corresponding scalar typeV
- the corresponding vector type- Parameters:
values
- DoubleVectorData; the valuesunit
- Unit<?>; the unit in which the values are expressedvectorClass
- Class<V>; the class of the vector to instantiate- Returns:
- V; an instantiated DoubleVector with the values expressed in their unit
-