U
- the unitT
- the typepublic abstract class AbstractFloatVector<U extends Unit<U>,T extends AbstractFloatVector<U,T>> extends AbstractValue<U> implements FloatVectorInterface<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 FloatVectorData |
data
The stored data as an object, can be sparse or dense.
|
Constructor and Description |
---|
AbstractFloatVector(U unit,
FloatVectorData data)
Construct a new FloatVector.
|
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(AbstractFloatVector<U,?> other)
Centralized size equality check.
|
protected void |
checkSize(float[] other)
Centralized size equality check.
|
boolean |
equals(Object obj) |
abstract AbstractFloatScalar<U,?> |
get(int index)
Retrieve a value from the vector.
|
protected FloatVectorData |
getData() |
float |
getInUnit(int index)
Retrieve the value stored at a specified position in the original unit.
|
float |
getInUnit(int index,
U targetUnit)
Retrieve the value stored at a specified position converted into a specified unit.
|
float |
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.
|
float[] |
getValuesInUnit()
Create a float[] array filled with the values in the original unit.
|
float[] |
getValuesInUnit(U targetUnit)
Create a float[] array filled with the values converted into a specified unit.
|
float[] |
getValuesSI()
Create a float[] 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 FloatVector with optional type and unit information.
|
String |
toString(U displayUnit)
Print this FloatVector with the values expressed in the specified unit.
|
String |
toString(U displayUnit,
boolean verbose,
boolean withUnit)
Print this FloatVector with the values expressed in the specified unit.
|
float |
zSum()
Compute the sum of all values of this vector.
|
expressAsSIUnit, expressAsSpecifiedUnit, getUnit, isAbsolute, isRelative, setDisplayUnit
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
mutable, toDense, toSparse
protected FloatVectorData data
AbstractFloatVector(U unit, FloatVectorData data)
unit
- U; the unitdata
- FloatVectorData; an internal data objectprotected final FloatVectorData getData()
public final StorageType getStorageType()
public abstract AbstractFloatScalar<U,?> get(int index) throws ValueException
index
- int; the index to retrieve the value atValueException
- in case index is out of boundspublic final float[] getValuesSI()
getValuesSI
in interface FloatVectorInterface<U extends Unit<U>>
public final float[] getValuesInUnit()
getValuesInUnit
in interface FloatVectorInterface<U extends Unit<U>>
public final float[] getValuesInUnit(U targetUnit)
getValuesInUnit
in interface FloatVectorInterface<U extends Unit<U>>
targetUnit
- U; the unit into which the values are converted for usepublic final int size()
size
in interface FloatVectorInterface<U extends Unit<U>>
protected final void checkIndex(int index) throws ValueException
index
- int; the value to checkValueException
- when index is invalidpublic final float getSI(int index) throws ValueException
getSI
in interface FloatVectorInterface<U extends Unit<U>>
index
- int; index of the value to retrieveValueException
- when index out of range (index < 0 or index >= size())public final float getInUnit(int index) throws ValueException
getInUnit
in interface FloatVectorInterface<U extends Unit<U>>
index
- int; index of the value to retrieveValueException
- when index out of range (index < 0 or index >= size())public final float getInUnit(int index, U targetUnit) throws ValueException
getInUnit
in interface FloatVectorInterface<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 float zSum()
zSum
in interface FloatVectorInterface<U extends Unit<U>>
public final int cardinality()
cardinality
in interface FloatVectorInterface<U extends Unit<U>>
public final String toString()
public final String toString(U displayUnit)
toString
in interface FloatVectorInterface<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 FloatVectorInterface<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 FloatVectorInterface<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(AbstractFloatVector<U,?> other) throws ValueException
other
- AbstractFloatVector<U, ?>; other FloatVectorValueException
- when other is null, or vectors have unequal sizeprotected final void checkSize(float[] other) throws ValueException
other
- float[]; array of floatValueException
- when vectors have unequal sizeCopyright © 2015–2019 Delft University of Technology. All rights reserved.