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 type
T - the 'SELF' table type
SI - the table type with generics <SIQuantity, SIUnit<
H - the generic table type with generics <?, ?< for Hadamard operations
TT - 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 Details

    • Table

      public Table(Unit<?,Q> displayUnit)
      Create a new Table with a unit.
      Parameters:
      displayUnit - the display unit to use
  • Method Details

    • si

      public abstract double si(int row, int col) throws IndexOutOfBoundsException
      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

      public double msi(int mRow, int mCol) throws IndexOutOfBoundsException
      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

      public Q get(int row, int col) throws IndexOutOfBoundsException
      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

      public Q mget(int mRow, int mCol) throws IndexOutOfBoundsException
      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

      public Q[] getScalarArray()
      Return a row-major array of quantities for this QuantityTable.
      Returns:
      a row-major array of quantities for this QuantityTable
    • getScalarGrid

      public Q[][] 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

      public abstract Vector<Q,?,?,?,?> getRowVector(int row)
      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

      public abstract Vector<Q,?,?,?,?> mgetRowVector(int mRow)
      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

      public abstract Vector<Q,?,?,?,?> getColumnVector(int col)
      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

      public abstract Vector<Q,?,?,?,?> mgetColumnVector(int mCol)
      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

      public Q[] getRowScalars(int row) throws IndexOutOfBoundsException
      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

      public Q[] mgetRowScalars(int mRow) throws IndexOutOfBoundsException
      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

      public Q[] getColumnScalars(int col) throws IndexOutOfBoundsException
      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

      public Q[] mgetColumnScalars(int mCol) throws IndexOutOfBoundsException
      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