Module ojalgo

Class R064CSR

    • Constructor Detail

      • R064CSR

        R064CSR​(int nbRows,
                int nbCols,
                double[] elementValues,
                int[] columnIndices,
                int[] rowPointers)
        Creates a new CSR matrix store.
        Parameters:
        nbRows - The number of rows in the matrix
        nbCols - The number of columns in the matrix
        elementValues - Array containing the non-zero values
        columnIndices - Array containing the column index for each non-zero value
        rowPointers - Array containing the starting position in values/columnIndices for each row
    • Method Detail

      • doubleValue

        public double doubleValue​(int row,
                                  int col)
        Gets the value at the specified row and column. Returns 0.0 if the element is not stored (i.e., is zero).
        Parameters:
        row - The row index
        col - The column index
        Returns:
        The value at the specified position, or 0.0 if not stored
      • firstInColumn

        public int firstInColumn​(int col)
        Description copied from interface: Structure2D
        The default value is simply 0, and if all elements are zeros then this.countRows().
        Parameters:
        col - The column index
        Returns:
        The row index of the first non-zero element in the specified column
      • firstInRow

        public int firstInRow​(int row)
        Description copied from interface: Structure2D
        The default value is simply 0, and if all elements are zeros then this.countColumns().
        Returns:
        The column index of the first non-zero element in the specified row
      • limitOfColumn

        public int limitOfColumn​(int col)
        Description copied from interface: Structure2D
        The default value is simply this.countRows(), and if all elements are zeros then 0.
        Specified by:
        limitOfColumn in interface Structure2D
        Overrides:
        limitOfColumn in class AbstractStore<java.lang.Double>
        Returns:
        The row index of the first zero element, after all non-zeros, in the specified column (index of the last non-zero + 1)
      • limitOfRow

        public int limitOfRow​(int row)
        Description copied from interface: Structure2D
        The default value is simply this.countColumns(), and if all elements are zeros then 0.
        Specified by:
        limitOfRow in interface Structure2D
        Overrides:
        limitOfRow in class AbstractStore<java.lang.Double>
        Returns:
        The column index of the first zero element, after all non-zeros, in the specified row (index of the last non-zero + 1)
      • multiply

        public void multiply​(Access1D<java.lang.Double> right,
                             TransformableRegion<java.lang.Double> target)
        Performs matrix-vector multiplication using the CSR format. This implementation is optimized for the CSR format by iterating over non-zero elements row by row and accumulating the results.
        Parameters:
        right - The vector to multiply with
        target - The target vector to store the result
      • nonzeros

        public R064CSR.NonZeroView nonzeros()
        Description copied from interface: Access1D
        Similar to Access1D.elements() but avoids elements that are structurally known to be zero. (That does not eliminate all zero-values from this view.) With an arbitrary (dense) unstructured implementation the Access1D.nonzeros() and Access1D.elements() methods do the same thing! Only some specific implementations are able to actually exploit structure/sparsity to view fewer elements.