Class DenseDoubleDataSi

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

public class DenseDoubleDataSi extends Object implements DataGridSi<DenseDoubleDataSi>
DenseDoubleData implements a dense data grid for N x M matrices or N x 1 or 1 x M vectors with double values.

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
    DenseDoubleDataSi(double[][] data)
    Instantiate a data object with a double[rows][cols].
    DenseDoubleDataSi(double[] data, int rows, int cols)
    Instantiate a data object with one array in row-major format.
    DenseDoubleDataSi(Q[][] data)
    Instantiate a data object with a Q[rows][cols].
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Compute and return the number of non-zero cells in this indexed value.
    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 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
    Return the number of rows in the grid.

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

    • DenseDoubleDataSi

      public DenseDoubleDataSi(double[] data, int rows, int cols)
      Instantiate a data object with one array in row-major format. Note that NO safe copy of the data is stored.
      Parameters:
      data - the data 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
    • DenseDoubleDataSi

      public DenseDoubleDataSi(double[][] data)
      Instantiate a data object with a double[rows][cols]. A safe copy of the data is stored.
      Parameters:
      data - the data in row-major format
      Throws:
      IllegalArgumentException - when the size of the data object is not equal to rows*cols
    • DenseDoubleDataSi

      public DenseDoubleDataSi(Q[][] data)
      Instantiate a data object with a Q[rows][cols]. A safe copy of the data is stored.
      Type Parameters:
      Q - the quantity type
      U - the unit type
      Parameters:
      data - the data in row-major format
      Throws:
      IllegalArgumentException - when the size of the data object is not equal to rows*cols
  • Method Details

    • rows

      public int rows()
      Description copied from interface: DataGridSi
      Return the number of rows in the grid.
      Specified by:
      rows in interface DataGridSi<DenseDoubleDataSi>
      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<DenseDoubleDataSi>
      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<DenseDoubleDataSi>
      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<DenseDoubleDataSi>
      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<DenseDoubleDataSi>
      Parameters:
      row - the row number (0-based)
      col - the column number (0-based)
      Returns:
      element (row, col) from the grid as a double value
    • getDataArray

      public double[] getDataArray()
      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:
      getDataArray in interface DataGridSi<DenseDoubleDataSi>
      Returns:
      the data in row-major format
    • copy

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

      public int cardinality()
      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:
      cardinality in interface DataGridSi<DenseDoubleDataSi>
      Returns:
      the number of non-zero cells
    • instantiateNew

      public DenseDoubleDataSi 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<DenseDoubleDataSi>
      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 DenseDoubleDataSi 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<DenseDoubleDataSi>
      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