org.djunits.value.vfloat.matrix

## Class FloatMatrixData

• Direct Known Subclasses:

```abstract class FloatMatrixData
extends Object```
Stores the data for a FloatMatrix and carries out basic operations.

\$LastChangedDate: 2015-07-24 02:58:59 +0200 (Fri, 24 Jul 2015) \$, @version \$Revision: 1147 \$, by \$Author: averbraeck \$, initial version Oct 3, 2015
Author:
Alexander Verbraeck, Peter Knoppers
• ### Field Summary

Fields
Modifier and Type Field and Description
`protected int` `cols`
the number of columns of the matrix.
`protected float[]` `matrixSI`
the internal storage of the Matrix; can be sparse or dense.
`protected int` `rows`
the number of rows of the matrix.
• ### Constructor Summary

Constructors
Constructor and Description
`FloatMatrixData(StorageType storageType)`
• ### Method Summary

All Methods
Modifier and Type Method and Description
`int` `cardinality()`
`int` `cols()`
`abstract FloatMatrixData` `copy()`
`void` `decrementBy(float valueSI)`
Subtract a number from this matrix on a cell-by-cell basis.
`abstract void` `decrementBy(FloatMatrixData right)`
Subtract a matrix from this matrix on a cell-by-cell basis.
`FloatMatrixData` `divide(FloatMatrixData right)`
Divide two matrices on a cell-by-cell basis.
`void` `divideBy(float valueSI)`
Divide the values of this matrix by a number on a cell-by-cell basis.
`abstract void` `divideBy(FloatMatrixData right)`
Divide the values of a matrix by the values of another matrix on a cell-by-cell basis.
`boolean` `equals(Object obj)`
`abstract float[][]` `getDenseMatrixSI()`
`abstract double[][]` `getDoubleDenseMatrixSI()`
`abstract float` ```getSI(int row, int col)```
`StorageType` `getStorageType()`
Return the StorageType (DENSE, SPARSE, etc.) for the stored Matrix.
`int` `hashCode()`
`void` `incrementBy(float valueSI)`
Add a number to this matrix on a cell-by-cell basis.
`abstract void` `incrementBy(FloatMatrixData right)`
Add a matrix to this matrix on a cell-by-cell basis.
`static FloatMatrixData` ```instantiate(float[][] values, Scale scale, StorageType storageType)```
Instantiate a FloatMatrixData with the right data type.
`static FloatMatrixData` ```instantiate(FloatScalarInterface[][] values, StorageType storageType)```
Instantiate a FloatMatrixData with the right data type.
`boolean` `isDense()`
`boolean` `isSparse()`
`FloatMatrixData` `minus(FloatMatrixData right)`
Subtract two matrices on a cell-by-cell basis.
`void` `multiplyBy(float valueSI)`
Multiply the values of this matrix with a number on a cell-by-cell basis.
`abstract void` `multiplyBy(FloatMatrixData right)`
Multiply a matrix with the values of another matrix on a cell-by-cell basis.
`FloatMatrixData` `plus(FloatMatrixData right)`
Add two matrices on a cell-by-cell basis.
`int` `rows()`
`abstract void` ```setSI(int row, int col, float valueSI)```
Sets a value at the [row, col] point in the matrix.
`FloatMatrixData` `times(FloatMatrixData right)`
Multiply two matrix on a cell-by-cell basis.
`FloatMatrixDataDense` `toDense()`
`FloatMatrixDataSparse` `toSparse()`
`String` `toString()`
`float` `zSum()`
• ### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`
• ### Field Detail

• #### matrixSI

`protected float[] matrixSI`
the internal storage of the Matrix; can be sparse or dense.
• #### rows

`protected int rows`
the number of rows of the matrix.
• #### cols

`protected int cols`
the number of columns of the matrix.
• ### Constructor Detail

• #### FloatMatrixData

`FloatMatrixData(StorageType storageType)`
Parameters:
`storageType` - the data type.
• ### Method Detail

• #### instantiate

```public static FloatMatrixData instantiate(float[][] values,
Scale scale,
StorageType storageType)
throws ValueException```
Instantiate a FloatMatrixData with the right data type.
Parameters:
`values` - the (SI) values to store
`scale` - the scale of the unit to use for conversion to SI
`storageType` - the data type to use
Returns:
the FloatMatrixData with the right data type
Throws:
`ValueException` - when values are null, or storageType is null
• #### instantiate

```public static FloatMatrixData instantiate(FloatScalarInterface[][] values,
StorageType storageType)
throws ValueException```
Instantiate a FloatMatrixData with the right data type.
Parameters:
`values` - the values to store
`storageType` - the data type to use
Returns:
the FloatMatrixData with the right data type
Throws:
`ValueException` - when values is null, or storageType is null
• #### getStorageType

`public final StorageType getStorageType()`
Return the StorageType (DENSE, SPARSE, etc.) for the stored Matrix.
Returns:
the StorageType (DENSE, SPARSE, etc.) for the stored Matrix
• #### rows

