org.djunits.value.vdouble.vector

## Class DoubleVectorData

• Direct Known Subclasses:

```abstract class DoubleVectorData
extends Object```
Stores the data for a DoubleVector and carries out basic operations.

Copyright (c) 2013-2017 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.

\$LastChangedDate: 2015-07-24 02:58:59 +0200 (Fri, 24 Jul 2015) \$, @version \$Revision: 1147 \$, by \$Author: averbraeck \$, initial version Oct 3, 2015
Author:
Alexander Verbraeck, Peter Knoppers
• ### Field Summary

Fields
Modifier and Type Field and Description
`protected static int` `PARALLEL_THRESHOLD`
threshold to do parallel execution.
`protected double[]` `vectorSI`
the internal storage of the Vector; can be sparse or dense.
• ### Constructor Summary

Constructors
Constructor and Description
`DoubleVectorData(StorageType storageType)`
• ### Method Summary

All Methods
Modifier and Type Method and Description
`int` `cardinality()`
`abstract DoubleVectorData` `copy()`
`void` `decrementBy(double valueSI)`
Subtract a number from this vector on a cell-by-cell basis.
`abstract void` `decrementBy(DoubleVectorData right)`
Subtract a vector from this vector on a cell-by-cell basis.
`DoubleVectorData` `divide(DoubleVectorData right)`
Divide two vectors on a cell-by-cell basis.
`void` `divideBy(double valueSI)`
Divide the values of this vector by a number on a cell-by-cell basis.
`abstract void` `divideBy(DoubleVectorData right)`
Divide the values of a vector by the values of another vector on a cell-by-cell basis.
`boolean` `equals(Object obj)`
`abstract double[]` `getDenseVectorSI()`
`abstract double` `getSI(int index)`
`StorageType` `getStorageType()`
Return the StorageType (DENSE, SPARSE, etc.) for the stored Vector.
`int` `hashCode()`
`void` `incrementBy(double valueSI)`
Add a number to this vector on a cell-by-cell basis.
`abstract void` `incrementBy(DoubleVectorData right)`
Add a vector to this vector on a cell-by-cell basis.
`static DoubleVectorData` ```instantiate(double[] values, Scale scale, StorageType storageType)```
Instantiate a DoubleVectorData with the right data type.
`static DoubleVectorData` ```instantiate(DoubleScalarInterface[] values, StorageType storageType)```
Instantiate a DoubleVectorData with the right data type.
`static DoubleVectorData` ```instantiate(List<Double> values, Scale scale, StorageType storageType)```
Instantiate a DoubleVectorData with the right data type.
`static DoubleVectorData` ```instantiate(SortedMap<Integer,Double> values, int length, Scale scale, StorageType storageType)```
Instantiate a DoubleVectorData with the right data type.
`static DoubleVectorData` ```instantiateLD(List<? extends DoubleScalarInterface> values, StorageType storageType)```
Instantiate a DoubleVectorData with the right data type.
`static <S extends DoubleScalarInterface>DoubleVectorData` ```instantiateMD(SortedMap<Integer,S> values, int length, StorageType storageType)```
Instantiate a DoubleVectorData with the right data type.
`boolean` `isDense()`
`boolean` `isSparse()`
`DoubleVectorData` `minus(DoubleVectorData right)`
Subtract two vectors on a cell-by-cell basis.
`void` `multiplyBy(double valueSI)`
Multiply the values of this vector with a number on a cell-by-cell basis.
`abstract void` `multiplyBy(DoubleVectorData right)`
Multiply a vector with the values of another vector on a cell-by-cell basis.
`DoubleVectorData` `plus(DoubleVectorData right)`
Add two vectors on a cell-by-cell basis.
`abstract void` ```setSI(int index, double valueSI)```
Sets a value at the index in the vector.
`abstract int` `size()`
`DoubleVectorData` `times(DoubleVectorData right)`
Multiply two vector on a cell-by-cell basis.
`DoubleVectorDataDense` `toDense()`
`DoubleVectorDataSparse` `toSparse()`
`String` `toString()`
`double` `zSum()`
• ### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`
• ### Field Detail

• #### vectorSI

