Class RealSparseMatrixManipulations

java.lang.Object
org.flag4j.linalg.ops.sparse.coo.real.RealSparseMatrixManipulations

public final class RealSparseMatrixManipulations extends Object
This utility class contains implementations for real sparse COO matrix manipulations.
  • Method Details

    • removeRow

      public static CooMatrix removeRow(CooMatrix src, int rowIdx)
      Removes a specified row from a sparse matrix.
      Parameters:
      src - Source matrix to remove row from.
      rowIdx - Row to remove from the src matrix.
      Returns:
      A sparse matrix which has one less row than the src matrix with the specified row removed.
    • removeRows

      public static CooMatrix removeRows(CooMatrix src, int... rowIdxs)
      Removes multiple rows from a real sparse matrix.
      Parameters:
      src - The source sparse matrix to remove rows from.
      rowIdxs - Indices of rows to remove from the src matrix. This array is assumed to be sorted and contain unique indices (however, this is not checked or enforced). If it is not sorted, call Arrays.sort(int[]) first otherwise the behavior of this method is not defined.
      Returns:
      A copy of the src matrix with the specified rows removed.
    • removeCol

      public static CooMatrix removeCol(CooMatrix src, int colIdx)
      Removes a specified column from a sparse matrix.
      Parameters:
      src - Source matrix to remove column from.
      colIdx - Column to remove from the src matrix.
      Returns:
      A sparse matrix which has one less column than the src matrix with the specified column removed.
    • removeCols

      public static CooMatrix removeCols(CooMatrix src, int... colIdxs)
      Removes a list of specified columns from a sparse matrix.
      Parameters:
      src - Source matrix to remove columns from.
      colIdxs - Columns to remove from the src matrix.
      Returns:
      A copy of the src sparse matrix with the specified columns removed.
    • swapRows

      public static CooMatrix swapRows(CooMatrix src, int rowIdx1, int rowIdx2)
      Swaps two rows, in place, in a sparse matrix.
      Parameters:
      src - The source sparse matrix to swap rows within.
      rowIdx1 - Index of the first row in the swap.
      rowIdx2 - Index of the second row in the swap.
      Returns:
      A reference to the src sparse matrix.
    • swapCols

      public static CooMatrix swapCols(CooMatrix src, int colIdx1, int colIdx2)
      Swaps two columns, in place, in a sparse matrix.
      Parameters:
      src - The source sparse matrix to swap columns within.
      colIdx1 - Index of the first row in the swap.
      colIdx2 - Index of the second row in the swap.
      Returns:
      A reference to the src sparse matrix.