Class AbsVectorMatrix<A extends AbsQuantity<A,Q,?>,Q extends Quantity<Q>,VMA extends AbsVectorMatrix<A,Q,VMA,VMQ,VMAT>,VMQ extends VectorMatrix<Q,VMQ,?,?,?>,VMAT extends AbsVectorMatrix<A,Q,VMAT,?,VMA>>

java.lang.Object
org.djunits.vecmat.def.AbsVectorMatrix<A,Q,VMA,VMQ,VMAT>
Type Parameters:
A - the absolute quantity type
Q - the quantity type
VMA - the absolute vector or matrix type
VMQ - the relative vector or matrix type
VMAT - the type of the transposed version of the absolute vector or matrix
All Implemented Interfaces:
Serializable, Value<Q>
Direct Known Subclasses:
AbsTable, AbsVector

public abstract class AbsVectorMatrix<A extends AbsQuantity<A,Q,?>,Q extends Quantity<Q>,VMA extends AbsVectorMatrix<A,Q,VMA,VMQ,VMAT>,VMQ extends VectorMatrix<Q,VMQ,?,?,?>,VMAT extends AbsVectorMatrix<A,Q,VMAT,?,VMA>> extends Object implements Value<Q>
AbsVectorMatrix contains a number of standard operations on vectors and matrices of absolute quantities.

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

    • AbsVectorMatrix

      public AbsVectorMatrix(VMQ relativeVecMat, Reference<?,A,Q> reference)
      Create a new vector or matrix of absolute values with a reference point.
      Parameters:
      relativeVecMat - the underlying relative vector or matrix with SI values relative to the reference point
      reference - the reference point for the absolute values
  • Method Details

    • getDisplayUnit

      public UnitInterface<Q> getDisplayUnit()
      Description copied from interface: Value
      Retrieve the unit of this Value.
      Specified by:
      getDisplayUnit in interface Value<A extends AbsQuantity<A,Q,?>>
      Returns:
      the unit of this Value
    • rows

      public int rows()
      Return the number of rows.
      Returns:
      the number of rows
    • cols

      public int cols()
      Return the number of columns.
      Returns:
      the number of columns
    • instantiateSi

      public VMA instantiateSi(double[] siNew, Reference<?,A,Q> newReference, UnitInterface<Q> displayUnit)
      Return a new vector or matrix with the given SI or BASE values for the relative vector or matrix.
      Parameters:
      siNew - the values for the new vector or matrix in row-major format
      newReference - the reference point for the relative SI values
      displayUnit - the display unit of the data in the absolute vector or matrix
      Returns:
      a new matrix with the provided SI or BASE values
    • instantiate

      public abstract VMA instantiate(VMQ relVecMat, Reference<?,A,Q> newReference)
      Return a new vector or matrix with the given SI or BASE values for the relative vector or matrix. The absolute matrix uses the display unit of the relative vector or matrix.
      Parameters:
      relVecMat - the underlying relative vector or matrix with SI values relative to the reference point
      newReference - the reference point for the relative SI values
      Returns:
      a new matrix with the provided SI or BASE values, and the display unit of the relative vector or matrix
    • getRelativeVecMat

      public VMQ getRelativeVecMat()
      Return the underlying relative vector or matrix with SI values relative to the reference point.
      Returns:
      the underlying relative vector or matrix with SI values relative to the reference point
    • getReference

      public Reference<?,A,Q> getReference()
      Return the reference point for the absolute values.
      Returns:
      the reference point for the absolute values
    • transpose

      public abstract VMAT transpose()
      Return a transposed absolute vector or matrix, where rows and columns have been swapped.
      Returns:
      a transposed absolute vector or matrix, where rows and columns have been swapped
    • isRelative

      public boolean isRelative()
      Description copied from interface: Value
      Indicate whether this is a Relative Value.
      Specified by:
      isRelative in interface Value<A extends AbsQuantity<A,Q,?>>
      Returns:
      whether this is a Relative Value
    • 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
    • min

      public A min()
      Return the minimum value of the entries of the vector or matrix.
      Returns:
      the minimum value of the entries of the vector or matrix
    • max

      public A max()
      Return the maximum value of the entries of the vector or matrix.
      Returns:
      the maximum value of the entries of the vector or matrix
    • median

      public A median()
      Return the median value of the entries of the vector or matrix.
      Returns:
      the median value of the entries of the vector or matrix
    • add

      public VMA add(Q increment)
      Return a vector or matrix with entries that contain the sum of the element and the increment.
      Parameters:
      increment - the quantity by which to increase the values of the vector or matrix
      Returns:
      a vector or matrix with entries that are incremented by the given quantity
    • subtract

      public VMA subtract(Q decrement)
      Return a vector or matrix with entries that contain the value minus the decrement.
      Parameters:
      decrement - the quantity by which to decrease the values of the vector or matrix
      Returns:
      a vector or matrix with entries that are decremented by the given quantity
    • add

      public VMA add(VMQ other)
      Return a vector or matrix with entries that contain the sum of the element and the increment.
      Parameters:
      other - the vector or matrix that contains the values by which to increase the values of the vector or matrix
      Returns:
      a vector or matrix with entries that are decremented by the given quantity
    • subtract

      public VMA subtract(VMQ other)
      Return a vector or matrix with entries that contain the value minus the decrement.
      Parameters:
      other - the vector or matrix that contains the values by which to decrease the values of the vector or matrix
      Returns:
      a vector or matrix with entries that are decremented by the given vector or matrix values
    • subtract

      public VMQ subtract(VMA other)
      Return a relative vector or matrix with entries that contain the absolute value minus the absolute decrement.
      Parameters:
      other - the vector or matrix that contains the values by which to decrease the values of the vector or matrix
      Returns:
      a vector or matrix with entries that are decremented by the given vector or matrix values
    • subtract

      public VMQ subtract(A decrement)
      Return a relative vector or matrix with entries that contain the absolute value minus the absolute decrement.
      Parameters:
      decrement - the absolute quantity by which to decrease the values of the vector or matrix
      Returns:
      a vector or matrix with entries that are decremented by the given decrement
    • asAbsMatrixNxM

      public AbsMatrixNxM<A,Q> asAbsMatrixNxM()
      Convert this absolute vector or matrix to a AbsMatrixNxM. The underlying data MIGHT be shared between this object and the new AbsMatrixNxM.
      Returns:
      a AbsMatrixNxN with identical SI data, display unit, and reference point
    • asAbsQuantityTable

      public AbsQuantityTable<A,Q> asAbsQuantityTable()
      Convert this absolute vector or matrix to a AbsQuantityTable. The underlying data MIGHT be shared between this object and the new AbsQuantityTable.
      Returns:
      a AbsQuantityTable with identical SI data, display unit, and reference point
    • asAbsVector1

      public AbsVector1<A,Q> asAbsVector1()
      Return this absolute vector, matrix or table as a 1-element column vector. Shape must be 1 x 1.
      Returns:
      a AbsVector1 with identical SI data and display unit
      Throws:
      IllegalStateException - if shape is not 1 x 1
    • asAbsVector2Col

      public AbsVector2.Col<A,Q> asAbsVector2Col()
      Return this absolute vector, matrix or table as a 2-element column vector. Shape must be 2 x 1.
      Returns:
      a AbsVector2.Col with identical SI data and display unit
      Throws:
      IllegalStateException - if shape is not 2 x 1
    • asAbsVector3Col

      public AbsVector3.Col<A,Q> asAbsVector3Col()
      Return this absolute vector, matrix or table as a 3-element column vector. Shape must be 3 x 1.
      Returns:
      a AbsVector3.Col with identical SI data and display unit
      Throws:
      IllegalStateException - if shape is not 3 x 1
    • asAbsVectorNCol

      public AbsVectorN.Col<A,Q> asAbsVectorNCol()
      Convert this absolute vector, matrix or table to an N-element column vector. Shape must be N x 1. The underlying data MIGHT be shared between this object and the AbsVectorN.Col.
      Returns:
      a AbsVectorN.Col with identical SI data and display unit
      Throws:
      IllegalStateException - if cols() != 1
    • asAbsVector2Row

      public AbsVector2.Row<A,Q> asAbsVector2Row()
      Return this absolute vector, matrix or table as a 2-element row vector. Shape must be 1 x 2.
      Returns:
      a AbsVector2.Row with identical SI data and display unit
      Throws:
      IllegalStateException - if shape is not 1 x 2
    • asAbsVector3Row

      public AbsVector3.Row<A,Q> asAbsVector3Row()
      Return this absolute vector, matrix or table as a 3-element row vector. Shape must be 1 x 3.
      Returns:
      a AbsVector3.Row with identical SI data and display unit
      Throws:
      IllegalStateException - if shape is not 1 x 3
    • asAbsVectorNRow

      public AbsVectorN.Row<A,Q> asAbsVectorNRow()
      Convert this absolute vector, matrix or table to an N-element row vector. Shape must be 1 x N. The underlying data MIGHT be shared between this object and the AbsVectorN.Row.
      Returns:
      a AbsVectorN.Row with identical SI data and display unit
      Throws:
      IllegalStateException - if rows() != 1
    • asAbsMatrix1x1

      public AbsMatrix1x1<A,Q> asAbsMatrix1x1()
      Convert this absolute vector, matrix or table to a AbsMatrix1x1. The shape must be 1 x 1.
      Returns:
      a AbsMatrix1x1 with identical SI data and display unit
      Throws:
      IllegalStateException - if this matrix is not 1 x 1
    • asAbsMatrix2x2

      public AbsMatrix2x2<A,Q> asAbsMatrix2x2()
      Convert this absolute vector, matrix or table to a AbsMatrix2x2. The shape must be 2 x 2.
      Returns:
      a AbsMatrix2x2 with identical SI data and display unit
      Throws:
      IllegalStateException - if this matrix is not 2 x 2
    • asAbsMatrix3x3

      public AbsMatrix3x3<A,Q> asAbsMatrix3x3()
      Convert this absolute vector, matrix or table to a AbsMatrix3x3. The shape must be 3 x 3.
      Returns:
      a AbsMatrix3x3 with identical SI data and display unit
      Throws:
      IllegalStateException - if this matrix is not 3 x 3
    • asAbsMatrixNxN

      public AbsMatrixNxN<A,Q> asAbsMatrixNxN()
      Convert this absolute vector, matrix or table to a AbsMatrixNxN. The shape must be square. The underlying data MIGHT be shared between this object and the AbsMatrixNxN.
      Returns:
      a AbsMatrixNxN with identical SI data and display unit
      Throws:
      IllegalStateException - if this matrix is not square
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object