Package org.djunits.vecmat.def
Class SquareDenseMatrix<Q extends Quantity<Q>,M extends SquareDenseMatrix<Q,M,SI,H>,SI extends SquareDenseMatrix<SIQuantity,SI,?,?>,H extends SquareDenseMatrix<?,?,?,?>>
java.lang.Object
org.djunits.vecmat.def.VectorMatrix<Q,T,SI,H,TT>
org.djunits.vecmat.def.Table<Q,M,SI,H,MT>
org.djunits.vecmat.def.Matrix<Q,M,SI,H,M>
org.djunits.vecmat.def.SquareMatrix<Q,M,SI,H>
org.djunits.vecmat.def.SquareDenseMatrix<Q,M,SI,H>
- Type Parameters:
Q- the quantity typeM- the 'SELF' square dense matrix typeSI- the square dense matrix type with generics <SIQuantity, SIUnit<H- the generic square dense matrix type with generics <?, ?< for Hadamard operations
- All Implemented Interfaces:
Serializable,Additive<M>,Scalable<M>,Value<M,,Q> Hadamard<H,SI>
public abstract class SquareDenseMatrix<Q extends Quantity<Q>,M extends SquareDenseMatrix<Q,M,SI,H>,SI extends SquareDenseMatrix<SIQuantity,SI,?,?>,H extends SquareDenseMatrix<?,?,?,?>>
extends SquareMatrix<Q,M,SI,H>
SquareDenseMatrix implements the core functions for a matrix with n x n real-valued entries. The data is stored in a dense
double[] field. 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
ConstructorsModifierConstructorDescriptionprotectedSquareDenseMatrix(double[] dataSi, Unit<?, Q> displayUnit, int order) Create a new SquareDenseMatrix with a unit. -
Method Summary
Modifier and TypeMethodDescriptionintcols()Return the number of columns.booleandouble[]getColumnSi(int col) Return an array with SI-values for the given column (0-based) from the table or matrix.double[]getRowSi(int row) Return an array with SI-values for the given row (0-based) from the table or matrix.double[]Return a row-major array of SI-values for this matrix or vector.inthashCode()intReturn the number of non-zero entries in the vector, matrix or table.introws()Return the number of rows.doublesi(int row, int col) Return the si-value at position (row, col), where both row and col are 0-based values.double[]Return a row-major possibly UNSAFE array of SI-values for this matrix or vector.Methods inherited from class org.djunits.vecmat.def.SquareMatrix
adjugate, determinant, determinantSi, getDiagonalScalars, getDiagonalSi, getDiagonalVector, inverse, isSkewSymmetric, isSkewSymmetric, isSymmetric, isSymmetric, normFrobenius, order, trace, transposeMethods inherited from class org.djunits.vecmat.def.Table
checkCol, checkRow, get, getColumnScalars, getColumnVector, getRowScalars, getRowVector, getScalarArray, getScalarGrid, getSiGrid, mcheckCol, mcheckRow, mget, mgetColumnScalars, mgetColumnSi, mgetColumnVector, mgetRowScalars, mgetRowSi, mgetRowVector, msiMethods 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, divideElements, divideEntries, getDisplayUnit, instantiateSi, instantiateSi, invertEntries, isRelative, max, mean, median, min, multiplyElements, multiplyEntries, multiplyEntries, negate, nnz, scaleBy, setDisplayUnit, subtract, subtract, sum, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.djunits.vecmat.operations.Hadamard
divideEntriesMethods inherited from interface org.djunits.value.Value
isAbsolute, setDisplayUnit
-
Constructor Details
-
SquareDenseMatrix
Create a new SquareDenseMatrix with a unit. NO SAFE COPY of the double[] data element is made.- Parameters:
dataSi- the matrix values {a11, a12, ..., a21, a22, ...} expressed in the SI unitdisplayUnit- the display unit to useorder- the order of the square matrix (number of rows/columns)- Throws:
IllegalArgumentException- when dataSi.length != order * order.
-
-
Method Details
-
unsafeSiArray
public double[] unsafeSiArray()Description copied from class:VectorMatrixReturn a row-major possibly UNSAFE array of SI-values for this matrix or vector. The method might give access to the underlying data structure, so treat the data carefully.- Specified by:
unsafeSiArrayin classVectorMatrix<Q extends Quantity<Q>,M extends SquareDenseMatrix<Q, M, SI, H>, SI extends SquareDenseMatrix<SIQuantity, SI, ?, ?>, H extends SquareDenseMatrix<?, ?, ?, ?>, M extends SquareDenseMatrix<Q, M, SI, H>> - Returns:
- the row-major array of SI-values (safe copy)
-
getSiArray
public double[] getSiArray()Description copied from class:VectorMatrixReturn a row-major array of SI-values for this matrix or vector. This is guaranteed to be a safe copy.- Specified by:
getSiArrayin classVectorMatrix<Q extends Quantity<Q>,M extends SquareDenseMatrix<Q, M, SI, H>, SI extends SquareDenseMatrix<SIQuantity, SI, ?, ?>, H extends SquareDenseMatrix<?, ?, ?, ?>, M extends SquareDenseMatrix<Q, M, SI, H>> - Returns:
- the row-major array of SI-values (safe copy)
-
si
public double si(int row, int col) Description copied from class:TableReturn the si-value at position (row, col), where both row and col are 0-based values.- Specified by:
siin classTable<Q extends Quantity<Q>,M extends SquareDenseMatrix<Q, M, SI, H>, SI extends SquareDenseMatrix<SIQuantity, SI, ?, ?>, H extends SquareDenseMatrix<?, ?, ?, ?>, M extends SquareDenseMatrix<Q, M, SI, H>> - Parameters:
row- the row (0-based)col- the column (0-based)- Returns:
- the si-value at position (row, col)
-
rows
public int rows()Description copied from class:VectorMatrixReturn the number of rows.- Specified by:
rowsin classVectorMatrix<Q extends Quantity<Q>,M extends SquareDenseMatrix<Q, M, SI, H>, SI extends SquareDenseMatrix<SIQuantity, SI, ?, ?>, H extends SquareDenseMatrix<?, ?, ?, ?>, M extends SquareDenseMatrix<Q, M, SI, H>> - Returns:
- the number of rows
-
cols
public int cols()Description copied from class:VectorMatrixReturn the number of columns.- Specified by:
colsin classVectorMatrix<Q extends Quantity<Q>,M extends SquareDenseMatrix<Q, M, SI, H>, SI extends SquareDenseMatrix<SIQuantity, SI, ?, ?>, H extends SquareDenseMatrix<?, ?, ?, ?>, M extends SquareDenseMatrix<Q, M, SI, H>> - Returns:
- the number of columns
-
nonZeroCount
public int nonZeroCount()Description copied from class:VectorMatrixReturn the number of non-zero entries in the vector, matrix or table. Note that NaN and Infinity count as a non-zero element. The value -0.0 counts as 0.0.- Specified by:
nonZeroCountin classVectorMatrix<Q extends Quantity<Q>,M extends SquareDenseMatrix<Q, M, SI, H>, SI extends SquareDenseMatrix<SIQuantity, SI, ?, ?>, H extends SquareDenseMatrix<?, ?, ?, ?>, M extends SquareDenseMatrix<Q, M, SI, H>> - Returns:
- the number of non-zero entries in the vector, matrix or table
-
getRowSi
public double[] getRowSi(int row) Description copied from class:TableReturn an array with SI-values for the given row (0-based) from the table or matrix.- Specified by:
getRowSiin classTable<Q extends Quantity<Q>,M extends SquareDenseMatrix<Q, M, SI, H>, SI extends SquareDenseMatrix<SIQuantity, SI, ?, ?>, H extends SquareDenseMatrix<?, ?, ?, ?>, M extends SquareDenseMatrix<Q, M, SI, H>> - Parameters:
row- the row number to retrieve (0-based)- Returns:
- an array with SI-values with the data at the given row
-
getColumnSi
public double[] getColumnSi(int col) Description copied from class:TableReturn an array with SI-values for the given column (0-based) from the table or matrix.- Specified by:
getColumnSiin classTable<Q extends Quantity<Q>,M extends SquareDenseMatrix<Q, M, SI, H>, SI extends SquareDenseMatrix<SIQuantity, SI, ?, ?>, H extends SquareDenseMatrix<?, ?, ?, ?>, M extends SquareDenseMatrix<Q, M, SI, H>> - Parameters:
col- the column number to retrieve (0-based)- Returns:
- an array with SI-values with the data at the given column
-
hashCode
public int hashCode() -
equals
-