Package org.djunits.vecmat.def
Class Table<Q extends Quantity<Q>,T extends Table<Q,T,SI,H,TT>,SI extends Table<SIQuantity,SI,?,?,?>,H extends Table<?,?,?,?,?>,TT extends Table<Q,TT,?,?,T>>
java.lang.Object
org.djunits.vecmat.def.VectorMatrix<Q,T,SI,H,TT>
org.djunits.vecmat.def.Table<Q,T,SI,H,TT>
- Type Parameters:
Q- the quantity typeT- the 'SELF' table typeSI- the table type with generics <SIQuantity, SIUnit<H- the generic table type with generics <?, ?< for Hadamard operationsTT- the type of the transposed version of the table
- All Implemented Interfaces:
Serializable,Additive<T>,Scalable<T>,Value<T,,Q> Hadamard<H,SI>
- Direct Known Subclasses:
Matrix,QuantityTable
public abstract class Table<Q extends Quantity<Q>,T extends Table<Q,T,SI,H,TT>,SI extends Table<SIQuantity,SI,?,?,?>,H extends Table<?,?,?,?,?>,TT extends Table<Q,TT,?,?,T>>
extends VectorMatrix<Q,T,SI,H,TT>
Table contains a number of standard operations on 2-dimensional tables of relative quantities. The Matrix and QuantityTable
are examples of classes that extends Table.
Copyright (c) 2025-2026 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://djunits.org. The DJUNITS project is distributed under a three-clause BSD-style license.
- Author:
- Alexander Verbraeck
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheckCol(int col) Check if the 0-based column is within bounds.protected voidcheckRow(int row) Check if the 0-based row is within bounds.get(int row, int col) Return the quantity at position (row, col), where both row and col are 0-based values.Q[]getColumnScalars(int col) Retrieve a column (0-based) from the table or matrix as an array of scalars.abstract double[]getColumnSi(int col) Return an array with SI-values for the given column (0-based) from the table or matrix.getColumnVector(int col) Return a quantity column (0-based) from the table or matrix.Q[]getRowScalars(int row) Retrieve a row (0-based) from the table or matrix as an array of scalars.abstract double[]getRowSi(int row) Return an array with SI-values for the given row (0-based) from the table or matrix.getRowVector(int row) Return a quantity row (0-based) from the table or matrix.Q[]Return a row-major array of quantities for this QuantityTable.Q[][]Return the table or matrix as a 2D array of scalars.double[][]Return the table or matrix as a 2D array of double SI values.protected voidmcheckCol(int mCol) Check if the 1-based column is within bounds.protected voidmcheckRow(int mRow) Check if the 1-based row is within bounds.mget(int mRow, int mCol) Return the quantity at position (row, col), where both row and col are 1-based values.Q[]mgetColumnScalars(int mCol) Retrieve a column (1-based) from the table or matrix as an array of scalars.double[]mgetColumnSi(int mCol) Return an array with SI-values for the given column (1-based) from the table or matrix.mgetColumnVector(int mCol) Return a quantity column (1-based) from the table or matrix.Q[]mgetRowScalars(int mRow) Retrieve a row (1-based) from the table or matrix as an array of scalars.double[]mgetRowSi(int mRow) Return an array with SI-values for the given row (1-based) from the table or matrix.mgetRowVector(int mRow) Return a quantity row (1-based) from the table or matrix.doublemsi(int mRow, int mCol) Return the si-value at position (row, col), where both row and col are 1-based values.abstract doublesi(int row, int col) Return the si-value at position (row, col), where both row and col are 0-based values.Methods inherited from class org.djunits.vecmat.def.VectorMatrix
abs, add, add, asMatrix1x1, asMatrix2x2, asMatrix3x3, asMatrixNxM, asMatrixNxN, asQuantityTable, asVector1, asVector2Col, asVector2Row, asVector3Col, asVector3Row, asVectorNCol, asVectorNRow, checkMultiply, checkMultiply, cols, divideElements, divideEntries, getDisplayUnit, getSiArray, instantiateSi, instantiateSi, invertEntries, isRelative, max, mean, median, min, multiplyElements, multiplyEntries, multiplyEntries, negate, nnz, nonZeroCount, rows, scaleBy, setDisplayUnit, subtract, subtract, sum, toString, transpose, unsafeSiArrayMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.djunits.vecmat.operations.Hadamard
divideEntriesMethods inherited from interface org.djunits.value.Value
format, format, isAbsolute, setDisplayUnit
-
Constructor Details
-
Table
Create a new Table with a unit.- Parameters:
displayUnit- the display unit to use
-
-
Method Details
-
si
Return the si-value at position (row, col), where both row and col are 0-based values.- Parameters:
row- the row (0-based)col- the column (0-based)- Returns:
- the si-value at position (row, col)
- Throws:
IndexOutOfBoundsException- when row or col < 0 or larger than number of rows/columns - 1.
-
msi
Return the si-value at position (row, col), where both row and col are 1-based values.- Parameters:
mRow- the row (1-based)mCol- the column (1-based)- Returns:
- the si-value at position (row, col)
- Throws:
IndexOutOfBoundsException- when row or col < 1 or larger than number of rows/columns.
-
get
Return the quantity at position (row, col), where both row and col are 0-based values.- Parameters:
row- the row (0-based)col- the column (0-based)- Returns:
- the quantity at position (row, col)
- Throws:
IndexOutOfBoundsException- when row or col < 0 or larger than number of rows/columns - 1.
-
mget
Return the quantity at position (row, col), where both row and col are 1-based values.- Parameters:
mRow- the row (1-based)mCol- the column (1-based)- Returns:
- the quantity at position (row, col)
- Throws:
IndexOutOfBoundsException- when row or col < 1 or larger than number of rows/columns.
-
getScalarArray
Return a row-major array of quantities for this QuantityTable.- Returns:
- a row-major array of quantities for this QuantityTable
-
getScalarGrid
Return the table or matrix as a 2D array of scalars.- Returns:
- a new Q[rows()][cols()] array; entry [i][j] contains get(i, j).
-
getSiGrid
public double[][] getSiGrid()Return the table or matrix as a 2D array of double SI values.- Returns:
- a new double[rows()][cols()] array; entry [i][j] contains si(i, j).
-
getRowVector
Return a quantity row (0-based) from the table or matrix. Note that the specific vector to return can be tightened by the implementing class.- Parameters:
row- the row number to retrieve (0-based)- Returns:
- a row vector with the data at the given row
-
mgetRowVector
Return a quantity row (1-based) from the table or matrix. Note that the specific vector to return can be tightened by the implementing class.- Parameters:
mRow- the row number to retrieve (1-based)- Returns:
- a row vector with the data at the given row
-
getColumnVector
Return a quantity column (0-based) from the table or matrix. Note that the specific vector to return can be tightened by the implementing class.- Parameters:
col- the column number to retrieve (0-based)- Returns:
- a column vector with the data at the given column
-
mgetColumnVector
Return a quantity column (1-based) from the table or matrix. Note that the specific vector to return can be tightened by the implementing class.- Parameters:
mCol- the column number to retrieve (1-based)- Returns:
- a column vector with the data at the given column
-
getRowSi
public abstract double[] getRowSi(int row) Return an array with SI-values for the given row (0-based) from the table or matrix.- Parameters:
row- the row number to retrieve (0-based)- Returns:
- an array with SI-values with the data at the given row
-
mgetRowSi
public double[] mgetRowSi(int mRow) Return an array with SI-values for the given row (1-based) from the table or matrix.- Parameters:
mRow- the row number to retrieve (1-based)- Returns:
- an array with SI-values with the data at the given row
-
getColumnSi
public abstract double[] getColumnSi(int col) Return an array with SI-values for the given column (0-based) from the table or matrix.- Parameters:
col- the column number to retrieve (0-based)- Returns:
- an array with SI-values with the data at the given column
-
mgetColumnSi
public double[] mgetColumnSi(int mCol) Return an array with SI-values for the given column (1-based) from the table or matrix.- Parameters:
mCol- the column number to retrieve (1-based)- Returns:
- an array with SI-values with the data at the given column
-
getRowScalars
Retrieve a row (0-based) from the table or matrix as an array of scalars.- Parameters:
row- row of the values to retrieve (0-based)- Returns:
- the row as a Scalar array
- Throws:
IndexOutOfBoundsException- in case row is out of bounds
-
mgetRowScalars
Retrieve a row (1-based) from the table or matrix as an array of scalars.- Parameters:
mRow- row of the values to retrieve (1-based)- Returns:
- the row as a Scalar array
- Throws:
IndexOutOfBoundsException- in case row is out of bounds
-
getColumnScalars
Retrieve a column (0-based) from the table or matrix as an array of scalars.- Parameters:
col- column of the values to retrieve (0-based)- Returns:
- the column as a Scalar array
- Throws:
IndexOutOfBoundsException- in case column is out of bounds
-
mgetColumnScalars
Retrieve a column (1-based) from the table or matrix as an array of scalars.- Parameters:
mCol- column of the values to retrieve (1-based)- Returns:
- the column as a Scalar array
- Throws:
IndexOutOfBoundsException- in case column is out of bounds
-
checkRow
protected void checkRow(int row) Check if the 0-based row is within bounds.- Parameters:
row- the 0-based row to check- Throws:
IndexOutOfBoundsException- when row is out of bounds
-
checkCol
protected void checkCol(int col) Check if the 0-based column is within bounds.- Parameters:
col- the 0-based column to check- Throws:
IndexOutOfBoundsException- when column is out of bounds
-
mcheckRow
protected void mcheckRow(int mRow) Check if the 1-based row is within bounds.- Parameters:
mRow- the 1-based row to check- Throws:
IndexOutOfBoundsException- when row is out of bounds
-
mcheckCol
protected void mcheckCol(int mCol) Check if the 1-based column is within bounds.- Parameters:
mCol- the 1-based column to check- Throws:
IndexOutOfBoundsException- when column is out of bounds
-