Class SymmMatrix

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

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, double[][] AP)
      Constructor.
      Parameters:
      uplo - the symmetric matrix stores the upper or lower triangle.
      AP - the symmetric matrix.
  • Method Details

    • clone

      public SymmMatrix clone()
      Overrides:
      clone in class Object
    • 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 simplify 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, double 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 double 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, double 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, double alpha, double[] x, double beta, double[] 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 then y need not be set on input.
      y - the input and output vector.
    • mv

      public void mv(double[] 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(double[] 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.