Class Matrix1x1<Q extends Quantity<Q>>

Type Parameters:
Q - the quantity type
All Implemented Interfaces:
Serializable, Additive<Matrix1x1<Q>>, Scalable<Matrix1x1<Q>>, Value<Matrix1x1<Q>,Q>, Hadamard<Matrix1x1<?>,Matrix1x1<SIQuantity>>

public class Matrix1x1<Q extends Quantity<Q>> extends SquareDenseMatrix<Q,Matrix1x1<Q>,Matrix1x1<SIQuantity>,Matrix1x1<?>>
Matrix1x1 implements a matrix with 1x1 real-valued entries. The matrix is immutable, except for the display unit, which can be changed.

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

    • Matrix1x1

      protected Matrix1x1(double[] dataSi, Unit<?,Q> displayUnit)
      Create a new Matrix1x1 with a display unit.
      Parameters:
      dataSi - the matrix values {a11} expressed in the SI unit
      displayUnit - the display unit for the matrix
  • Method Details

    • instantiateSi

      public Matrix1x1<Q> instantiateSi(double[] siNew)
      Description copied from class: VectorMatrix
      Return a new vector or matrix with the given SI or BASE values.
      Specified by:
      instantiateSi in class VectorMatrix<Q extends Quantity<Q>,Matrix1x1<Q extends Quantity<Q>>,Matrix1x1<SIQuantity>,Matrix1x1<?>,Matrix1x1<Q extends Quantity<Q>>>
      Parameters:
      siNew - the values for the new vector or matrix in row-major format
      Returns:
      a new matrix with the provided SI or BASE values
    • instantiateSi

      public Matrix1x1<SIQuantity> instantiateSi(double[] siNew, SIUnit siUnit)
      Description copied from class: VectorMatrix
      Return a new vector or matrix in SI-units with the given SI or BASE values.
      Specified by:
      instantiateSi in class VectorMatrix<Q extends Quantity<Q>,Matrix1x1<Q extends Quantity<Q>>,Matrix1x1<SIQuantity>,Matrix1x1<?>,Matrix1x1<Q extends Quantity<Q>>>
      Parameters:
      siNew - the values for the new vector or matrix in row-major format
      siUnit - the new unit for the new vector or matrix
      Returns:
      a new matrix with the provided SI or BASE values
    • getRowVector

      public Vector1<Q> getRowVector(int row)
      Description copied from class: Table
      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.
      Specified by:
      getRowVector in class Table<Q extends Quantity<Q>,Matrix1x1<Q extends Quantity<Q>>,Matrix1x1<SIQuantity>,Matrix1x1<?>,Matrix1x1<Q extends Quantity<Q>>>
      Parameters:
      row - the row number to retrieve (0-based)
      Returns:
      a row vector with the data at the given row
    • mgetRowVector

      public Vector1<Q> mgetRowVector(int mRow)
      Description copied from class: Table
      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.
      Specified by:
      mgetRowVector in class Table<Q extends Quantity<Q>,Matrix1x1<Q extends Quantity<Q>>,Matrix1x1<SIQuantity>,Matrix1x1<?>,Matrix1x1<Q extends Quantity<Q>>>
      Parameters:
      mRow - the row number to retrieve (1-based)
      Returns:
      a row vector with the data at the given row
    • getColumnVector

      public Vector1<Q> getColumnVector(int col)
      Description copied from class: Table
      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.
      Specified by:
      getColumnVector in class Table<Q extends Quantity<Q>,Matrix1x1<Q extends Quantity<Q>>,Matrix1x1<SIQuantity>,Matrix1x1<?>,Matrix1x1<Q extends Quantity<Q>>>
      Parameters:
      col - the column number to retrieve (0-based)
      Returns:
      a column vector with the data at the given column
    • mgetColumnVector

      public Vector1<Q> mgetColumnVector(int mCol)
      Description copied from class: Table
      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.
      Specified by:
      mgetColumnVector in class Table<Q extends Quantity<Q>,Matrix1x1<Q extends Quantity<Q>>,Matrix1x1<SIQuantity>,Matrix1x1<?>,Matrix1x1<Q extends Quantity<Q>>>
      Parameters:
      mCol - the column number to retrieve (1-based)
      Returns:
      a column vector with the data at the given column
    • getDiagonalVector

      public Vector1<Q> getDiagonalVector() throws IllegalStateException
      Description copied from class: SquareMatrix
      Retrieve the main diagonal of the matrix as a column vector.
      Specified by:
      getDiagonalVector in class SquareMatrix<Q extends Quantity<Q>,Matrix1x1<Q extends Quantity<Q>>,Matrix1x1<SIQuantity>,Matrix1x1<?>>
      Returns:
      the main diagonal as a Vector
      Throws:
      IllegalStateException
    • inverse

      Description copied from class: SquareMatrix
      Return the inverse of the square matrix, if the matrix is non-singular. The unit of the matrix is U^(-1).
      Specified by:
      inverse in class SquareMatrix<Q extends Quantity<Q>,Matrix1x1<Q extends Quantity<Q>>,Matrix1x1<SIQuantity>,Matrix1x1<?>>
      Returns:
      the inverse of the square matrix, if the matrix is non-singular
      Throws:
      NonInvertibleMatrixException - when the matrix is singular or cannot be inverted
    • adjugate

      public Matrix1x1<SIQuantity> adjugate()
      Description copied from class: SquareMatrix
      Return the adjugate (classical adjoint) matrix for this matrix, often denoted as adj(M). The unit of adj(M) is U^(n-1) where n is the order of the matrix.
      Specified by:
      adjugate in class SquareMatrix<Q extends Quantity<Q>,Matrix1x1<Q extends Quantity<Q>>,Matrix1x1<SIQuantity>,Matrix1x1<?>>
      Returns:
      the adjugate (classical adjoint) matrix
    • invertEntries

      public Matrix1x1<SIQuantity> invertEntries()
      Description copied from interface: Hadamard
      Invert the vector, matrix or table on an entry-by-entry basis.
      Specified by:
      invertEntries in interface Hadamard<Matrix1x1<?>,Matrix1x1<SIQuantity>>
      Overrides:
      invertEntries in class VectorMatrix<Q extends Quantity<Q>,Matrix1x1<Q extends Quantity<Q>>,Matrix1x1<SIQuantity>,Matrix1x1<?>,Matrix1x1<Q extends Quantity<Q>>>
      Returns:
      a new vector, matrix or table with an entry-by-entry inversion (1/value) of the entries
    • multiplyEntries

      public Matrix1x1<SIQuantity> multiplyEntries(Matrix1x1<?> other)
      Description copied from interface: Hadamard
      Multiply the entries of this vector, matrix or table on an entry-by-entry basis with those of another collection of the same type (but possibly representing another quantity).
      Specified by:
      multiplyEntries in interface Hadamard<Matrix1x1<?>,Matrix1x1<SIQuantity>>
      Overrides:
      multiplyEntries in class VectorMatrix<Q extends Quantity<Q>,Matrix1x1<Q extends Quantity<Q>>,Matrix1x1<SIQuantity>,Matrix1x1<?>,Matrix1x1<Q extends Quantity<Q>>>
      Parameters:
      other - the other collection of the same type
      Returns:
      a new vector, matrix or table with an entry-by-entry multiplication of its entries
    • divideEntries

      public Matrix1x1<SIQuantity> divideEntries(Matrix1x1<?> other)
      Description copied from interface: Hadamard
      Divide the entries of this vector, matrix or table on an entry-by-entry basis with those of another collection of the same type (but possibly representing another quantity).
      Specified by:
      divideEntries in interface Hadamard<Matrix1x1<?>,Matrix1x1<SIQuantity>>
      Overrides:
      divideEntries in class VectorMatrix<Q extends Quantity<Q>,Matrix1x1<Q extends Quantity<Q>>,Matrix1x1<SIQuantity>,Matrix1x1<?>,Matrix1x1<Q extends Quantity<Q>>>
      Parameters:
      other - the other collection of the same type
      Returns:
      a new vector, matrix or table with an entry-by-entry division of this collection's entries and other's entries
    • multiply

      public Matrix1x1<SIQuantity> multiply(Matrix1x1<?> otherMat)
      Multiply this matrix with another matrix using matrix multiplication and return the result.
      Parameters:
      otherMat - the matrix to multiply with.
      Returns:
      the matrix from the multiplication with the correct unit
    • multiply

      public Vector1<SIQuantity> multiply(Vector1<?> otherVec)
      Multiply this matrix with a column vector, resulting in a column vector.
      Parameters:
      otherVec - the column vector to multiply with
      Returns:
      the resulting vector from the multiplication
    • multiply

      public Vector2.Row<SIQuantity> multiply(Vector2.Row<?> otherVec)
      Multiply this matrix with a row vector, resulting in a row vector.
      Parameters:
      otherVec - the row vector to multiply with
      Returns:
      the resulting vector from the multiplication
    • multiply

      public Vector3.Row<SIQuantity> multiply(Vector3.Row<?> otherVec)
      Multiply this matrix with a row vector, resulting in a row vector.
      Parameters:
      otherVec - the row vector to multiply with
      Returns:
      the resulting vector from the multiplication
    • multiply

      public VectorN.Row<SIQuantity> multiply(VectorN.Row<?> otherVec)
      Multiply this matrix with a row vector, resulting in a row vector.
      Parameters:
      otherVec - the row vector to multiply with
      Returns:
      the resulting vector from the multiplication
    • multiplyEntries

      public Matrix1x1<SIQuantity> multiplyEntries(Quantity<?> quantity)
      Description copied from interface: Hadamard
      Multiply the entries of this vector, matrix or table by the given quantity.
      Specified by:
      multiplyEntries in interface Hadamard<Matrix1x1<?>,Matrix1x1<SIQuantity>>
      Overrides:
      multiplyEntries in class VectorMatrix<Q extends Quantity<Q>,Matrix1x1<Q extends Quantity<Q>>,Matrix1x1<SIQuantity>,Matrix1x1<?>,Matrix1x1<Q extends Quantity<Q>>>
      Parameters:
      quantity - the scalar quantity to multiply by
      Returns:
      a new vector, matrix or table where the entries have been multiplied by the given quantity
    • of

      public static <Q extends Quantity<Q>> Matrix1x1<Q> of(double xInUnit, Unit<?,Q> unit)
      Create a Matrix1x1 without needing generics.
      Type Parameters:
      Q - the quantity type
      Parameters:
      xInUnit - the a11-value expressed in the given unit
      unit - the unit of the value
      Returns:
      a new Matrix1x1 with a unit
    • of

      public static <Q extends Quantity<Q>> Matrix1x1<Q> of(Q data)
      Create a Matrix1x1 without needing generics.
      Type Parameters:
      Q - the quantity type
      Parameters:
      data - the a11-value expressed as a quantity
      Returns:
      a new Matrix1x1 with a unit
    • of

      public static <Q extends Quantity<Q>> Matrix1x1<Q> of(double[] dataInUnit, Unit<?,Q> unit)
      Create a Matrix1x1 without needing generics.
      Type Parameters:
      Q - the quantity type
      Parameters:
      dataInUnit - the a11-value expressed as an array in the display unit
      unit - the unit of the data, which will also be used as the display unit
      Returns:
      a new Matrix1x1 with a unit
    • ofSi

      public static <Q extends Quantity<Q>> Matrix1x1<Q> ofSi(double[] dataSi, Unit<?,Q> displayUnit)
      Create a Matrix1x1 without needing generics.
      Type Parameters:
      Q - the quantity type
      Parameters:
      dataSi - the a11-value expressed as an array in the SI units
      displayUnit - the display unit to use
      Returns:
      a new Matrix1x1 with a unit
    • of

      public static <Q extends Quantity<Q>> Matrix1x1<Q> of(Q[] data)
      Create a Matrix1x1 without needing generics.
      Type Parameters:
      Q - the quantity type
      Parameters:
      data - the matrix values {a11} expressed as an array of quantities
      Returns:
      a new Matrix1x1 with a unit
    • ofSi

      public static <Q extends Quantity<Q>> Matrix1x1<Q> ofSi(double[][] gridSi, Unit<?,Q> displayUnit)
      Create a new Matrix1x1 with a unit, based on a 2-dimensional grid with SI-values.
      Type Parameters:
      Q - the quantity type
      Parameters:
      gridSi - the matrix values {{a11}} expressed in the SI or base unit
      displayUnit - the unit of the data, which will also be used as the display unit
      Returns:
      a new Matrix1x1 with a unit
    • of

      public static <Q extends Quantity<Q>> Matrix1x1<Q> of(double[][] gridInUnit, Unit<?,Q> unit)
      Create a new Matrix1x1 with a unit, based on a 2-dimensional grid.
      Type Parameters:
      Q - the quantity type
      Parameters:
      gridInUnit - the matrix values {{a11}} expressed in the unit
      unit - the unit of the data, which will also be used as the display unit
      Returns:
      a new Matrix1x1 with a unit
    • of

      public static <Q extends Quantity<Q>> Matrix1x1<Q> of(Q[][] grid)
      Create a Matrix1x1 without needing generics.
      Type Parameters:
      Q - the quantity type
      Parameters:
      grid - the matrix values {{a11}} expressed as an array of quantities
      Returns:
      a new Matrix1x1 with a unit
    • as

      public <TQ extends Quantity<TQ>> Matrix1x1<TQ> as(Unit<?,TQ> targetUnit) throws IllegalArgumentException
      Return the matrix 'as' a matrix with a known quantity, using a unit to express the result in. Throw a Runtime exception when the SI units of this vector and the target vector do not match.
      Type Parameters:
      TQ - target quantity type
      Parameters:
      targetUnit - the unit to convert the matrix to
      Returns:
      a matrix typed in the target matrix class
      Throws:
      IllegalArgumentException - when the units do not match