U
- the unitT
- the typepublic abstract class AbstractDoubleMatrix<U extends Unit<U>,T extends AbstractDoubleMatrix<U,T>> extends AbstractValue<U> implements DoubleMatrixInterface<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 DoubleMatrixData |
data
The stored data as an object, can be sparse or dense.
|
Constructor and Description |
---|
AbstractDoubleMatrix(U unit,
DoubleMatrixData data)
Construct a new DoubleMatrix.
|
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 row,
int column)
Check that provided row and column indices are valid.
|
protected void |
checkSize(AbstractDoubleMatrixRel<?,?,?,?> other)
Centralized size equality check.
|
protected void |
checkSize(double[][] other)
Centralized size equality check.
|
int |
columns()
Retrieve the number of columns of the matrix.
|
double |
determinant()
Compute the determinant of the matrix.
|
protected static double[][] |
ensureRectangularAndNonEmpty(double[][] values)
Check that a 2D array of double is not null and rectangular; i.e.
|
boolean |
equals(Object obj) |
protected DoubleMatrixData |
getData() |
double |
getInUnit(int row,
int column)
Retrieve the value stored at a specified row and column in the original unit.
|
double |
getInUnit(int row,
int column,
U targetUnit)
Retrieve the value stored at a specified row and column converted into a specified unit.
|
double |
getSI(int row,
int column)
Retrieve the value stored at a specified row and column in the standard SI unit.
|
StorageType |
getStorageType()
Return the StorageType (DENSE, SPARSE, etc.) for the stored Matrix.
|
double[][] |
getValuesInUnit()
Create a dense double[][] array filled with the values in the original unit.
|
double[][] |
getValuesInUnit(U targetUnit)
Create a dense double[][] array filled with the values converted into a specified unit.
|
double[][] |
getValuesSI()
Create a dense double[][] array filled with the values in the standard SI unit.
|
int |
hashCode() |
int |
rows()
Retrieve the number of rows of the matrix.
|
String |
toString() |
String |
toString(boolean verbose,
boolean withUnit)
Print this DoubleMatrix with optional type and unit information.
|
String |
toString(U displayUnit)
Print this DoubleMatrix with the values expressed in the specified unit.
|
String |
toString(U displayUnit,
boolean verbose,
boolean withUnit)
Print this DoubleMatrix with the values expressed in the specified unit.
|
double |
zSum()
Compute the sum of all values of this matrix.
|
expressAsSIUnit, expressAsSpecifiedUnit, getUnit, isAbsolute, isRelative, setDisplayUnit
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
get, toDense, toSparse
protected DoubleMatrixData data
AbstractDoubleMatrix(U unit, DoubleMatrixData data)
unit
- U; the unitdata
- DoubleMatrixData; an internal data objectprotected final DoubleMatrixData getData()
public final StorageType getStorageType()
public final double[][] getValuesSI()
getValuesSI
in interface DoubleMatrixInterface<U extends Unit<U>>
public final double[][] getValuesInUnit()
getValuesInUnit
in interface DoubleMatrixInterface<U extends Unit<U>>
public final double[][] getValuesInUnit(U targetUnit)
getValuesInUnit
in interface DoubleMatrixInterface<U extends Unit<U>>
targetUnit
- U; the unit into which the values are converted for usepublic final int rows()
rows
in interface DoubleMatrixInterface<U extends Unit<U>>
public final int columns()
columns
in interface DoubleMatrixInterface<U extends Unit<U>>
public final double getSI(int row, int column) throws ValueException
getSI
in interface DoubleMatrixInterface<U extends Unit<U>>
row
- int; row of the value to retrievecolumn
- int; column of the value to retrieveValueException
- when row or column out of range (row < 0 or row >= rows() or column < 0 or column >=
columns())public final double getInUnit(int row, int column) throws ValueException
getInUnit
in interface DoubleMatrixInterface<U extends Unit<U>>
row
- int; row of the value to retrievecolumn
- int; column of the value to retrieveValueException
- when row or column out of range (row < 0 or row >= rows() or column < 0 or column >=
columns())public final double getInUnit(int row, int column, U targetUnit) throws ValueException
getInUnit
in interface DoubleMatrixInterface<U extends Unit<U>>
row
- int; row of the value to retrievecolumn
- int; column of the value to retrievetargetUnit
- U; the unit for the resultValueException
- when row or column out of range (row < 0 or row >= rows() or column < 0 or column >=
columns())public final double zSum()
zSum
in interface DoubleMatrixInterface<U extends Unit<U>>
public final int cardinality()
cardinality
in interface DoubleMatrixInterface<U extends Unit<U>>
public final String toString()
public final String toString(U displayUnit)
toString
in interface DoubleMatrixInterface<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 DoubleMatrixInterface<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 DoubleMatrixInterface<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(AbstractDoubleMatrixRel<?,?,?,?> other) throws ValueException
other
- AbstractDoubleMatrixRel<?, ?, ?, ?>; other DoubleMatrixValueException
- when other is null, or matrices have unequal sizeprotected static double[][] ensureRectangularAndNonEmpty(double[][] values) throws ValueException
values
- double[][]; the 2D array to checkValueException
- when not all rows have the same lengthprotected final void checkSize(double[][] other) throws ValueException
other
- double[][]; array of doubleValueException
- when matrices have unequal sizeprotected final void checkIndex(int row, int column) throws ValueException
row
- int; the row value to checkcolumn
- int; the column value to checkValueException
- when row or column is invalidpublic final double determinant() throws ValueException
determinant
in interface DoubleMatrixInterface<U extends Unit<U>>
ValueException
- when matrix is neither sparse, nor dense, or not squareCopyright © 2015–2019 Delft University of Technology. All rights reserved.