Package org.djunits.vecmat.d3
Class Matrix3x3<Q extends Quantity<Q,U>,U extends UnitInterface<U,Q>>
java.lang.Object
org.djunits.vecmat.def.VectorMatrix<Q,U,M,SI,H>
org.djunits.vecmat.def.Matrix<Q,U,M,SI,H>
org.djunits.vecmat.def.SquareMatrix<Q,U,M,SI,H>
org.djunits.vecmat.def.SquareDenseMatrix<Q,U,Matrix3x3<Q,U>,Matrix3x3<SIQuantity,SIUnit>,Matrix3x3<?,?>>
org.djunits.vecmat.d3.Matrix3x3<Q,U>
- Type Parameters:
Q- the quantity typeU- the unit type
- All Implemented Interfaces:
Serializable,Additive<Matrix3x3<Q,,U>> Scalable<Matrix3x3<Q,,U>> Value<U,,Matrix3x3<Q, U>> Hadamard<Matrix3x3<?,?>, Matrix3x3<SIQuantity, SIUnit>>
public class Matrix3x3<Q extends Quantity<Q,U>,U extends UnitInterface<U,Q>>
extends SquareDenseMatrix<Q,U,Matrix3x3<Q,U>,Matrix3x3<SIQuantity,SIUnit>,Matrix3x3<?,?>>
Matrix3x3 implements a matrix with 3x3 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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadjugate()Return the adjugate (classical adjoint) matrix for this matrix, often denoted as adj(M).<TQ extends Quantity<TQ,TU>, TU extends UnitInterface<TU, TQ>>
Matrix3x3<TQ,TU> as(TU targetUnit) Return the matrix 'as' a matrix with a known quantity, using a unit to express the result in.divideElements(Matrix3x3<?, ?> other) Divide the elements of this vector, matrix or table on an element-by-element basis with those of another collection of the same type (but possibly representing another quantity).getColumnVector(int col) Return a quantity column (0-based) from the vector or matrix.Retrieve the main diagonal of the matrix as a column vector.getRowVector(int row) Return a quantity row (0-based) from the vector or matrix.instantiateSi(double[] siNew) Return a new vector or matrix with the given SI or BASE values.instantiateSi(double[] siNew, SIUnit siUnit) Return a new vector or matrix in SI-units with the given SI or BASE values.inverse()Return the inverse of the square matrix, if the matrix is non-singular.Invert the vector, matrix or table on an element-by-element basis.mgetColumnVector(int mCol) Return a quantity column (1-based) from the vector or matrix.mgetRowVector(int mRow) Return a quantity row (1-based) from the vector or matrix.Multiply this matrix with another matrix using matrix multiplication and return the result.multiply(Vector3.Col<?, ?> otherVec) Multiply this matrix with a column vector, resulting in a column vector.multiplyElements(Quantity<?, ?> quantity) Multiply the elements of this vector, matrix or table by the given quantity.multiplyElements(Matrix3x3<?, ?> other) Multiply the elements of this vector, matrix or table on an element-by-element basis with those of another collection of the same type (but possibly representing another quantity).static <Q extends Quantity<Q,U>, U extends UnitInterface<U, Q>>
Matrix3x3<Q,U> of(double[][] gridInUnit, U displayUnit) Create a new Matrix3x3 with a unit, based on a 2-dimensional grid.static <Q extends Quantity<Q,U>, U extends UnitInterface<U, Q>>
Matrix3x3<Q,U> of(double[] arrayInUnit, U displayUnit) Create a new Matrix3x3 with a unit, based on a 1-dimensional array.Methods inherited from class org.djunits.vecmat.def.SquareDenseMatrix
cols, equals, getColumnSi, getRowSi, hashCode, rows, si, siMethods inherited from class org.djunits.vecmat.def.SquareMatrix
determinant, determinantScalar, getDiagonalScalars, getDiagonalSi, isSkewSymmetric, isSkewSymmetric, isSymmetric, isSymmetric, normFrobenius, order, trace, transposeMethods inherited from class org.djunits.vecmat.def.Matrix
checkMultiply, checkMultiply, multiplyMethods inherited from class org.djunits.vecmat.def.VectorMatrix
abs, add, add, asMatrixNxM, asQuantityTable, checkCol, checkRow, divideElements, get, getColumnScalars, getDisplayUnit, getRowScalars, getScalarGrid, isRelative, max, mcheckCol, mcheckRow, mean, median, mget, mgetColumnScalars, mgetColumnSi, mgetRowScalars, mgetRowSi, min, mode, msi, multiplyElements, negate, scaleBy, setDisplayUnit, subtract, subtract, sum, toString, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.djunits.vecmat.operations.Hadamard
divideElementsMethods inherited from interface org.djunits.value.Value
isAbsolute, setDisplayUnit
-
Constructor Details
-
Matrix3x3
Create a new Matrix3x3 with a unit.- Parameters:
arrayInUnit- the matrix values [a11, a12, a13, a21, a22, a23, a31, a32, a33] expressed in the display unitdisplayUnit- the display unit to use
-
-
Method Details
-
of
public static <Q extends Quantity<Q,U>, Matrix3x3<Q,U extends UnitInterface<U, Q>> U> of(double[] arrayInUnit, U displayUnit) Create a new Matrix3x3 with a unit, based on a 1-dimensional array.Implementation Note: the condition is also checked by super() but the fail fast approach is used here
- Type Parameters:
Q- the quantity typeU- the unit type- Parameters:
arrayInUnit- the matrix values {a11, a12, 13, ..., a31, a32, a33} expressed in the display unitdisplayUnit- the display unit to use- Returns:
- a new Matrix3x3 with a unit
- Throws:
IllegalArgumentException- when valueArray does not contain 3x3 = 9 values
-
of
public static <Q extends Quantity<Q,U>, Matrix3x3<Q,U extends UnitInterface<U, Q>> U> of(double[][] gridInUnit, U displayUnit) Create a new Matrix3x3 with a unit, based on a 2-dimensional grid.- Type Parameters:
Q- the quantity typeU- the unit type- Parameters:
gridInUnit- the matrix values {{a11, a12, a13}, ..., {a31, a32, a33}} expressed in the display unitdisplayUnit- the display unit to use- Returns:
- a new Matrix3x3 with a unit
-
instantiateSi
Description copied from class:VectorMatrixReturn a new vector or matrix with the given SI or BASE values.- Specified by:
instantiateSiin classVectorMatrix<Q extends Quantity<Q,U>, U extends UnitInterface<U, Q>, Matrix3x3<Q extends Quantity<Q, U>, U extends UnitInterface<U, Q>>, Matrix3x3<SIQuantity, SIUnit>, Matrix3x3<?, ?>> - 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
Description copied from class:VectorMatrixReturn a new vector or matrix in SI-units with the given SI or BASE values.- Specified by:
instantiateSiin classVectorMatrix<Q extends Quantity<Q,U>, U extends UnitInterface<U, Q>, Matrix3x3<Q extends Quantity<Q, U>, U extends UnitInterface<U, Q>>, Matrix3x3<SIQuantity, SIUnit>, Matrix3x3<?, ?>> - Parameters:
siNew- the values for the new vector or matrix in row-major formatsiUnit- the new unit for the new vector or matrix- Returns:
- a new matrix with the provided SI or BASE values
-
getRowVector
Description copied from class:VectorMatrixReturn a quantity row (0-based) from the vector or matrix. Note that the specific vector to return can be tightened by the implementing class.- Specified by:
getRowVectorin classVectorMatrix<Q extends Quantity<Q,U>, U extends UnitInterface<U, Q>, Matrix3x3<Q extends Quantity<Q, U>, U extends UnitInterface<U, Q>>, Matrix3x3<SIQuantity, SIUnit>, Matrix3x3<?, ?>> - Parameters:
row- the row number to retrieve (0-based)- Returns:
- a row vector with the data at the given row
-
mgetRowVector
Description copied from class:VectorMatrixReturn a quantity row (1-based) from the vector or matrix. Note that the specific vector to return can be tightened by the implementing class.- Specified by:
mgetRowVectorin classVectorMatrix<Q extends Quantity<Q,U>, U extends UnitInterface<U, Q>, Matrix3x3<Q extends Quantity<Q, U>, U extends UnitInterface<U, Q>>, Matrix3x3<SIQuantity, SIUnit>, Matrix3x3<?, ?>> - Parameters:
mRow- the row number to retrieve (1-based)- Returns:
- a row vector with the data at the given row
-
getColumnVector
Description copied from class:VectorMatrixReturn a quantity column (0-based) from the vector or matrix. Note that the specific vector to return can be tightened by the implementing class.- Specified by:
getColumnVectorin classVectorMatrix<Q extends Quantity<Q,U>, U extends UnitInterface<U, Q>, Matrix3x3<Q extends Quantity<Q, U>, U extends UnitInterface<U, Q>>, Matrix3x3<SIQuantity, SIUnit>, Matrix3x3<?, ?>> - Parameters:
col- the column number to retrieve (0-based)- Returns:
- a column vector with the data at the given column
-
mgetColumnVector
Description copied from class:VectorMatrixReturn a quantity column (1-based) from the vector or matrix. Note that the specific vector to return can be tightened by the implementing class.- Specified by:
mgetColumnVectorin classVectorMatrix<Q extends Quantity<Q,U>, U extends UnitInterface<U, Q>, Matrix3x3<Q extends Quantity<Q, U>, U extends UnitInterface<U, Q>>, Matrix3x3<SIQuantity, SIUnit>, Matrix3x3<?, ?>> - Parameters:
mCol- the column number to retrieve (1-based)- Returns:
- a column vector with the data at the given column
-
getDiagonalVector
Description copied from class:SquareMatrixRetrieve the main diagonal of the matrix as a column vector.- Specified by:
getDiagonalVectorin classSquareMatrix<Q extends Quantity<Q,U>, U extends UnitInterface<U, Q>, Matrix3x3<Q extends Quantity<Q, U>, U extends UnitInterface<U, Q>>, Matrix3x3<SIQuantity, SIUnit>, Matrix3x3<?, ?>> - Returns:
- the main diagonal as a Vector
- Throws:
IllegalStateException
-
inverse
Description copied from class:SquareMatrixReturn the inverse of the square matrix, if the matrix is non-singular. The unit of the matrix is U^(-1).- Specified by:
inversein classSquareMatrix<Q extends Quantity<Q,U>, U extends UnitInterface<U, Q>, Matrix3x3<Q extends Quantity<Q, U>, U extends UnitInterface<U, Q>>, Matrix3x3<SIQuantity, SIUnit>, Matrix3x3<?, ?>> - 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
Description copied from class:SquareMatrixReturn 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. -
invertElements
Description copied from interface:HadamardInvert the vector, matrix or table on an element-by-element basis.- Specified by:
invertElementsin interfaceHadamard<Q extends Quantity<Q,U>, U extends UnitInterface<U, Q>> - Overrides:
invertElementsin classVectorMatrix<Q extends Quantity<Q,U>, U extends UnitInterface<U, Q>, Matrix3x3<Q extends Quantity<Q, U>, U extends UnitInterface<U, Q>>, Matrix3x3<SIQuantity, SIUnit>, Matrix3x3<?, ?>> - Returns:
- a vector, matrix or table with an element-by-element inversion (1/value) of the elements
-
multiplyElements
Description copied from interface:HadamardMultiply the elements of this vector, matrix or table on an element-by-element basis with those of another collection of the same type (but possibly representing another quantity).- Specified by:
multiplyElementsin interfaceHadamard<Q extends Quantity<Q,U>, U extends UnitInterface<U, Q>> - Overrides:
multiplyElementsin classVectorMatrix<Q extends Quantity<Q,U>, U extends UnitInterface<U, Q>, Matrix3x3<Q extends Quantity<Q, U>, U extends UnitInterface<U, Q>>, Matrix3x3<SIQuantity, SIUnit>, Matrix3x3<?, ?>> - Parameters:
other- the other collection of the same type- Returns:
- a vector, matrix or table with an element-by-element multiplication of its elements
-
divideElements
Description copied from interface:HadamardDivide the elements of this vector, matrix or table on an element-by-element basis with those of another collection of the same type (but possibly representing another quantity).- Specified by:
divideElementsin interfaceHadamard<Q extends Quantity<Q,U>, U extends UnitInterface<U, Q>> - Overrides:
divideElementsin classVectorMatrix<Q extends Quantity<Q,U>, U extends UnitInterface<U, Q>, Matrix3x3<Q extends Quantity<Q, U>, U extends UnitInterface<U, Q>>, Matrix3x3<SIQuantity, SIUnit>, Matrix3x3<?, ?>> - Parameters:
other- the other collection of the same type- Returns:
- a vector, matrix or table with an element-by-element division of this collection's elements and other's elements
-
multiply
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
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
-
multiplyElements
Description copied from interface:HadamardMultiply the elements of this vector, matrix or table by the given quantity.- Specified by:
multiplyElementsin interfaceHadamard<Q extends Quantity<Q,U>, U extends UnitInterface<U, Q>> - Overrides:
multiplyElementsin classVectorMatrix<Q extends Quantity<Q,U>, U extends UnitInterface<U, Q>, Matrix3x3<Q extends Quantity<Q, U>, U extends UnitInterface<U, Q>>, Matrix3x3<SIQuantity, SIUnit>, Matrix3x3<?, ?>> - Parameters:
quantity- the scalar quantity to multiply by- Returns:
- a vector, matrix or table where the elements have been multiplied by the given quantity
-
as
public <TQ extends Quantity<TQ,TU>, Matrix3x3<TQ,TU extends UnitInterface<TU, TQ>> TU> as(TU 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 typeTU- target unit 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
-