Class DoubleMatrixDataDense
java.lang.Object
org.djunits.value.storage.Storage<DoubleMatrixData>
org.djunits.value.vdouble.matrix.data.DoubleMatrixData
org.djunits.value.vdouble.matrix.data.DoubleMatrixDataDense
- All Implemented Interfaces:
Serializable,Cloneable
Stores dense data for a DoubleMatrix and carries out basic operations.
Copyright (c) 2013-2025 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See DJUNITS License.
- Author:
- Alexander Verbraeck, Peter Knoppers
- See Also:
-
Field Summary
Fields inherited from class org.djunits.value.vdouble.matrix.data.DoubleMatrixData
cols, matrixSI, rows -
Constructor Summary
ConstructorsConstructorDescriptionDoubleMatrixDataDense(double[][] matrixSI) Create a matrix with dense data.DoubleMatrixDataDense(double[] matrixSI, int rows, int cols) Create a matrix with dense data. -
Method Summary
Modifier and TypeMethodDescriptionfinal DoubleMatrixDataDenseassign(DoubleFunction doubleFunction) Apply an operation to each cell.final DoubleMatrixDataDenseassign(DoubleFunction2 doubleFunction, DoubleMatrixData right) Apply a binary operation on a cell by cell basis.final intCompute and return the number of non-zero cells in this indexed value.final DoubleMatrixDataDensecopy()Create and return a deep copy of the data.divide(DoubleMatrixData right) Divide two matrices on a cell-by-cell basis.final double[][]Create and return a deep copy of the data in dense format.final doublegetSI(int row, int col) Retrieve one value from this data.final DoubleMatrixDataDenseminus(DoubleMatrixData right) Subtract two matrices on a cell-by-cell basis.plus(DoubleMatrixData right) Add two matrices on a cell-by-cell basis.final voidsetSI(int row, int col, double valueSI) Sets a value at the [row, col] point in the matrix.times(DoubleMatrixData right) Multiply two matrices on a cell-by-cell basis.final DoubleMatrixDataDensetoDense()Return the data of this matrix in dense storage format.final DoubleMatrixDataSparsetoSparse()Return the data of this matrix in sparse storage format.toString()Methods inherited from class org.djunits.value.vdouble.matrix.data.DoubleMatrixData
checkRectangularAndNonNull, checkRectangularAndNonNull, checkSizes, cols, compareDenseMatrixWithSparseMatrix, decrementBy, divideBy, equals, hashCode, incrementBy, instantiate, instantiate, instantiate, multiplyBy, rows, zSumMethods inherited from class org.djunits.value.storage.Storage
getStorageType, isDense, isSparse
-
Constructor Details
-
DoubleMatrixDataDense
Create a matrix with dense data.- Parameters:
matrixSI- the data to storerows- the number of rowscols- the number of columns- Throws:
ValueRuntimeException- in caserows * cols != matrixSI.length
-
DoubleMatrixDataDense
Create a matrix with dense data. The double array is of the form d[rows][columns] so each value can be found with d[row][column].- Parameters:
matrixSI- the data to store- Throws:
NullPointerException- when matrixSI is nullValueRuntimeException- in case matrix is ragged
-
-
Method Details
-
cardinality
public final int cardinality()Description copied from class:StorageCompute and return the number of non-zero cells in this indexed value.- Specified by:
cardinalityin classStorage<DoubleMatrixData>- Returns:
- the number of non-zero cells
-
assign
Description copied from class:DoubleMatrixDataApply an operation to each cell.- Specified by:
assignin classDoubleMatrixData- Parameters:
doubleFunction- the operation to apply- Returns:
- this (modified) double matrix data object
-
assign
Description copied from class:DoubleMatrixDataApply a binary operation on a cell by cell basis.- Specified by:
assignin classDoubleMatrixData- Parameters:
doubleFunction- the binary operation to applyright- the right operand for the binary operation- Returns:
- this (modified) double matrix data object
-
toDense
Description copied from class:DoubleMatrixDataReturn the data of this matrix in dense storage format.- Specified by:
toDensein classDoubleMatrixData- Returns:
- the dense transformation of this data
-
toSparse
Description copied from class:DoubleMatrixDataReturn the data of this matrix in sparse storage format.- Specified by:
toSparsein classDoubleMatrixData- Returns:
- the sparse transformation of this data
-
getSI
public final double getSI(int row, int col) Description copied from class:DoubleMatrixDataRetrieve one value from this data.- Specified by:
getSIin classDoubleMatrixData- Parameters:
row- the row number to get the value forcol- the column number to get the value for- Returns:
- the value at the [row, col] point
-
setSI
public final void setSI(int row, int col, double valueSI) Description copied from class:DoubleMatrixDataSets a value at the [row, col] point in the matrix.- Specified by:
setSIin classDoubleMatrixData- Parameters:
row- the row number to set the value forcol- the column number to set the value forvalueSI- the value at the index
-
getDenseMatrixSI
public final double[][] getDenseMatrixSI()Description copied from class:DoubleMatrixDataCreate and return a deep copy of the data in dense format. The double array is of the form d[rows][columns] so each value can be found with d[row][column].- Specified by:
getDenseMatrixSIin classDoubleMatrixData- Returns:
- a safe, dense copy of matrixSI as a matrix
-
copy
Description copied from class:StorageCreate and return a deep copy of the data.- Specified by:
copyin classStorage<DoubleMatrixData>- Returns:
- a deep copy of the data
-
plus
Description copied from class:DoubleMatrixDataAdd two matrices on a cell-by-cell basis. If both matrices are sparse, a sparse matrix is returned, otherwise a dense matrix is returned.- Specified by:
plusin classDoubleMatrixData- Parameters:
right- the other data object to add- Returns:
- the sum of this data object and the other data object
- Throws:
ValueRuntimeException- if matrices have different lengths
-
minus
Description copied from class:DoubleMatrixDataSubtract two matrices on a cell-by-cell basis. If both matrices are sparse, a sparse matrix is returned, otherwise a dense matrix is returned.- Specified by:
minusin classDoubleMatrixData- Parameters:
right- the other data object to subtract- Returns:
- the sum of this data object and the other data object
-
times
Description copied from class:DoubleMatrixDataMultiply two matrices on a cell-by-cell basis. If both matrices are dense, a dense matrix is returned, otherwise a sparse matrix is returned.- Specified by:
timesin classDoubleMatrixData- Parameters:
right- the other data object to multiply with- Returns:
- a new double matrix data store holding the result of the multiplications
- Throws:
ValueRuntimeException- if matrices have different sizes
-
divide
Description copied from class:DoubleMatrixDataDivide two matrices on a cell-by-cell basis. If this matrix is sparse andrightis dense, a sparse matrix is returned, otherwise a dense matrix is returned.- Specified by:
dividein classDoubleMatrixData- Parameters:
right- the other data object to divide by- Returns:
- the ratios of the values of this data object and the other data object
- Throws:
ValueRuntimeException- if matrices have different sizes
-
toString
-