`protected double[] vectorSI`
the internal storage of the Vector; can be sparse or dense.
• #### PARALLEL_THRESHOLD

`protected static final int PARALLEL_THRESHOLD`
threshold to do parallel execution.
Constant Field Values
• ### Constructor Detail

• #### DoubleVectorData

`DoubleVectorData(StorageType storageType)`
Parameters:
`storageType` - the data type.
• ### Method Detail

• #### instantiate

```public static DoubleVectorData instantiate(double[] values,
Scale scale,
StorageType storageType)
throws ValueException```
Instantiate a DoubleVectorData with the right data type.
Parameters:
`values` - the (SI) values to store
`scale` - the scale of the unit to use for conversion to SI
`storageType` - the data type to use
Returns:
the DoubleVectorData with the right data type
Throws:
`ValueException` - when values are null, or storageType is null
• #### instantiate

```public static DoubleVectorData instantiate(List<Double> values,
Scale scale,
StorageType storageType)
throws ValueException```
Instantiate a DoubleVectorData with the right data type.
Parameters:
`values` - the values to store
`scale` - the scale of the unit to use for conversion to SI
`storageType` - the data type to use
Returns:
the DoubleVectorData with the right data type
Throws:
`ValueException` - when list is null, or storageType is null
• #### instantiate

```public static DoubleVectorData instantiate(DoubleScalarInterface[] values,
StorageType storageType)
throws ValueException```
Instantiate a DoubleVectorData with the right data type.
Parameters:
`values` - the values to store
`storageType` - the data type to use
Returns:
the DoubleVectorData with the right data type
Throws:
`ValueException` - when values is null, or storageType is null
• #### instantiateLD

```public static DoubleVectorData instantiateLD(List<? extends DoubleScalarInterface> values,
StorageType storageType)
throws ValueException```
Instantiate a DoubleVectorData with the right data type.
Parameters:
`values` - the DoubleScalar values to store
`storageType` - the data type to use
Returns:
the DoubleVectorData with the right data type
Throws:
`ValueException` - when values is null, or storageType is null
• #### instantiateMD

```public static <S extends DoubleScalarInterface> DoubleVectorData instantiateMD(SortedMap<Integer,S> values,
int length,
StorageType storageType)
throws ValueException```
Instantiate a DoubleVectorData with the right data type.
Type Parameters:
`S` - the scalar type to use
Parameters:
`values` - the DoubleScalar values to store
`length` - the length of the vector to pad with 0 after last entry in map
`storageType` - the data type to use
Returns:
the DoubleVectorData with the right data type
Throws:
`ValueException` - when values is null, or storageType is null
• #### instantiate

```public static DoubleVectorData instantiate(SortedMap<Integer,Double> values,
int length,
Scale scale,
StorageType storageType)
throws ValueException```
Instantiate a DoubleVectorData with the right data type.
Parameters:
`values` - the DoubleScalar values to store
`length` - the length of the vector to pad with 0 after last entry in map
`scale` - the scale of the unit to use for conversion to SI
`storageType` - the data type to use
Returns:
the DoubleVectorData with the right data type
Throws:
`ValueException` - when values is null, or storageType is null
• #### getStorageType

`public final StorageType getStorageType()`
Return the StorageType (DENSE, SPARSE, etc.) for the stored Vector.
Returns:
the StorageType (DENSE, SPARSE, etc.) for the stored Vector
• #### size

`public abstract int size()`
Returns:
the size of the vector
• #### isSparse

`public boolean isSparse()`
Returns:
whether data type is sparse.
• #### toSparse

`public DoubleVectorDataSparse toSparse()`
Returns:
the sparse transformation of this data
• #### isDense

`public boolean isDense()`
Returns:
whether data type is dense.
• #### toDense

`public DoubleVectorDataDense toDense()`
Returns:
the dense transformation of this data
• #### getSI

`public abstract double getSI(int index)`
Parameters:
`index` - the index to get the value for
Returns:
the value at the index
• #### setSI

```public abstract void setSI(int index,
double valueSI)```
Sets a value at the index in the vector.
Parameters:
`index` - the index to set the value for
`valueSI` - the value at the index
• #### cardinality

