Class RealCsrManipulations
java.lang.Object
org.flag4j.operations.sparse.csr.real.RealCsrManipulations
Utility class for manipulating
real sparse CSR matrices
(e.g. row swaps, column swaps,
etc.).-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate static void
moveAndShiftLeft
(CsrMatrix src, int newColIdx, int currPos, int newPos) Moves a non-zero value in a row of a CSR matrix to a new column to the right of its current column.private static void
moveAndShiftRight
(CsrMatrix src, int newColIdx, int currPos, int newPos) Moves a non-zero value in a row of a CSR matrix to a new column to the left of its current column.static void
Swaps two columns in a sparse CSR matrix.static void
Swaps two rows in a sparse CSR matrix.
-
Constructor Details
-
RealCsrManipulations
private RealCsrManipulations()
-
-
Method Details
-
swapRows
Swaps two rows in a sparse CSR matrix. This is done in place.- Parameters:
src
- The matrix to swap rows within, done in place.rowIdx1
- Index of the first row to swap.rowIdx2
- Index of the second row to swap.- Throws:
IndexOutOfBoundsException
- If eitherrowIdx1
orrowIdx2
is out of bounds of the rows of this matrix.
-
swapCols
Swaps two columns in a sparse CSR matrix. This is done in place.- Parameters:
src
- The matrix to swap rows within, done in place.colIdx1
- Index of the first column to swap.colIdx2
- Index of the second column to swap.- Throws:
IndexOutOfBoundsException
- If eithercolIndex1
orcolIndex2
is out of bounds of the columns of this matrix.
-
moveAndShiftRight
Moves a non-zero value in a row of a CSR matrix to a new column to the left of its current column. The new column is assumed to contain a zero. To accommodate this move, all entries between the columns are shifted right within the non-zero entries array.- Parameters:
src
- Source matrix to perform the move and shift within (modified).newColIdx
- New column for the value to be moved to within the row.currPos
- Current index of the value within the non-zero entries ofsrc
(assumed to be in the same row asnewPos
).newPos
- New index for the value to be moved to within the non-zero entries ofsrc
(assumed to be in the same row ascurrPos
).
-
moveAndShiftLeft
Moves a non-zero value in a row of a CSR matrix to a new column to the right of its current column. The new column is assumed to contain a zero. To accommodate this move, all entries between the columns are shifted left within the non-zero entries array.- Parameters:
src
- Source matrix to perform the move and shift within (modified).newColIdx
- New column for the value to be moved to within the row.currPos
- Current index of the value within the non-zero entries ofsrc
(assumed to be in the same row asnewPos
).newPos
- New index for the value to be moved to within the non-zero entries ofsrc
(assumed to be in the same row ascurrPos
).
-