Class SymmMatrix

java.lang.Object
smile.math.matrix.fp32.IMatrix
smile.math.matrix.fp32.SymmMatrix
All Implemented Interfaces:
Serializable

public class SymmMatrix extends IMatrix
The symmetric matrix in packed storage.
See Also:
  • Constructor Details

    • SymmMatrix

      public SymmMatrix(UPLO uplo, int n)
      Constructor.
      Parameters:
      uplo - the symmetric matrix stores the upper or lower triangle.
      n - the dimension of matrix.
    • SymmMatrix

      public SymmMatrix(UPLO uplo, float[][] AP)
      Constructor.
      Parameters:
      uplo - the symmetric matrix stores the upper or lower triangle.
      AP - the symmetric matrix.
  • Method Details

    • copy

      public SymmMatrix copy()
      Description copied from class: IMatrix
      Returns a deep copy of matrix.
      Overrides:
      copy in class IMatrix
      Returns:
      a deep copy of matrix.
    • nrow

      public int nrow()
      Description copied from class: IMatrix
      Returns the number of rows.
      Specified by:
      nrow in class IMatrix
      Returns:
      the number of rows.
    • ncol

      public int ncol()
      Description copied from class: IMatrix
      Returns the number of columns.
      Specified by:
      ncol in class IMatrix
      Returns:
      the number of columns.
    • size

      public long size()
      Description copied from class: IMatrix
      Returns the number of stored matrix elements. For conventional matrix, it is simply nrow * ncol. But it is usually much less for band, packed or sparse matrix.
      Specified by:
      size in class IMatrix
      Returns:
      the number of stored matrix elements.
    • layout

      public Layout layout()
      Returns the matrix layout.
      Returns:
      the matrix layout.
    • uplo

      public UPLO uplo()
      Gets the format of packed matrix.
      Returns:
      the format of packed matrix.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • equals

      public boolean equals(SymmMatrix o, float epsilon)
      Returns true if two matrices equal in given precision.
      Parameters:
      o - the other matrix.
      epsilon - a number close to zero.
      Returns:
      true if two matrices equal in given precision.
    • get

      public float get(int i, int j)
      Description copied from class: IMatrix
      Returns A[i,j].
      Overrides:
      get in class IMatrix
      Parameters:
      i - the row index.
      j - the column index.
      Returns:
      the matrix cell value.
    • set

      public void set(int i, int j, float x)
      Description copied from class: IMatrix
      Sets A[i,j] = x.
      Overrides:
      set in class IMatrix
      Parameters:
      i - the row index.
      j - the column index.
      x - the matrix cell value.
    • mv

      public void mv(Transpose trans, float alpha, float[] x, float beta, float[] y)
      Description copied from class: IMatrix
      Matrix-vector multiplication.
      
           y = alpha * op(A) * x + beta * y
       
      where op is the transpose operation.
      Specified by:
      mv in class IMatrix
      Parameters:
      trans - normal, transpose, or conjugate transpose operation on the matrix.
      alpha - the scalar alpha.
      x - the input vector.
      beta - the scalar beta. When beta is supplied as zero, y need not be set on input.
      y - the input and output vector.
    • mv

      public void mv(float[] work, int inputOffset, int outputOffset)
      Description copied from class: IMatrix
      Matrix-vector multiplication A * x.
      Specified by:
      mv in class IMatrix
      Parameters:
      work - the workspace for both input and output vector.
      inputOffset - the offset of input vector in workspace.
      outputOffset - the offset of output vector in workspace.
    • tv

      public void tv(float[] work, int inputOffset, int outputOffset)
      Description copied from class: IMatrix
      Matrix-vector multiplication A' * x.
      Specified by:
      tv in class IMatrix
      Parameters:
      work - the workspace for both input and output vector.
      inputOffset - the offset of input vector in workspace.
      outputOffset - the offset of output vector in workspace.
    • bk

      Bunch-Kaufman decomposition.
      Returns:
      Bunch-Kaufman decomposition.
    • cholesky

      public SymmMatrix.Cholesky cholesky()
      Cholesky decomposition for symmetric and positive definite matrix.
      Returns:
      Cholesky decomposition.
      Throws:
      ArithmeticException - if the matrix is not positive definite.