Class DenseOps

java.lang.Object
org.flag4j.linalg.ops.dense.DenseOps

public final class DenseOps extends Object
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> void
    swapCols(Shape shape, T[] data, int colIdx1, int colIdx2)
    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
    swapRows(Shape shape, T[] data, int rowIdx1, int rowIdx2)
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • swapRows

      public static <T> void swapRows(Shape shape, T[] data, int rowIdx1, int rowIdx2)
      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 - If shape.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 and rowIdx2 and between columns start (inclusive) and stop (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

      public static <T> void swapCols(Shape shape, T[] data, int colIdx1, int colIdx2)
      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 - If shape.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 and colIdx2 and between rows start (inclusive) and stop (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).