Class FloatMatrixDataDense
java.lang.Object
org.djunits.value.storage.Storage<FloatMatrixData>
org.djunits.value.vfloat.matrix.data.FloatMatrixData
org.djunits.value.vfloat.matrix.data.FloatMatrixDataDense
- All Implemented Interfaces:
Serializable
,Cloneable
Stores dense data for a FloatMatrix and carries out basic operations.
Copyright (c) 2013-2024 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.vfloat.matrix.data.FloatMatrixData
cols, matrixSI, rows
-
Constructor Summary
ConstructorDescriptionFloatMatrixDataDense
(float[][] matrixSI) Create a matrix with dense data.FloatMatrixDataDense
(float[] matrixSI, int rows, int cols) Create a matrix with dense data. -
Method Summary
Modifier and TypeMethodDescriptionfinal FloatMatrixDataDense
assign
(FloatFunction floatFunction) Apply an operation to each cell.final FloatMatrixDataDense
assign
(FloatFunction2 floatFunction, FloatMatrixData right) Apply a binary operation on a cell by cell basis.final int
Compute and return the number of non-zero cells in this indexed value.final FloatMatrixDataDense
copy()
Create and return a deep copy of the data.divide
(FloatMatrixData right) Divide two matrices on a cell-by-cell basis.final float[][]
Create and return a deep copy of the data in dense format.final double[][]
Create and return a deep copy of the data in dense format.final float
getSI
(int row, int col) Retrieve one value from this data.final FloatMatrixDataDense
minus
(FloatMatrixData right) Subtract two matrices on a cell-by-cell basis.plus
(FloatMatrixData right) Add two matrices on a cell-by-cell basis.final void
setSI
(int row, int col, float valueSI) Sets a value at the [row, col] point in the matrix.times
(FloatMatrixData right) Multiply two matrices on a cell-by-cell basis.final FloatMatrixDataDense
toDense()
Return the data of this matrix in dense storage format.final FloatMatrixDataSparse
toSparse()
Return the data of this matrix in sparse storage format.Methods inherited from class org.djunits.value.vfloat.matrix.data.FloatMatrixData
checkRectangularAndNonNull, checkRectangularAndNonNull, checkSizes, cols, compareDenseMatrixWithSparseMatrix, decrementBy, divideBy, equals, hashCode, incrementBy, instantiate, instantiate, instantiate, multiplyBy, rows, toString, zSum
Methods inherited from class org.djunits.value.storage.Storage
getStorageType, isDense, isSparse
-
Constructor Details
-
FloatMatrixDataDense
Create a matrix with dense data.- Parameters:
matrixSI
- float[]; the data to storerows
- int; the number of rowscols
- int; the number of columns- Throws:
ValueRuntimeException
- in caserows * cols != matrixSI.length
-
FloatMatrixDataDense
Create a matrix with dense data. The float array is of the form d[rows][columns] so each value can be found with f[row][column].- Parameters:
matrixSI
- float[][]; 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:Storage
Compute and return the number of non-zero cells in this indexed value.- Specified by:
cardinality
in classStorage<FloatMatrixData>
- Returns:
- int; the number of non-zero cells
-
assign
Description copied from class:FloatMatrixData
Apply an operation to each cell.- Specified by:
assign
in classFloatMatrixData
- Parameters:
floatFunction
- FloatFunction; the operation to apply- Returns:
- FloatMatrixData; this (modified) double vector data object
-
assign
Description copied from class:FloatMatrixData
Apply a binary operation on a cell by cell basis.- Specified by:
assign
in classFloatMatrixData
- Parameters:
floatFunction
- FloatFunction2; the binary operation to applyright
- FloatMatrixData; the right operand for the binary operation- Returns:
- FloatMatrixData; this (modified) double matrix data object
-
toDense
Description copied from class:FloatMatrixData
Return the data of this matrix in dense storage format.- Specified by:
toDense
in classFloatMatrixData
- Returns:
- FloatMatrixDataDense; the dense transformation of this data
-
toSparse
Description copied from class:FloatMatrixData
Return the data of this matrix in sparse storage format.- Specified by:
toSparse
in classFloatMatrixData
- Returns:
- FloatMatrixDataSparse; the sparse transformation of this data
-
getSI
public final float getSI(int row, int col) Description copied from class:FloatMatrixData
Retrieve one value from this data.- Specified by:
getSI
in classFloatMatrixData
- Parameters:
row
- int; the row number to get the value forcol
- int; 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, float valueSI) Description copied from class:FloatMatrixData
Sets a value at the [row, col] point in the matrix.- Specified by:
setSI
in classFloatMatrixData
- Parameters:
row
- int; the row number to set the value forcol
- int; the column number to set the value forvalueSI
- float; the value at the index
-
getDenseMatrixSI
public final float[][] getDenseMatrixSI()Description copied from class:FloatMatrixData
Create and return a deep copy of the data in dense format. The float array is of the form f[rows][columns] so each value can be found with f[row][column].- Specified by:
getDenseMatrixSI
in classFloatMatrixData
- Returns:
- float[][]; a safe, dense copy of matrixSI as a matrix
-
getDoubleDenseMatrixSI
public final double[][] getDoubleDenseMatrixSI()Description copied from class:FloatMatrixData
Create 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:
getDoubleDenseMatrixSI
in classFloatMatrixData
- Returns:
- double[][]; a safe, dense copy of matrixSI as a matrix
-
copy
Description copied from class:Storage
Create and return a deep copy of the data.- Specified by:
copy
in classStorage<FloatMatrixData>
- Returns:
- T; a deep copy of the data
-
plus
Description copied from class:FloatMatrixData
Add 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:
plus
in classFloatMatrixData
- Parameters:
right
- FloatMatrixData; 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:FloatMatrixData
Subtract 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:
minus
in classFloatMatrixData
- Parameters:
right
- FloatMatrixData; the other data object to subtract- Returns:
- the sum of this data object and the other data object
-
times
Description copied from class:FloatMatrixData
Multiply 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:
times
in classFloatMatrixData
- Parameters:
right
- FloatMatrixData; the other data object to multiply with- Returns:
- FloatMatrixData; a new double matrix data store holding the result of the multiplications
- Throws:
ValueRuntimeException
- if matrices have different sizes
-
divide
Description copied from class:FloatMatrixData
Divide 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:
divide
in classFloatMatrixData
- Parameters:
right
- FloatMatrixData; the other data object to divide by- Returns:
- the sum of this data object and the other data object
- Throws:
ValueRuntimeException
- if matrices have different sizes
-