Class DenseFloatDataSi

java.lang.Object
org.djunits.vecmat.storage.DenseFloatDataSi
All Implemented Interfaces:
DataGridSi<DenseFloatDataSi>

public class DenseFloatDataSi extends Object implements DataGridSi<DenseFloatDataSi>
DenseFloatData implements a dense data grid for N x M matrices or N x 1 or 1 x N vectors with float values. Calculations are carried out in double precision, so the instantiate() and si() method work with double[]. DenseFloatData always stores a safe copy of the data.

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
  • Constructor Summary

    Constructors
    Constructor
    Description
    DenseFloatDataSi(double[] dataSi, int rows, int cols)
    Instantiate a data object with one array in row-major format.
    DenseFloatDataSi(float[] dataSi, int rows, int cols)
    Instantiate a data object with one array in row-major format.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Return the number of columns in the grid.
    Return a deep copy of the DataGrid object.
    boolean
     
    double
    get(int row, int col)
    Return element (row, col) from the grid as a double value, independent of the fact whether it is stored as a double.
    double[]
    Return a safe copy of the data in row-major format.
    int
     
    instantiateNew(double[] newData)
    Instantiate a new version of the DataGrid object with the given data and the same number of rows and columns.
    instantiateNew(double[] newData, int newRows, int newCols)
    Instantiate a new version of the DataGrid object with the given data and the given number of rows and columns.
    boolean
    Return whether the data is dense.
    boolean
    Return whether the data is double precision.
    int
    Compute and return the number of non-zero cells in this indexed value.
    static <Q extends Quantity<Q>>
    DenseFloatDataSi
    of(double[][] gridInUnit, Unit<?,Q> unit)
    Instantiate a data object with a double[rows][cols].
    static <Q extends Quantity<Q>>
    DenseFloatDataSi
    of(double[] dataInUnit, int rows, int cols, Unit<?,Q> unit)
    Instantiate a data object with one array in row-major format.
    static <Q extends Quantity<Q>>
    DenseFloatDataSi
    of(float[][] gridInUnit, Unit<?,Q> unit)
    Instantiate a data object with a float[rows][cols].
    static <Q extends Quantity<Q>>
    DenseFloatDataSi
    of(float[] dataInUnit, int rows, int cols, Unit<?,Q> unit)
    Instantiate a data object with one array in row-major format.
    static <Q extends Quantity<Q>>
    DenseFloatDataSi
    of(Q[][] grid)
    Instantiate a data object with a Q[rows][cols].
    static <Q extends Quantity<Q>>
    DenseFloatDataSi
    of(Q[] data, int rows, int cols)
    Instantiate a data object with one array in row-major format.
    ofSi(double[][] gridSi)
    Instantiate a data object with a double[rows][cols].
    ofSi(double[] dataSi, int rows, int cols)
    Instantiate a data object with one array in row-major format.
    ofSi(float[][] gridSi)
    Instantiate a data object with a float[rows][cols].
    ofSi(float[] dataSi, int rows, int cols)
    Instantiate a data object with one array in row-major format.
    int
    Return the number of rows in the grid.
    double[]
    Return the data in row-major format.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.djunits.vecmat.storage.DataGridSi

    equals, getColArray, getRowArray, isFloat, isSparse, nnz
  • Constructor Details

    • DenseFloatDataSi

      public DenseFloatDataSi(float[] dataSi, int rows, int cols)
      Instantiate a data object with one array in row-major format. NO safe copy of the data is stored. The constructor is very useful to store data after a calculation that already made a new safe copy.
      Parameters:
      dataSi - the data with SI-values in row-major format
      rows - the number of rows
      cols - the number of columns
      Throws:
      IllegalArgumentException - when the size of the data object is not equal to rows*cols, or when the number of rows or columns is not positive
    • DenseFloatDataSi

      public DenseFloatDataSi(double[] dataSi, int rows, int cols)
      Instantiate a data object with one array in row-major format. A safe copy of the data is stored, since the data has to be transferred from double format to float format.
      Parameters:
      dataSi - the data with SI-values in row-major format
      rows - the number of rows
      cols - the number of columns
      Throws:
      IllegalArgumentException - when the size of the data object is not equal to rows*cols, or when the number of rows or columns is not positive
  • Method Details

    • ofSi

      public static DenseFloatDataSi ofSi(float[] dataSi, int rows, int cols)
      Instantiate a data object with one array in row-major format. A safe copy of the data is stored.
      Parameters:
      dataSi - the data with SI-values in row-major format
      rows - the number of rows
      cols - the number of columns
      Returns:
      a dense float data object with SI values for vectors, matrices and tables
      Throws:
      IllegalArgumentException - when the size of the data object is not equal to rows*cols, or when the number of rows or columns is not positive
    • ofSi

      public static DenseFloatDataSi ofSi(double[] dataSi, int rows, int cols)
      Instantiate a data object with one array in row-major format. A safe copy of the data is stored.
      Parameters:
      dataSi - the data with SI-values in row-major format
      rows - the number of rows
      cols - the number of columns
      Returns:
      a dense float data object with SI values for vectors, matrices and tables
      Throws:
      IllegalArgumentException - when the size of the data object is not equal to rows*cols, or when the number of rows or columns is not positive
    • of

      public static <Q extends Quantity<Q>> DenseFloatDataSi of(float[] dataInUnit, int rows, int cols, Unit<?,Q> unit)
      Instantiate a data object with one array in row-major format. A safe copy of the data is stored.
      Type Parameters:
      Q - the quantity type
      Parameters:
      dataInUnit - the data expressed in the given unit in row-major format
      rows - the number of rows
      cols - the number of columns
      unit - the unit of the data
      Returns:
      a dense float data object with SI values for vectors, matrices and tables
      Throws:
      IllegalArgumentException - when the size of the data object is not equal to rows*cols, or when the number of rows or columns is not positive
    • of

      public static <Q extends Quantity<Q>> DenseFloatDataSi of(double[] dataInUnit, int rows, int cols, Unit<?,Q> unit)
      Instantiate a data object with one array in row-major format. A safe copy of the data is stored.
      Type Parameters:
      Q - the quantity type
      Parameters:
      dataInUnit - the data expressed in the given unit in row-major format
      rows - the number of rows
      cols - the number of columns
      unit - the unit of the data
      Returns:
      a dense float data object with SI values for vectors, matrices and tables
      Throws:
      IllegalArgumentException - when the size of the data object is not equal to rows*cols, or when the number of rows or columns is not positive
    • of

      public static <Q extends Quantity<Q>> DenseFloatDataSi of(Q[] data, int rows, int cols)
      Instantiate a data object with one array in row-major format. A safe copy of the data is stored.
      Type Parameters:
      Q - the quantity type
      Parameters:
      data - the quantity data in row-major format
      rows - the number of rows
      cols - the number of columns
      Returns:
      a dense float data object with SI values for vectors, matrices and tables
      Throws:
      IllegalArgumentException - when the size of the data object is not equal to rows*cols, or when the number of rows or columns is not positive
    • ofSi

      public static DenseFloatDataSi ofSi(double[][] gridSi)
      Instantiate a data object with a double[rows][cols]. A safe copy of the data is stored.
      Parameters:
      gridSi - the data as a double[][] array in row-major format, with SI-values
      Returns:
      a dense float data object with SI values for vectors, matrices and tables
      Throws:
      IllegalArgumentException - when the size of the data object is not equal to rows*cols
    • ofSi

      public static DenseFloatDataSi ofSi(float[][] gridSi)
      Instantiate a data object with a float[rows][cols]. A safe copy of the data is stored.
      Parameters:
      gridSi - the data as a float[][] array in row-major format, with SI-values
      Returns:
      a dense float data object with SI values for vectors, matrices and tables
      Throws:
      IllegalArgumentException - when the size of the data object is not equal to rows*cols
    • of

      public static <Q extends Quantity<Q>> DenseFloatDataSi of(double[][] gridInUnit, Unit<?,Q> unit)
      Instantiate a data object with a double[rows][cols]. A safe copy of the data is stored.
      Type Parameters:
      Q - the quantity type
      Parameters:
      gridInUnit - the data as a double[][] array in row-major format, expressed in the given unit
      unit - the unit of the data
      Returns:
      a dense float data object with SI values for vectors, matrices and tables
      Throws:
      IllegalArgumentException - when the size of the data object is not equal to rows*cols
    • of

      public static <Q extends Quantity<Q>> DenseFloatDataSi of(float[][] gridInUnit, Unit<?,Q> unit)
      Instantiate a data object with a float[rows][cols]. A safe copy of the data is stored.
      Type Parameters:
      Q - the quantity type
      Parameters:
      gridInUnit - the data as a double[][] array in row-major format, expressed in the given unit
      unit - the unit of the data
      Returns:
      a dense float data object with SI values for vectors, matrices and tables
      Throws:
      IllegalArgumentException - when the size of the data object is not equal to rows*cols
    • of

      public static <Q extends Quantity<Q>> DenseFloatDataSi of(Q[][] grid)
      Instantiate a data object with a Q[rows][cols]. A safe copy of the data is stored.
      Type Parameters:
      Q - the quantity type
      Parameters:
      grid - the quantities as a [][] array in row-major format
      Returns:
      a dense float data object with SI values for vectors, matrices and tables
      Throws:
      IllegalArgumentException - when the size of the data object is not equal to rows*cols
    • rows

      public int rows()
      Description copied from interface: DataGridSi
      Return the number of rows in the grid.
      Specified by:
      rows in interface DataGridSi<DenseFloatDataSi>
      Returns:
      the number of rows in the grid
    • cols

      public int cols()
      Description copied from interface: DataGridSi
      Return the number of columns in the grid.
      Specified by:
      cols in interface DataGridSi<DenseFloatDataSi>
      Returns:
      the number of columns in the grid
    • isDense

      public boolean isDense()
      Description copied from interface: DataGridSi
      Return whether the data is dense.
      Specified by:
      isDense in interface DataGridSi<DenseFloatDataSi>
      Returns:
      whether the data is dense
    • isDouble

      public boolean isDouble()
      Description copied from interface: DataGridSi
      Return whether the data is double precision.
      Specified by:
      isDouble in interface DataGridSi<DenseFloatDataSi>
      Returns:
      whether the data is double precision
    • get

      public double get(int row, int col)
      Description copied from interface: DataGridSi
      Return element (row, col) from the grid as a double value, independent of the fact whether it is stored as a double. Note that row and col are 0-based for fast calculations.
      Specified by:
      get in interface DataGridSi<DenseFloatDataSi>
      Parameters:
      row - the row number (0-based)
      col - the column number (0-based)
      Returns:
      element (row, col) from the grid as a double value
    • getSiArray

      public double[] getSiArray()
      Description copied from interface: DataGridSi
      Return a safe copy of the data in row-major format.
      Specified by:
      getSiArray in interface DataGridSi<DenseFloatDataSi>
      Returns:
      the data in row-major format
    • unsafeSiArray

      public double[] unsafeSiArray()
      Description copied from interface: DataGridSi
      Return the data in row-major format. When the data is available in the correct format, NO safe copy is made.
      Specified by:
      unsafeSiArray in interface DataGridSi<DenseFloatDataSi>
      Returns:
      the data in row-major format
    • copy

      public DenseFloatDataSi copy()
      Description copied from interface: DataGridSi
      Return a deep copy of the DataGrid object.
      Specified by:
      copy in interface DataGridSi<DenseFloatDataSi>
      Returns:
      a deep copy of the DataGrid object
    • nonZeroCount

      public int nonZeroCount()
      Description copied from interface: DataGridSi
      Compute and return the number of non-zero cells in this indexed value. Counts entries that are not exactly 0.0 (including -0.0 as zero). NaN and infinite values are counted as non-zero.
      Specified by:
      nonZeroCount in interface DataGridSi<DenseFloatDataSi>
      Returns:
      the number of non-zero cells
    • instantiateNew

      public DenseFloatDataSi instantiateNew(double[] newData)
      Description copied from interface: DataGridSi
      Instantiate a new version of the DataGrid object with the given data and the same number of rows and columns.
      Specified by:
      instantiateNew in interface DataGridSi<DenseFloatDataSi>
      Parameters:
      newData - the data in row-major format
      Returns:
      a new version of the DataGrid object with the given data, same number of rows and columns
    • instantiateNew

      public DenseFloatDataSi instantiateNew(double[] newData, int newRows, int newCols)
      Description copied from interface: DataGridSi
      Instantiate a new version of the DataGrid object with the given data and the given number of rows and columns.
      Specified by:
      instantiateNew in interface DataGridSi<DenseFloatDataSi>
      Parameters:
      newData - the data in row-major format
      newRows - the new number of rows
      newCols - the new number of columms
      Returns:
      a new version of the DataGrid object with the given data, new number of rows and columns
    • hashCode

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

      public boolean equals(Object obj)
      Overrides:
      equals in class Object