U - Unit the unit for which this Vector will be createdpublic abstract class DoubleVector<U extends Unit<U>> extends AbstractValue<U> implements DoubleVectorInterface<U>, Serializable
Copyright (c) 2015 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See DJUNITS License.
$LastChangedDate: 2015-10-07 11:22:40 +0200 (Wed, 07 Oct 2015) $, @version $Revision: 90 $, by $Author: averbraeck $, initial
version 30 Oct, 2015
| Modifier and Type | Class and Description |
|---|---|
static class |
DoubleVector.Abs<U extends Unit<U>> |
static class |
DoubleVector.Rel<U extends Unit<U>> |
| Modifier and Type | Field and Description |
|---|---|
protected org.djunits.value.vdouble.vector.DoubleVectorData |
data
The stored data as an object, can be sparse or dense.
|
| Modifier | Constructor and Description |
|---|---|
protected |
DoubleVector(U unit)
Construct a new Absolute Immutable 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(double[] other)
Centralized size equality check.
|
protected void |
checkSize(DoubleVector<?> other)
Centralized size equality check.
|
boolean |
equals(Object obj) |
protected abstract org.djunits.value.vdouble.vector.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.
|
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() |
protected DoubleVectorDataSparse |
initializeSparse(SortedMap<Integer,Double> values,
int length)
Import the values from a sparse map of integers and values.
|
protected DoubleVectorDataSparse |
initializeSparseMA(SortedMap<Integer,DoubleScalar.Abs<U>> values,
int length)
Import the values from a sparse map of integers and values.
|
protected DoubleVectorDataSparse |
initializeSparseMR(SortedMap<Integer,DoubleScalar.Rel<U>> values,
int length)
Import the values from a sparse map of integers and values.
|
protected double |
safeGet(int index)
Retrieve a value in vectorSI without checking validity of the index.
|
protected void |
safeSet(int index,
double valueSI)
Modify a value in vectorSI without checking validity of the index.
|
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, isRelativeclone, finalize, getClass, notify, notifyAll, wait, wait, waitget, mutable, toDense, toSparseprotected org.djunits.value.vdouble.vector.DoubleVectorData data
protected DoubleVector(U unit)
unit - U; the unit of the new Absolute Immutable DoubleVectorprotected abstract org.djunits.value.vdouble.vector.DoubleVectorData getData()
protected final DoubleVectorDataSparse initializeSparse(SortedMap<Integer,Double> values, int length)
values - Map<Integer, Double>; the valueslength - the size of the vectorprotected final DoubleVectorDataSparse initializeSparseMA(SortedMap<Integer,DoubleScalar.Abs<U>> values, int length)
values - Map<Integer, Double>; the valueslength - the size of the vectorprotected final DoubleVectorDataSparse initializeSparseMR(SortedMap<Integer,DoubleScalar.Rel<U>> values, int length)
values - Map<Integer, Double>; the valueslength - the size of the vectorpublic 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(DoubleVector<?> other) throws ValueException
other - DoubleVector<?>; 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 sizeprotected final double safeGet(int index)
index - int; the indexprotected final void safeSet(int index,
double valueSI)
index - int; the indexvalueSI - double; the new value for the entry in vectorSICopyright © 2015 Delft University of Technology. All rights reserved.