`public int rows()`
Returns:
the number of rows of the matrix
• #### cols

`public int cols()`
Returns:
the number of columns of the matrix
• #### isSparse

`public boolean isSparse()`
Returns:
whether data type is sparse.
• #### toSparse

`public FloatMatrixDataSparse toSparse()`
Returns:
the sparse transformation of this data
• #### isDense

`public boolean isDense()`
Returns:
whether data type is dense.
• #### toDense

`public FloatMatrixDataDense toDense()`
Returns:
the dense transformation of this data
• #### getSI

```public abstract float getSI(int row,
int col)```
Parameters:
`row` - the row number to get the value for
`col` - the column number to get the value for
Returns:
the value at the [row, col] point
• #### setSI

```public abstract void setSI(int row,
int col,
float valueSI)```
Sets a value at the [row, col] point in the matrix.
Parameters:
`row` - the row number to set the value for
`col` - the column number to set the value for
`valueSI` - the value at the index
• #### cardinality

`public final int cardinality()`
Returns:
the number of non-zero cells.
• #### zSum

`public final float zSum()`
Returns:
the sum of the values of all cells.
• #### copy

`public abstract FloatMatrixData copy()`
Returns:
a deep copy of the data.
• #### getDenseMatrixSI

`public abstract float[][] getDenseMatrixSI()`
Returns:
a safe dense copy of matrixSI as a matrix
• #### getDoubleDenseMatrixSI

`public abstract double[][] getDoubleDenseMatrixSI()`
Returns:
a safe dense copy of matrixSI as a double matrix
• #### plus

```public FloatMatrixData plus(FloatMatrixData right)
throws ValueException```
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.
Parameters:
`right` - the other data object to add
Returns:
the sum of this data object and the other data object
Throws:
`ValueException` - if matrices have different lengths
• #### incrementBy

```public abstract void incrementBy(FloatMatrixData right)
throws ValueException```
Add a matrix to this matrix on a cell-by-cell basis. The type of matrix (sparse, dense) stays the same.
Parameters:
`right` - the other data object to add
Throws:
`ValueException` - if matrices have different lengths
• #### incrementBy

`public void incrementBy(float valueSI)`
Add a number to this matrix on a cell-by-cell basis.
Parameters:
`valueSI` - the value to add
• #### minus

```public FloatMatrixData minus(FloatMatrixData right)
throws ValueException```
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.
Parameters:
`right` - the other data object to subtract
Returns:
the sum of this data object and the other data object
Throws:
`ValueException` - if matrices have different lengths
• #### decrementBy

```public abstract void decrementBy(FloatMatrixData right)
throws ValueException```
Subtract a matrix from this matrix on a cell-by-cell basis. The type of matrix (sparse, dense) stays the same.
Parameters:
`right` - the other data object to subtract
Throws:
`ValueException` - if matrices have different lengths
• #### decrementBy

`public void decrementBy(float valueSI)`
Subtract a number from this matrix on a cell-by-cell basis.
Parameters:
`valueSI` - the value to subtract
• #### times

```public FloatMatrixData times(FloatMatrixData right)
throws ValueException```
Multiply two matrix on a cell-by-cell basis. If both matrices are dense, a dense matrix is returned, otherwise a sparse matrix is returned.
Parameters:
`right` - the other data object to multiply with
Returns:
the sum of this data object and the other data object
Throws:
`ValueException` - if matrices have different lengths
• #### multiplyBy

```public abstract void multiplyBy(FloatMatrixData right)
throws ValueException```
Multiply a matrix with the values of another matrix on a cell-by-cell basis. The type of matrix (sparse, dense) stays the same.
Parameters:
`right` - the other data object to multiply with
Throws:
`ValueException` - if matrices have different lengths
• #### multiplyBy

`public void multiplyBy(float valueSI)`
Multiply the values of this matrix with a number on a cell-by-cell basis.
Parameters:
`valueSI` - the value to multiply with
• #### divide

```public FloatMatrixData divide(FloatMatrixData right)
throws ValueException```
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.
Parameters:
`right` - the other data object to divide by
Returns:
the sum of this data object and the other data object
Throws:
`ValueException` - if matrices have different lengths
• #### divideBy

```public abstract void divideBy(FloatMatrixData right)
throws ValueException```
Divide the values of a matrix by the values of another matrix on a cell-by-cell basis. The type of matrix (sparse, dense) stays the same.
Parameters:
`right` - the other data object to divide by
Throws:
`ValueException` - if matrices have different lengths
• #### divideBy

`public void divideBy(float valueSI)`
Divide the values of this matrix by a number on a cell-by-cell basis.
Parameters:
`valueSI` - the value to multiply with
• #### hashCode

`public int hashCode()`
Overrides:
`hashCode` in class `Object`
• #### equals

`public boolean equals(Object obj)`
Overrides:
`equals` in class `Object`
• #### toString

`public String toString()`
Overrides:
`toString` in class `Object`