org.djunits.value.vdouble.vector

## Class DoubleVectorDataSparse

• ```public class DoubleVectorDataSparse
extends DoubleVectorData```
Stores sparse data for a DoubleVector and carries out basic operations.

\$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

• ### Fields inherited from class org.djunits.value.vdouble.vector.DoubleVectorData

`PARALLEL_THRESHOLD, vectorSI`
• ### Constructor Summary

Constructors
Constructor and Description
```DoubleVectorDataSparse(double[] vectorSI, int[] indices, int size)```
Create a vector with sparse data.
• ### Method Summary

All Methods
Modifier and Type Method and Description
`DoubleVectorDataSparse` `copy()`
`void` `decrementBy(DoubleVectorData right)`
Subtract a vector from this vector on a cell-by-cell basis.
`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)`
`double[]` `getDenseVectorSI()`
`double` `getSI(int index)`
`int` `hashCode()`
`void` `incrementBy(DoubleVectorData right)`
Add a vector to this vector on a cell-by-cell basis.
`static DoubleVectorDataSparse` `instantiate(double[] valuesSI)`
Instantiate a DoubleVectorDataSparse from an array.
`void` `multiplyBy(DoubleVectorData right)`
Multiply a vector with the values of another vector on a cell-by-cell basis.
`void` ```setSI(int index, double valueSI)```
Sets a value at the index in the vector.
`int` `size()`
`DoubleVectorDataDense` `toDense()`
• ### Methods inherited from class org.djunits.value.vdouble.vector.DoubleVectorData

`cardinality, decrementBy, divide, divideBy, getStorageType, incrementBy, instantiate, instantiate, instantiate, instantiate, instantiateLD, instantiateMD, isDense, isSparse, minus, multiplyBy, plus, times, toSparse, toString, zSum`
• ### Methods inherited from class java.lang.Object

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

• #### DoubleVectorDataSparse

```public DoubleVectorDataSparse(double[] vectorSI,
int[] indices,
int size)```
Create a vector with sparse data.
Parameters:
`vectorSI` - the data to store
`indices` - the index values of the Vector
`size` - the length of the vector (padded with 0 after highest index in indices)
• ### Method Detail

• #### toDense

`public final DoubleVectorDataDense toDense()`
Overrides:
`toDense` in class `DoubleVectorData`
Returns:
the dense transformation of this data
• #### size

`public final int size()`
Specified by:
`size` in class `DoubleVectorData`
Returns:
the size of the vector
• #### getSI

`public final double getSI(int index)`
Specified by:
`getSI` in class `DoubleVectorData`
Parameters:
`index` - the index to get the value for
Returns:
the value at the index
• #### setSI

```public final void setSI(int index,
double valueSI)```
Sets a value at the index in the vector.
Specified by:
`setSI` in class `DoubleVectorData`
Parameters:
`index` - the index to set the value for
`valueSI` - the value at the index
• #### getDenseVectorSI

`public final double[] getDenseVectorSI()`
Specified by:
`getDenseVectorSI` in class `DoubleVectorData`
Returns:
a safe copy of VectorSI
• #### copy

`public final DoubleVectorDataSparse copy()`
Specified by:
`copy` in class `DoubleVectorData`
Returns:
a deep copy of the data.
• #### instantiate

`public static DoubleVectorDataSparse instantiate(double[] valuesSI)`
Instantiate a DoubleVectorDataSparse from an array.
Parameters:
`valuesSI` - the (SI) values to store
Returns:
the DoubleVectorDataSparse
• #### incrementBy

```public final 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.
Specified by:
`incrementBy` in class `DoubleVectorData`
Parameters:
`right` - the other data object to add
Throws:
`ValueException` - if vectors have different lengths
• #### decrementBy

```public final 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.
Specified by:
`decrementBy` in class `DoubleVectorData`
Parameters:
`right` - the other data object to subtract
Throws:
`ValueException` - if vectors have different lengths
• #### multiplyBy

```public final 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.
Specified by:
`multiplyBy` in class `DoubleVectorData`
Parameters:
`right` - the other data object to multiply with
Throws:
`ValueException` - if vectors have different lengths
• #### divideBy

```public final 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.
Specified by:
`divideBy` in class `DoubleVectorData`
Parameters:
`right` - the other data object to divide by
Throws:
`ValueException` - if vectors have different lengths
• #### hashCode

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

`public boolean equals(Object obj)`
Overrides:
`equals` in class `DoubleVectorData`