`public final int cardinality()`
Returns:
the number of non-zero cells.
• #### zSum

`public final double zSum()`
Returns:
the sum of the values of all cells.
• #### copy

`public abstract DoubleVectorData copy()`
Returns:
a deep copy of the data.
• #### getDenseVectorSI

`public abstract double[] getDenseVectorSI()`
Returns:
a safe copy of VectorSI
• #### plus

```public DoubleVectorData plus(DoubleVectorData right)
throws ValueException```
Add two vectors on a cell-by-cell basis. If both vectors are sparse, a sparse vector is returned, otherwise a dense vector is returned.
Parameters:
`right` - the other data object to add
Returns:
the sum of this data object and the other data object
Throws:
`ValueException` - if vectors have different lengths
• #### incrementBy

```public abstract void incrementBy(DoubleVectorData right)
throws ValueException```
Add a vector to this vector on a cell-by-cell basis. The type of vector (sparse, dense) stays the same.
Parameters:
`right` - the other data object to add
Throws:
`ValueException` - if vectors have different lengths
• #### incrementBy

`public void incrementBy(double valueSI)`
Add a number to this vector on a cell-by-cell basis.
Parameters:
`valueSI` - the value to add
• #### minus

```public DoubleVectorData minus(DoubleVectorData right)
throws ValueException```
Subtract two vectors on a cell-by-cell basis. If both vectors are sparse, a sparse vector is returned, otherwise a dense vector is returned.
Parameters:
`right` - the other data object to subtract
Returns:
the sum of this data object and the other data object
Throws:
`ValueException` - if vectors have different lengths
• #### decrementBy

```public abstract void decrementBy(DoubleVectorData right)
throws ValueException```
Subtract a vector from this vector on a cell-by-cell basis. The type of vector (sparse, dense) stays the same.
Parameters:
`right` - the other data object to subtract
Throws:
`ValueException` - if vectors have different lengths
• #### decrementBy

`public void decrementBy(double valueSI)`
Subtract a number from this vector on a cell-by-cell basis.
Parameters:
`valueSI` - the value to subtract
• #### times

```public DoubleVectorData times(DoubleVectorData right)
throws ValueException```
Multiply two vector on a cell-by-cell basis. If both vectors are dense, a dense vector is returned, otherwise a sparse vector is returned.
Parameters:
`right` - the other data object to multiply with
Returns:
the sum of this data object and the other data object
Throws:
`ValueException` - if vectors have different lengths
• #### multiplyBy

```public abstract void multiplyBy(DoubleVectorData right)
throws ValueException```
Multiply a vector with the values of another vector on a cell-by-cell basis. The type of vector (sparse, dense) stays the same.
Parameters:
`right` - the other data object to multiply with
Throws:
`ValueException` - if vectors have different lengths
• #### multiplyBy

`public void multiplyBy(double valueSI)`
Multiply the values of this vector with a number on a cell-by-cell basis.
Parameters:
`valueSI` - the value to multiply with
• #### divide

```public DoubleVectorData divide(DoubleVectorData right)
throws ValueException```
Divide two vectors on a cell-by-cell basis. If both vectors are dense, a dense vector is returned, otherwise a sparse vector is returned.
Parameters:
`right` - the other data object to divide by
Returns:
the sum of this data object and the other data object
Throws:
`ValueException` - if vectors have different lengths
• #### divideBy

```public abstract void divideBy(DoubleVectorData right)
throws ValueException```
Divide the values of a vector by the values of another vector on a cell-by-cell basis. The type of vector (sparse, dense) stays the same.
Parameters:
`right` - the other data object to divide by
Throws:
`ValueException` - if vectors have different lengths
• #### divideBy

`public void divideBy(double valueSI)`
Divide the values of this vector by a number on a cell-by-cell basis.
Parameters:
`valueSI` - the value to multiply with
• #### hashCode

`public int hashCode()`
Overrides:
`hashCode` in class `Object`
• #### equals

`public boolean equals(Object obj)`
Overrides:
`equals` in class `Object`
• #### toString

`public String toString()`
Overrides:
`toString` in class `Object`