U
- the unitT
- the typepublic abstract class AbstractDoubleVector<U extends Unit<U>,T extends AbstractDoubleVector<U,T>> extends AbstractValue<U> implements DoubleVectorInterface<U>
Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See DJUNITS License.
Modifier and Type | Field and Description |
---|---|
protected DoubleVectorData |
data
The stored data as an object, can be sparse or dense.
|
Constructor and Description |
---|
AbstractDoubleVector(U unit,
DoubleVectorData data)
Construct a new DoubleVector.
|
Modifier and Type | Method and Description |
---|---|
int |
cardinality()
Count the number of cells that have a non-zero value (ignores tolerance).
|
protected void |
checkIndex(int index)
Check that a provided index is valid.
|
protected void |
checkSize(AbstractDoubleVector<U,?> other)
Centralized size equality check.
|
protected void |
checkSize(double[] other)
Centralized size equality check.
|
boolean |
equals(Object obj) |
protected DoubleVectorData |
getData() |
double |
getInUnit(int index)
Retrieve the value stored at a specified position in the original unit.
|
double |
getInUnit(int index,
U targetUnit)
Retrieve the value stored at a specified position converted into a specified unit.
|
double |
getSI(int index)
Retrieve the value stored at a specified position in the standard SI unit.
|
StorageType |
getStorageType()
Return the StorageType (DENSE, SPARSE, etc.) for the stored Vector.
|
double[] |
getValuesInUnit()
Create a double[] array filled with the values in the original unit.
|
double[] |
getValuesInUnit(U targetUnit)
Create a double[] array filled with the values converted into a specified unit.
|
double[] |
getValuesSI()
Create a double[] array filled with the values in the standard SI unit.
|
int |
hashCode() |
int |
size()
Retrieve the size of the vector.
|
String |
toString() |
String |
toString(boolean verbose,
boolean withUnit)
Print this DoubleVector with optional type and unit information.
|
String |
toString(U displayUnit)
Print this DoubleVector with the values expressed in the specified unit.
|
String |
toString(U displayUnit,
boolean verbose,
boolean withUnit)
Print this DoubleVector with the values expressed in the specified unit.
|
double |
zSum()
Compute the sum of all values of this vector.
|
expressAsSIUnit, expressAsSpecifiedUnit, getUnit, isAbsolute, isRelative, setDisplayUnit
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
get, mutable, toDense, toSparse
protected DoubleVectorData data
AbstractDoubleVector(U unit, DoubleVectorData data)
unit
- U; the unitdata
- DoubleVectorData; an internal data objectprotected final DoubleVectorData getData()
public final StorageType getStorageType()
public final double[] getValuesSI()
getValuesSI
in interface DoubleVectorInterface<U extends Unit<U>>
public final double[] getValuesInUnit()
getValuesInUnit
in interface DoubleVectorInterface<U extends Unit<U>>
public final double[] getValuesInUnit(U targetUnit)
getValuesInUnit
in interface DoubleVectorInterface<U extends Unit<U>>
targetUnit
- U; the unit into which the values are converted for usepublic final int size()
size
in interface DoubleVectorInterface<U extends Unit<U>>
protected final void checkIndex(int index) throws ValueException
index
- int; the value to checkValueException
- when index is invalidpublic final double getSI(int index) throws ValueException
getSI
in interface DoubleVectorInterface<U extends Unit<U>>
index
- int; index of the value to retrieveValueException
- when index out of range (index < 0 or index >= size())public final double getInUnit(int index) throws ValueException
getInUnit
in interface DoubleVectorInterface<U extends Unit<U>>
index
- int; index of the value to retrieveValueException
- when index out of range (index < 0 or index >= size())public final double getInUnit(int index, U targetUnit) throws ValueException
getInUnit
in interface DoubleVectorInterface<U extends Unit<U>>
index
- int; index of the value to retrievetargetUnit
- U; the unit for the resultValueException
- when index out of range (index < 0 or index >= size())public final double zSum()
zSum
in interface DoubleVectorInterface<U extends Unit<U>>
public final int cardinality()
cardinality
in interface DoubleVectorInterface<U extends Unit<U>>
public final String toString()
public final String toString(U displayUnit)
toString
in interface DoubleVectorInterface<U extends Unit<U>>
displayUnit
- U; the unit into which the values are converted for displaypublic final String toString(boolean verbose, boolean withUnit)
toString
in interface DoubleVectorInterface<U extends Unit<U>>
verbose
- boolean; if true; include type info; if false; exclude type infowithUnit
- boolean; if true; include the unit; of false; exclude the unitpublic final String toString(U displayUnit, boolean verbose, boolean withUnit)
toString
in interface DoubleVectorInterface<U extends Unit<U>>
displayUnit
- U; the unit into which the values are converted for displayverbose
- boolean; if true; include type info; if false; exclude type infowithUnit
- boolean; if true; include the unit; of false; exclude the unitprotected final void checkSize(AbstractDoubleVector<U,?> other) throws ValueException
other
- AbstractDoubleVector<U, ?>; other DoubleVectorValueException
- when other is null, or vectors have unequal sizeprotected final void checkSize(double[] other) throws ValueException
other
- double[]; array of doubleValueException
- when vectors have unequal sizeCopyright © 2015–2019 Delft University of Technology. All rights reserved.