Class DenseOps
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> void
Swaps specified columns in the matrix.static <T> void
swapColsUnsafe
(Shape shape, T[] data, int colIdx1, int colIdx2, int start, int stop) Swaps two columns, over a specified range of rows, within a matrix.static <T> void
Swaps specified rows in the matrix.static <T> void
swapRowsUnsafe
(Shape shape, T[] data, int rowIdx1, int rowIdx2, int start, int stop) Swaps two rows, over a specified range of columns, within a matrix.
-
Method Details
-
swapRows
Swaps specified rows in the matrix. This is done in place.- Parameters:
shape
- Shape of the matrix.data
- Data of the matrix (modified).rowIndex1
- Index of the first row to swap.rowIndex2
- Index of the second row to swap.- Throws:
LinearAlgebraException
- Ifshape.getRank() != 2
.IndexOutOfBoundsException
- If either index is outside the matrix bounds.
-
swapRowsUnsafe
public static <T> void swapRowsUnsafe(Shape shape, T[] data, int rowIdx1, int rowIdx2, int start, int stop) Swaps two rows, over a specified range of columns, within a matrix. Specifically, all elements in the matrix within rows
rowIdx1
androwIdx2
and between columnsstart
(inclusive) andstop
(exclusive). This operation is done in place.No bounds checking is done within this method to ensure that the indices provided are valid. As such, it is highly recommended to us
swapRows(Shape, Object[], int, int)
in most cases.- Parameters:
shape
- Shape of the matrix.data
- Data of the matrix (modified).rowIdx1
- Index of the first row to swap.rowIdx2
- Index of the second row to swap.start
- Index of the column specifying the start of the range for the row swap (inclusive).stop
- Index of the column specifying the end of the range for the row swap (exclusive).
-
swapCols
Swaps specified columns in the matrix. This is done in place.- Parameters:
shape
- Shape of the matrix.data
- Data of the matrix (modified).rowIndex1
- Index of the first column to swap.rowIndex2
- Index of the second column to swap.- Throws:
LinearAlgebraException
- Ifshape.getRank() != 2
.IndexOutOfBoundsException
- If either index is outside the matrix bounds.
-
swapColsUnsafe
public static <T> void swapColsUnsafe(Shape shape, T[] data, int colIdx1, int colIdx2, int start, int stop) Swaps two columns, over a specified range of rows, within a matrix. Specifically, all elements in the matrix within columns
colIdx1
andcolIdx2
and between rowsstart
(inclusive) andstop
(exclusive). This operation is done in place.No bounds checking is done within this method to ensure that the indices provided are valid. As such, it is highly recommended to us
swapCols(Shape, Object[], int, int)
in most cases.- Parameters:
shape
- Shape of the matrix.data
- Data of the matrix (modified).colIdx1
- Index of the first column to swap.colIdx2
- Index of the second column to swap.start
- Index of the row specifying the start of the range for the row swap (inclusive).stop
- Index of the row specifying the end of the range for the row swap (exclusive).
-