Class RealSparseMatrixManipulations
java.lang.Object
org.flag4j.operations.sparse.coo.real.RealSparseMatrixManipulations
This class contains implementations for real sparse matrix manipulations.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate static void
copyRanges
(CooMatrix src, double[] entries, int[] rowIndices, int[] colIndices, int[] startEnd) A helper method which copies from a sparse matrix to a set of three arrays (non-zero entries, row indices, and column indices) but skips over a specified range.static CooMatrix
Removes a specified column from a sparse matrix.static CooMatrix
removeCols
(CooMatrix src, int... colIdxs) Removes a list of specified columns from a sparse matrix.static CooMatrix
Removes a specified row from a sparse matrix.static CooMatrix
removeRows
(CooMatrix src, int... rowIdxs) Removes multiple rows from a real sparse matrix.static CooMatrix
Swaps two columns, in place, in a sparse matrix.static CooMatrix
Swaps two rows, in place, in a sparse matrix.
-
Constructor Details
-
RealSparseMatrixManipulations
private RealSparseMatrixManipulations()
-
-
Method Details
-
removeRow
Removes a specified row from a sparse matrix.- Parameters:
src
- Source matrix to remove row from.rowIdx
- Row to remove from thesrc
matrix.- Returns:
- A sparse matrix which has one less row than the
src
matrix with the specified row removed.
-
removeRows
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 thesrc
matrix. This array is assumed to be sorted and contain unique indices (however, this is not checked or enforced). If it is not sorted, callArrays.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
Removes a specified column from a sparse matrix.- Parameters:
src
- Source matrix to remove column from.colIdx
- Column to remove from thesrc
matrix.- Returns:
- A sparse matrix which has one less column than the
src
matrix with the specified column removed.
-
removeCols
Removes a list of specified columns from a sparse matrix.- Parameters:
src
- Source matrix to remove columns from.colIdxs
- Columns to remove from thesrc
matrix.- Returns:
- A copy of the
src
sparse matrix with the specified columns removed.
-
copyRanges
private static void copyRanges(CooMatrix src, double[] entries, int[] rowIndices, int[] colIndices, int[] startEnd) A helper method which copies from a sparse matrix to a set of three arrays (non-zero entries, row indices, and column indices) but skips over a specified range.- Parameters:
src
- Source sparse matrix to copy from.entries
- Array to copy src non-zero entries to.rowIndices
- Array to copy src row indices entries to.colIndices
- Array to copy src column indices entries to.startEnd
- An array of length two specifying thestart
(inclusive) andend
(exclusive) indices of the range to skip during the copy.
-
swapRows
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
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.
-