Class DoubleVectorDataDense
java.lang.Object
org.djunits.value.storage.AbstractStorage<DoubleVectorData>
org.djunits.value.vdouble.vector.data.DoubleVectorData
org.djunits.value.vdouble.vector.data.DoubleVectorDataDense
- All Implemented Interfaces:
Serializable
,Cloneable
public class DoubleVectorDataDense extends DoubleVectorData
Stores dense data for a DoubleVector and carries out basic operations.
Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
- Author:
- Alexander Verbraeck, Peter Knoppers
- See Also:
- Serialized Form
-
Field Summary
Fields inherited from class org.djunits.value.vdouble.vector.data.DoubleVectorData
PARALLEL_THRESHOLD, vectorSI
-
Constructor Summary
Constructors Constructor Description DoubleVectorDataDense(double[] vectorSI)
Create a vector with dense data. -
Method Summary
Modifier and Type Method Description DoubleVectorDataDense
assign(DoubleFunction doubleFunction)
Apply an operation to each cell.DoubleVectorDataDense
assign(DoubleFunction2 doubleFunction2, DoubleVectorData right)
Apply a binary operation on a cell by cell basis.int
cardinality()
Compute and return the number of non-zero cells in this indexed value.DoubleVectorDataDense
copy()
Create and return a deep copy of the data.DoubleVectorData
divide(DoubleVectorData right)
Divide two vectors on a cell-by-cell basis.double[]
getDenseVectorSI()
Create and return a dense copy of the data.double
getSI(int index)
Retrieve the SI value of one element of this data.DoubleVectorDataDense
minus(DoubleVectorData right)
Subtract two vectors on a cell-by-cell basis.DoubleVectorDataDense
plus(DoubleVectorData right)
Add two vectors on a cell-by-cell basis.void
setSI(int index, double valueSI)
Sets a value at the index in the vector.int
size()
Retrieve the size of the vector.DoubleVectorData
times(DoubleVectorData right)
Multiply two vectors on a cell-by-cell basis.DoubleVectorDataDense
toDense()
Return the densely stored equivalent of this data.DoubleVectorDataSparse
toSparse()
Return the sparsely stored equivalent of this data.Methods inherited from class org.djunits.value.vdouble.vector.data.DoubleVectorData
checkSizes, compareDenseVectorWithSparseVector, decrementBy, divideBy, divideBy, equals, hashCode, incrementBy, instantiate, instantiate, instantiate, instantiate, instantiateList, instantiateMap, multiplyBy, multiplyBy, toString, zSum
Methods inherited from class org.djunits.value.storage.AbstractStorage
getStorageType, isDense, isSparse
-
Constructor Details
-
DoubleVectorDataDense
public DoubleVectorDataDense(double[] vectorSI)Create a vector with dense data.- Parameters:
vectorSI
- double[]; the data to store
-
-
Method Details
-
cardinality
public final int cardinality()Compute and return the number of non-zero cells in this indexed value.- Specified by:
cardinality
in classAbstractStorage<DoubleVectorData>
- Returns:
- int; the number of non-zero cells
-
assign
Apply an operation to each cell.- Specified by:
assign
in classDoubleVectorData
- Parameters:
doubleFunction
- DoubleFunction; the operation to apply- Returns:
- DoubleVectorData; this (modified) double vector data object
-
assign
Apply a binary operation on a cell by cell basis.- Specified by:
assign
in classDoubleVectorData
- Parameters:
doubleFunction2
- DoubleFunction2; the binary operation to applyright
- DoubleVectorData; the right operand for the binary operation- Returns:
- DoubleVectorData; this (modified) double vector data object
-
toDense
Return the densely stored equivalent of this data.- Specified by:
toDense
in classDoubleVectorData
- Returns:
- DoubleVectorDataDense; the dense transformation of this data
-
toSparse
Return the sparsely stored equivalent of this data.- Specified by:
toSparse
in classDoubleVectorData
- Returns:
- DoubleVectorDataSparse; the sparse transformation of this data
-
size
public final int size()Retrieve the size of the vector.- Specified by:
size
in classDoubleVectorData
- Returns:
- int; the size of the vector
-
getSI
public final double getSI(int index)Retrieve the SI value of one element of this data.- Specified by:
getSI
in classDoubleVectorData
- Parameters:
index
- int; the index to get the value for- Returns:
- double; 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 classDoubleVectorData
- Parameters:
index
- int; the index to set the value forvalueSI
- double; the value at the index
-
getDenseVectorSI
public final double[] getDenseVectorSI()Create and return a dense copy of the data.- Specified by:
getDenseVectorSI
in classDoubleVectorData
- Returns:
- double[]; a safe copy of VectorSI
-
copy
Create and return a deep copy of the data.- Specified by:
copy
in classAbstractStorage<DoubleVectorData>
- Returns:
- T; a deep copy of the data
-
plus
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. Neither of the two objects is changed.- Specified by:
plus
in classDoubleVectorData
- Parameters:
right
- DoubleVectorData; the other data object to add- Returns:
- DoubleVectorData; the sum of this data object and the other data object as a new data object
-
minus
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. Neither of the two objects is changed.- Specified by:
minus
in classDoubleVectorData
- Parameters:
right
- DoubleVectorData; the other data object to subtract- Returns:
- DoubleVectorData; the difference of this data object and the other data object as a new data object
-
times
Multiply two vectors on a cell-by-cell basis. If both vectors are dense, a dense vector is returned, otherwise a sparse vector is returned.- Specified by:
times
in classDoubleVectorData
- Parameters:
right
- DoubleVectorData; the other data object to multiply with- Returns:
- DoubleVectorData; a new double vector data store holding the result of the multiplications
-
divide
Divide two vectors on a cell-by-cell basis. If this vector is sparse andright
is dense, a sparse vector is returned, otherwise a dense vector is returned.- Specified by:
divide
in classDoubleVectorData
- Parameters:
right
- DoubleVectorData; the other data object to divide by- Returns:
- DoubleVectorData; the ratios of the values of this data object and the other data object
-