Class DenseMatrix

java.lang.Object
jline.util.matrix.BaseMatrix
jline.util.matrix.DenseMatrix
All Implemented Interfaces:
Serializable

public abstract class DenseMatrix extends BaseMatrix
Base class for dense matrix implementations, containing the core data structure and methods that directly manipulate the underlying dense matrix representation.

This class encapsulates all interactions with EJML's DMatrixRMaj and CommonOps_DDRM classes, providing a clean abstraction layer for dense matrix operations. It serves as the foundation for concrete dense matrix implementations.

The class provides:

  • Basic matrix operations (get, set, dimensions)
  • Encapsulated CommonOps_DDRM method calls
  • Memory management for dense matrix data structures
  • Utility methods for matrix manipulation

Dense matrices store all elements (including zeros) explicitly, making them suitable for matrices with a high percentage of non-zero elements or when dense linear algebra operations are required.

Since:
1.0
Author:
QORE Lab, Imperial College London
See Also:
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Protected constructor for delayed initialization.
     
    DenseMatrix(int numRows, int numCols)
    Constructs a dense matrix with specified dimensions.
    protected
    Copy constructor for creating a new dense matrix from an existing one.
     
    DenseMatrix(org.ejml.data.DMatrix matrix)
    Constructs a dense matrix by copying an existing DMatrix.
     
    DenseMatrix(org.ejml.data.DMatrixRMaj matrix)
    Constructs a dense matrix by copying an existing EJML dense matrix.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Replaces each value in the matrix with its absolute value, in-place.
    protected void
    add(double alpha, org.ejml.data.DMatrix A, double beta, org.ejml.data.DMatrix B, org.ejml.data.DMatrix output)
    Performs the operation: output = alpha*A + beta*B.
    protected org.ejml.data.DMatrix
    addMatrices(double alpha, org.ejml.data.DMatrix A, double beta, org.ejml.data.DMatrix B, org.ejml.data.DMatrix output)
    Performs the operation: output = alpha*A + beta*B.
    protected void
    addMatricesInPlace(double alpha, org.ejml.data.DMatrix A, double beta, org.ejml.data.DMatrix B, org.ejml.data.DMatrix output)
     
    protected static void
    addMatricesInPlaceStatic(double alpha, org.ejml.data.DMatrix A, double beta, org.ejml.data.DMatrix B, org.ejml.data.DMatrix output)
     
    protected static org.ejml.data.DMatrixRMaj
    addMatricesStatic(double alpha, org.ejml.data.DMatrix A, double beta, org.ejml.data.DMatrix B, org.ejml.data.DMatrix output)
     
    protected static org.ejml.data.DMatrixRMaj
    addStatic(org.ejml.data.DMatrixRMaj A, org.ejml.data.DMatrixRMaj B, org.ejml.data.DMatrixRMaj output)
    Performs element-wise addition of two dense matrices: output = A + B.
    boolean
    any()
    Checks if the current matrix contains any non-zero elements.
    protected void
    applyConditionalTransform(double source, double target, double tol, String operation)
    Applies a transformation to matrix elements based on conditions.
    protected void
     
    protected static void
    changeSignStatic(org.ejml.data.DMatrix input, org.ejml.data.DMatrix output)
     
    void
    colIncrease(int col, double a)
    Adds a scalar value to each element in the specified column.
    protected void
    concatColumnsInPlace(org.ejml.data.DMatrix left, org.ejml.data.DMatrix right, org.ejml.data.DMatrix output)
    Concatenates matrices column-wise.
    protected void
    concatRowsInPlace(org.ejml.data.DMatrix top, org.ejml.data.DMatrix bottom, org.ejml.data.DMatrix output)
    Concatenates matrices row-wise.
    abstract BaseMatrix
    Creates and returns a deep copy of this dense matrix.
    countEachRow(double val)
    Counts occurrences of each unique value in each row.
    protected abstract BaseMatrix
    createNewInstance(int rows, int cols, int nzLength)
    Creates a new instance of the concrete dense matrix implementation.
    protected double
     
    protected static double
    determinantStatic(org.ejml.data.DMatrix matrix)
     
    protected void
    divideInPlace(double scalar)
     
    protected void
    divideMatrix(double scalar, org.ejml.data.DMatrix output)
     
    protected void
    divideRowsByArray(double[] diag, int offset)
     
    protected void
    divideScalarByMatrix(double scalar, org.ejml.data.DMatrix output)
     
    protected double
     
    protected double
     
    protected double
     
    protected org.ejml.data.DMatrix
    elementMult(org.ejml.data.DMatrix A, org.ejml.data.DMatrix B, org.ejml.data.DMatrix output)
     
    protected static org.ejml.data.DMatrixRMaj
    elementMultStatic(org.ejml.data.DMatrix A, org.ejml.data.DMatrix B, org.ejml.data.DMatrix output)
     
    protected double
     
    abstract boolean
    Indicates whether some other object is "equal to" this dense matrix.
    protected void
    extractMatrix(org.ejml.data.DMatrix src, int srcX0, int srcX1, int srcY0, int srcY1, org.ejml.data.DMatrix dst, int dstY0, int dstX0)
     
    protected static void
    extractMatrixStatic(org.ejml.data.DMatrix src, int srcX0, int srcX1, int srcY0, int srcY1, org.ejml.data.DMatrix dst, int dstY0, int dstX0)
     
    protected void
    fillMatrix(double value)
    Fills the matrix with the specified value.
    protected static void
    fillMatrixStatic(org.ejml.data.DMatrix matrix, double value)
     
    Returns a matrix containing indices of all non-negative elements.
    double
    get(int row, int col)
    Returns the value at the specified matrix position.
    protected int
    getColumnIndex(int col)
     
    protected int[]
     
    protected org.ejml.data.DMatrixRMaj
    Returns the underlying EJML dense matrix data structure.
    int
    Returns the number of stored non-zero elements.
    protected int
    getNonZeroRow(int index)
     
    int[]
    Returns array of row indices of non-zero entries.
    int
    Returns the number of non-zero elements in the matrix.
    protected double
    getNonZeroValue(int index)
     
    double[]
    Returns array of non-zero values.
    int
    Returns the number of columns in the matrix.
    int
    Returns the number of rows in the matrix.
    boolean
    Checks if the matrix contains duplicate values.
    boolean
    Checks if the matrix contains any finite (non-infinite, non-NaN) values.
    boolean
    Checks if the matrix contains any infinite values.
    boolean
    Checks if more than one finite value exists.
    boolean
    Checks if the matrix contains any NaN values.
    protected static org.ejml.data.DMatrixRMaj
    identityStatic(int size)
    Creates an identity matrix of the specified size.
    protected static void
    invertStatic(org.ejml.data.DMatrix input, org.ejml.data.DMatrix output)
     
    protected static org.ejml.data.DMatrixRMaj
    kronStatic(org.ejml.data.DMatrixRMaj A, org.ejml.data.DMatrixRMaj B, org.ejml.data.DMatrixRMaj output)
    Computes the Kronecker product of two dense matrices: A \otimes B.
    protected void
    mult(org.ejml.data.DMatrix A, org.ejml.data.DMatrix B, org.ejml.data.DMatrix output)
    Performs matrix multiplication: output = A * B.
    protected org.ejml.data.DMatrix
    multMatrix(org.ejml.data.DMatrix B, org.ejml.data.DMatrix output)
    Performs matrix multiplication with sparse matrices.
    protected static org.ejml.data.DMatrixRMaj
    multMatrixStatic(org.ejml.data.DMatrix A, org.ejml.data.DMatrix B, org.ejml.data.DMatrix output)
     
    protected void
    Removes zero-valued elements from the matrix with default tolerance.
    protected void
    removeZerosWithTol(double tolerance)
    Removes zero-valued elements from the matrix with specified tolerance.
    void
    reshape(int numRows, int numCols)
    Reshapes the matrix to the specified dimensions.
    protected void
    scaleInPlace(double alpha)
    Scales the matrix in-place by the specified factor.
    protected void
    scaleMatrix(double scalar, org.ejml.data.DMatrix output)
     
    protected static void
    scaleMatrixStatic(double scalar, org.ejml.data.DMatrix input, org.ejml.data.DMatrix output)
     
    void
    set(int row, int col, double value)
    Sets the value at the specified matrix position.
    protected void
    setColumnIndex(int col, int value)
     
    protected void
    setData(Object newData)
    Sets the underlying data structure.
    void
    setData(org.ejml.data.DMatrix newData)
    Sets the underlying EJML dense matrix data structure.
    protected void
    setData(org.ejml.data.DMatrixRMaj newData)
    Sets the underlying EJML dense matrix data structure.
    protected void
    setNonZeroLength(int length)
     
    protected void
    setNonZeroRow(int index, int row)
     
    protected void
    setNonZeroValue(int index, double value)
     
    void
    shrinkNumCols(int newmax)
    Reduce the maximum number of columns by setting the internal column count.
    void
    shrinkNumRows(int newmax)
    Reduce the maximum number of rows by setting the internal row count.
    protected org.ejml.data.DMatrix
     
    protected org.ejml.data.DMatrix
     
    Returns a string representation of the matrix.
    protected void
    transpose(org.ejml.data.DMatrix input, org.ejml.data.DMatrix output)
    Computes the transpose of the input matrix.
    protected void
    transposeMatrix(org.ejml.data.DMatrix output)
    Computes the transpose of this matrix.
    protected static void
    transposeMatrixStatic(org.ejml.data.DMatrix input, org.ejml.data.DMatrix output)
     
    void
    Sets all elements in the matrix to zero.

    Methods inherited from class jline.util.matrix.BaseMatrix

    getNumNonZeros

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • DenseMatrix

      public DenseMatrix(int numRows, int numCols)
      Constructs a dense matrix with specified dimensions. All elements are initialized to zero.
      Parameters:
      numRows - the number of rows in the matrix
      numCols - the number of columns in the matrix
    • DenseMatrix

      public DenseMatrix(org.ejml.data.DMatrixRMaj matrix)
      Constructs a dense matrix by copying an existing EJML dense matrix.
      Parameters:
      matrix - the EJML dense matrix to copy
    • DenseMatrix

      public DenseMatrix(org.ejml.data.DMatrix matrix)
      Constructs a dense matrix by copying an existing DMatrix.
      Parameters:
      matrix - the DMatrix to copy
    • DenseMatrix

      protected DenseMatrix(DenseMatrix matrix)
      Copy constructor for creating a new dense matrix from an existing one.
      Parameters:
      matrix - the dense matrix to copy
    • DenseMatrix

      protected DenseMatrix()
      Protected constructor for delayed initialization. Subclasses must ensure that data is properly initialized.
  • Method Details

    • addMatricesInPlaceStatic

      protected static void addMatricesInPlaceStatic(double alpha, org.ejml.data.DMatrix A, double beta, org.ejml.data.DMatrix B, org.ejml.data.DMatrix output)
    • addMatricesStatic

      protected static org.ejml.data.DMatrixRMaj addMatricesStatic(double alpha, org.ejml.data.DMatrix A, double beta, org.ejml.data.DMatrix B, org.ejml.data.DMatrix output)
    • addStatic

      protected static org.ejml.data.DMatrixRMaj addStatic(org.ejml.data.DMatrixRMaj A, org.ejml.data.DMatrixRMaj B, org.ejml.data.DMatrixRMaj output)
      Performs element-wise addition of two dense matrices: output = A + B.
      Parameters:
      A - the first matrix
      B - the second matrix
      output - the result matrix (can be null to create a new matrix)
      Returns:
      the sum matrix
    • changeSignStatic

      protected static void changeSignStatic(org.ejml.data.DMatrix input, org.ejml.data.DMatrix output)
    • determinantStatic

      protected static double determinantStatic(org.ejml.data.DMatrix matrix)
    • elementMultStatic

      protected static org.ejml.data.DMatrixRMaj elementMultStatic(org.ejml.data.DMatrix A, org.ejml.data.DMatrix B, org.ejml.data.DMatrix output)
    • extractMatrixStatic

      protected static void extractMatrixStatic(org.ejml.data.DMatrix src, int srcX0, int srcX1, int srcY0, int srcY1, org.ejml.data.DMatrix dst, int dstY0, int dstX0)
    • fillMatrixStatic

      protected static void fillMatrixStatic(org.ejml.data.DMatrix matrix, double value)
    • identityStatic

      protected static org.ejml.data.DMatrixRMaj identityStatic(int size)
      Creates an identity matrix of the specified size. An identity matrix has ones on the main diagonal and zeros elsewhere.
      Parameters:
      size - the number of rows and columns in the identity matrix
      Returns:
      a new identity matrix
    • invertStatic

      protected static void invertStatic(org.ejml.data.DMatrix input, org.ejml.data.DMatrix output)
    • kronStatic

      protected static org.ejml.data.DMatrixRMaj kronStatic(org.ejml.data.DMatrixRMaj A, org.ejml.data.DMatrixRMaj B, org.ejml.data.DMatrixRMaj output)
      Computes the Kronecker product of two dense matrices: A \otimes B. The Kronecker product creates a larger matrix where each element of A is multiplied by the entire matrix B.
      Parameters:
      A - the left matrix
      B - the right matrix
      output - the result matrix (can be null to create a new matrix)
      Returns:
      the Kronecker product matrix
    • multMatrixStatic

      protected static org.ejml.data.DMatrixRMaj multMatrixStatic(org.ejml.data.DMatrix A, org.ejml.data.DMatrix B, org.ejml.data.DMatrix output)
    • scaleMatrixStatic

      protected static void scaleMatrixStatic(double scalar, org.ejml.data.DMatrix input, org.ejml.data.DMatrix output)
    • transposeMatrixStatic

      protected static void transposeMatrixStatic(org.ejml.data.DMatrix input, org.ejml.data.DMatrix output)
    • absEq

      public void absEq()
      Description copied from class: BaseMatrix
      Replaces each value in the matrix with its absolute value, in-place.
      Specified by:
      absEq in class BaseMatrix
    • add

      protected void add(double alpha, org.ejml.data.DMatrix A, double beta, org.ejml.data.DMatrix B, org.ejml.data.DMatrix output)
      Performs the operation: output = alpha*A + beta*B.
      Parameters:
      alpha - scalar coefficient for matrix A
      A - first input matrix
      beta - scalar coefficient for matrix B
      B - second input matrix
      output - the result matrix
    • addMatrices

      protected org.ejml.data.DMatrix addMatrices(double alpha, org.ejml.data.DMatrix A, double beta, org.ejml.data.DMatrix B, org.ejml.data.DMatrix output)
      Description copied from class: BaseMatrix
      Performs the operation: output = alpha*A + beta*B.
      Specified by:
      addMatrices in class BaseMatrix
      Parameters:
      alpha - scalar coefficient for matrix A
      A - first input matrix
      beta - scalar coefficient for matrix B
      B - second input matrix
      output - the result matrix
    • addMatricesInPlace

      protected void addMatricesInPlace(double alpha, org.ejml.data.DMatrix A, double beta, org.ejml.data.DMatrix B, org.ejml.data.DMatrix output)
    • any

      public boolean any()
      Description copied from class: BaseMatrix
      Checks if the current matrix contains any non-zero elements.
      Specified by:
      any in class BaseMatrix
      Returns:
      true if at least one non-zero element exists; false otherwise.
    • applyConditionalTransform

      protected void applyConditionalTransform(double source, double target, double tol, String operation)
      Description copied from class: BaseMatrix
      Applies a transformation to matrix elements based on conditions. Replaces elements matching the condition with the target value.
      Specified by:
      applyConditionalTransform in class BaseMatrix
    • changeSign

      protected void changeSign()
      Specified by:
      changeSign in class BaseMatrix
    • copy

      public abstract BaseMatrix copy()
      Creates and returns a deep copy of this dense matrix.
      Specified by:
      copy in class BaseMatrix
      Returns:
      a new dense matrix that is a copy of this instance
    • colIncrease

      public void colIncrease(int col, double a)
      Description copied from class: BaseMatrix
      Adds a scalar value to each element in the specified column.
      Specified by:
      colIncrease in class BaseMatrix
      Parameters:
      col - Column index to update.
      a - Scalar value to add to each element in the column.
    • concatColumnsInPlace

      protected void concatColumnsInPlace(org.ejml.data.DMatrix left, org.ejml.data.DMatrix right, org.ejml.data.DMatrix output)
      Description copied from class: BaseMatrix
      Concatenates matrices column-wise.
      Specified by:
      concatColumnsInPlace in class BaseMatrix
      Parameters:
      left - the left matrix
      right - the right matrix
      output - the result matrix
    • concatRowsInPlace

      protected void concatRowsInPlace(org.ejml.data.DMatrix top, org.ejml.data.DMatrix bottom, org.ejml.data.DMatrix output)
      Description copied from class: BaseMatrix
      Concatenates matrices row-wise.
      Specified by:
      concatRowsInPlace in class BaseMatrix
      Parameters:
      top - the top matrix
      bottom - the bottom matrix
      output - the result matrix
    • countEachRow

      public BaseMatrix countEachRow(double val)
      Description copied from class: BaseMatrix
      Counts occurrences of each unique value in each row.
      Specified by:
      countEachRow in class BaseMatrix
    • createNewInstance

      protected abstract BaseMatrix createNewInstance(int rows, int cols, int nzLength)
      Creates a new instance of the concrete dense matrix implementation. This factory method allows the base class to create instances of the correct subtype.
      Specified by:
      createNewInstance in class BaseMatrix
      Parameters:
      rows - the number of rows for the new matrix
      cols - the number of columns for the new matrix
      nzLength - the initial capacity for non-zero elements (may be ignored by dense matrices)
      Returns:
      a new instance of the concrete dense matrix type
    • determinant

      protected double determinant()
      Specified by:
      determinant in class BaseMatrix
    • divideInPlace

      protected void divideInPlace(double scalar)
      Specified by:
      divideInPlace in class BaseMatrix
    • divideMatrix

      protected void divideMatrix(double scalar, org.ejml.data.DMatrix output)
      Specified by:
      divideMatrix in class BaseMatrix
    • divideRowsByArray

      protected void divideRowsByArray(double[] diag, int offset)
      Specified by:
      divideRowsByArray in class BaseMatrix
    • divideScalarByMatrix

      protected void divideScalarByMatrix(double scalar, org.ejml.data.DMatrix output)
      Specified by:
      divideScalarByMatrix in class BaseMatrix
    • elementMax

      protected double elementMax()
      Specified by:
      elementMax in class BaseMatrix
    • elementMaxAbs

      protected double elementMaxAbs()
      Specified by:
      elementMaxAbs in class BaseMatrix
    • elementMin

      protected double elementMin()
      Specified by:
      elementMin in class BaseMatrix
    • elementMult

      protected org.ejml.data.DMatrix elementMult(org.ejml.data.DMatrix A, org.ejml.data.DMatrix B, org.ejml.data.DMatrix output)
      Specified by:
      elementMult in class BaseMatrix
    • elementSum

      protected double elementSum()
      Specified by:
      elementSum in class BaseMatrix
    • equals

      public abstract boolean equals(Object obj)
      Indicates whether some other object is "equal to" this dense matrix.
      Specified by:
      equals in class BaseMatrix
      Parameters:
      obj - the reference object with which to compare
      Returns:
      true if this object is the same as the obj argument; false otherwise
    • extractMatrix

      protected void extractMatrix(org.ejml.data.DMatrix src, int srcX0, int srcX1, int srcY0, int srcY1, org.ejml.data.DMatrix dst, int dstY0, int dstX0)
      Specified by:
      extractMatrix in class BaseMatrix
    • fillMatrix

      protected void fillMatrix(double value)
      Description copied from class: BaseMatrix
      Fills the matrix with the specified value.
      Specified by:
      fillMatrix in class BaseMatrix
      Parameters:
      value - the value to fill the matrix with
    • findNonNegative

      public BaseMatrix findNonNegative()
      Description copied from class: BaseMatrix
      Returns a matrix containing indices of all non-negative elements.
      Specified by:
      findNonNegative in class BaseMatrix
    • get

      public double get(int row, int col)
      Returns the value at the specified matrix position.
      Specified by:
      get in class BaseMatrix
      Parameters:
      row - the row index
      col - the column index
      Returns:
      the value at position (row, col)
    • getColumnIndex

      protected int getColumnIndex(int col)
      Specified by:
      getColumnIndex in class BaseMatrix
    • getColumnIndicesArray

      protected int[] getColumnIndicesArray()
      Specified by:
      getColumnIndicesArray in class BaseMatrix
    • getData

      protected org.ejml.data.DMatrixRMaj getData()
      Returns the underlying EJML dense matrix data structure. This method provides direct access to the internal data for subclasses.
      Specified by:
      getData in class BaseMatrix
      Returns:
      the underlying DMatrixRMaj instance
    • setData

      protected void setData(org.ejml.data.DMatrixRMaj newData)
      Sets the underlying EJML dense matrix data structure. This method allows subclasses to replace the internal data.
      Parameters:
      newData - the new DMatrixRMaj instance to use
    • setData

      public void setData(org.ejml.data.DMatrix newData)
      Sets the underlying EJML dense matrix data structure. This method allows subclasses to replace the internal data.
      Parameters:
      newData - the new DMatrix instance to use
    • setData

      protected void setData(Object newData)
      Description copied from class: BaseMatrix
      Sets the underlying data structure. Implementation depends on the concrete matrix type.
      Specified by:
      setData in class BaseMatrix
      Parameters:
      newData - the new data structure
    • getNonZeroLength

      public int getNonZeroLength()
      Description copied from class: BaseMatrix
      Returns the number of stored non-zero elements. This may be different from actual non-zero count for dense matrices.
      Specified by:
      getNonZeroLength in class BaseMatrix
      Returns:
      number of stored non-zero elements
    • setNonZeroLength

      protected void setNonZeroLength(int length)
      Specified by:
      setNonZeroLength in class BaseMatrix
    • getNonZeroRow

      protected int getNonZeroRow(int index)
      Specified by:
      getNonZeroRow in class BaseMatrix
    • getNonZeroRows

      public int[] getNonZeroRows()
      Description copied from class: BaseMatrix
      Returns array of row indices of non-zero entries. For dense matrices, this may compute row indices dynamically. For sparse matrices, this returns the compressed row index array.
      Specified by:
      getNonZeroRows in class BaseMatrix
      Returns:
      array of row indices
    • getNonZeroValue

      protected double getNonZeroValue(int index)
      Specified by:
      getNonZeroValue in class BaseMatrix
    • getNonZeroValues

      public double[] getNonZeroValues()
      Description copied from class: BaseMatrix
      Returns array of non-zero values. For dense matrices, this may return all values or only actual non-zeros. For sparse matrices, this returns the compressed storage array.
      Specified by:
      getNonZeroValues in class BaseMatrix
      Returns:
      array of non-zero values
    • getNonZeros

      public int getNonZeros()
      Description copied from class: BaseMatrix
      Returns the number of non-zero elements in the matrix. For dense matrices, this counts actual non-zero values. For sparse matrices, this returns the stored non-zero count.
      Specified by:
      getNonZeros in class BaseMatrix
      Returns:
      the number of non-zero elements
    • getNumCols

      public int getNumCols()
      Returns the number of columns in the matrix.
      Specified by:
      getNumCols in class BaseMatrix
      Returns:
      the number of columns
    • getNumRows

      public int getNumRows()
      Returns the number of rows in the matrix.
      Specified by:
      getNumRows in class BaseMatrix
      Returns:
      the number of rows
    • hasDuplicates

      public boolean hasDuplicates()
      Description copied from class: BaseMatrix
      Checks if the matrix contains duplicate values.
      Specified by:
      hasDuplicates in class BaseMatrix
      Returns:
      true if duplicates exist
    • hasFinite

      public boolean hasFinite()
      Description copied from class: BaseMatrix
      Checks if the matrix contains any finite (non-infinite, non-NaN) values.
      Specified by:
      hasFinite in class BaseMatrix
      Returns:
      true if at least one finite value exists
    • hasInfinite

      public boolean hasInfinite()
      Description copied from class: BaseMatrix
      Checks if the matrix contains any infinite values.
      Specified by:
      hasInfinite in class BaseMatrix
      Returns:
      true if at least one infinite value exists
    • hasMultipleFinite

      public boolean hasMultipleFinite()
      Description copied from class: BaseMatrix
      Checks if more than one finite value exists.
      Specified by:
      hasMultipleFinite in class BaseMatrix
      Returns:
      true if more than one finite value exists
    • hasNaN

      public boolean hasNaN()
      Description copied from class: BaseMatrix
      Checks if the matrix contains any NaN values.
      Specified by:
      hasNaN in class BaseMatrix
      Returns:
      true if at least one NaN exists
    • mult

      protected void mult(org.ejml.data.DMatrix A, org.ejml.data.DMatrix B, org.ejml.data.DMatrix output)
      Performs matrix multiplication: output = A * B.
      Parameters:
      A - the left matrix
      B - the right matrix
      output - the result matrix
    • multMatrix

      protected org.ejml.data.DMatrix multMatrix(org.ejml.data.DMatrix B, org.ejml.data.DMatrix output)
      Description copied from class: BaseMatrix
      Performs matrix multiplication with sparse matrices.
      Specified by:
      multMatrix in class BaseMatrix
      Parameters:
      B - the right matrix
      output - the result matrix
    • removeZeros

      protected void removeZeros()
      Description copied from class: BaseMatrix
      Removes zero-valued elements from the matrix with default tolerance. For dense matrices, this may be a no-op or convert to sparse representation.
      Specified by:
      removeZeros in class BaseMatrix
    • removeZerosWithTol

      protected void removeZerosWithTol(double tolerance)
      Description copied from class: BaseMatrix
      Removes zero-valued elements from the matrix with specified tolerance.
      Specified by:
      removeZerosWithTol in class BaseMatrix
      Parameters:
      tolerance - the tolerance for considering values as zero
    • reshape

      public void reshape(int numRows, int numCols)
      Reshapes the matrix to the specified dimensions.
      Specified by:
      reshape in class BaseMatrix
      Parameters:
      numRows - the new number of rows
      numCols - the new number of columns
    • scaleInPlace

      protected void scaleInPlace(double alpha)
      Description copied from class: BaseMatrix
      Scales the matrix in-place by the specified factor.
      Specified by:
      scaleInPlace in class BaseMatrix
      Parameters:
      alpha - the scaling factor
    • scaleMatrix

      protected void scaleMatrix(double scalar, org.ejml.data.DMatrix output)
      Specified by:
      scaleMatrix in class BaseMatrix
    • set

      public void set(int row, int col, double value)
      Sets the value at the specified matrix position.
      Specified by:
      set in class BaseMatrix
      Parameters:
      row - the row index
      col - the column index
      value - the value to set
    • setColumnIndex

      protected void setColumnIndex(int col, int value)
      Specified by:
      setColumnIndex in class BaseMatrix
    • setNonZeroRow

      protected void setNonZeroRow(int index, int row)
      Specified by:
      setNonZeroRow in class BaseMatrix
    • setNonZeroValue

      protected void setNonZeroValue(int index, double value)
      Specified by:
      setNonZeroValue in class BaseMatrix
    • shrinkNumCols

      public void shrinkNumCols(int newmax)
      Description copied from class: BaseMatrix
      Reduce the maximum number of columns by setting the internal column count.
      Specified by:
      shrinkNumCols in class BaseMatrix
      Parameters:
      newmax - the new maximum number of columns
    • shrinkNumRows

      public void shrinkNumRows(int newmax)
      Description copied from class: BaseMatrix
      Reduce the maximum number of rows by setting the internal row count.
      Specified by:
      shrinkNumRows in class BaseMatrix
      Parameters:
      newmax - the new maximum number of rows
    • sumColsRaw

      protected org.ejml.data.DMatrix sumColsRaw()
      Specified by:
      sumColsRaw in class BaseMatrix
    • sumRowsRaw

      protected org.ejml.data.DMatrix sumRowsRaw()
      Specified by:
      sumRowsRaw in class BaseMatrix
    • toString

      public String toString()
      Returns a string representation of the matrix. Elements are formatted to 4 decimal places in a grid layout.
      Overrides:
      toString in class BaseMatrix
      Returns:
      a formatted string representation of the matrix
    • transpose

      protected void transpose(org.ejml.data.DMatrix input, org.ejml.data.DMatrix output)
      Computes the transpose of the input matrix.
      Parameters:
      input - the matrix to transpose
      output - the transposed matrix
    • transposeMatrix

      protected void transposeMatrix(org.ejml.data.DMatrix output)
      Description copied from class: BaseMatrix
      Computes the transpose of this matrix.
      Specified by:
      transposeMatrix in class BaseMatrix
      Parameters:
      output - the transposed matrix
    • zero

      public void zero()
      Sets all elements in the matrix to zero.
      Specified by:
      zero in class BaseMatrix