Class ComplexCsrManipulations
java.lang.Object
org.flag4j.operations.sparse.csr.complex.ComplexCsrManipulations
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
(CsrCMatrix 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
(CsrCMatrix 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
swapCols
(CsrCMatrix src, int colIdx1, int colIdx2) Swaps two columns in a sparse CSR matrix.static void
swapRows
(CsrCMatrix src, int rowIdx1, int rowIdx2) Swaps two rows in a complex sparse CSR matrix.
-
Constructor Details
-
ComplexCsrManipulations
private ComplexCsrManipulations()
-
-
Method Details
-
swapRows
Swaps two rows in a complex 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
).
-